Skip to content

Commit eb11a69

Browse files
committed
Detect connector regsitry from cluster
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 2017859 commit eb11a69

File tree

5,175 files changed

+1169759
-1385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,175 files changed

+1169759
-1385
lines changed

cmd/demo-server/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var links = map[string]shared.LinkData{}
3838
func genLink(fs blobfs.Interface, bs *lib.BlobStore, reg repo.IRegistry, u shared.User, req shared.LinkRequest) (*shared.Link, error) {
3939
now := time.Now()
4040

41-
l, err := link.Generate(bs, reg, kubeops.ClusterConnectorSpec{
41+
l, err := link.Generate(nil, bs, reg, kubeops.ClusterConnectorSpec{
4242
LinkID: "",
4343
Nats: kubeops.ClusterConnectorNats{},
4444
})

go.mod

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,12 @@ require (
3030
k8s.io/klog/v2 v2.80.1
3131
kmodules.xyz/client-go v0.25.39
3232
kmodules.xyz/custom-resources v0.25.1
33+
kmodules.xyz/resource-metadata v0.17.32
3334
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a
3435
kubepack.dev/kubepack v0.7.1-0.20231006154337-32460f637e2c
3536
kubepack.dev/lib-helm v0.7.3
3637
sigs.k8s.io/controller-runtime v0.13.1
37-
x-helm.dev/apimachinery v0.0.12
38-
)
39-
40-
require (
41-
github.com/google/s2a-go v0.1.4 // indirect
42-
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
43-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
38+
x-helm.dev/apimachinery v0.0.15
4439
)
4540

4641
require (
@@ -146,6 +141,7 @@ require (
146141
github.com/google/go-cmp v0.5.9 // indirect
147142
github.com/google/go-containerregistry v0.13.0 // indirect
148143
github.com/google/gofuzz v1.2.0 // indirect
144+
github.com/google/s2a-go v0.1.4 // indirect
149145
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
150146
github.com/google/uuid v1.3.0 // indirect
151147
github.com/google/wire v0.5.0 // indirect
@@ -154,6 +150,7 @@ require (
154150
github.com/gorilla/mux v1.8.0 // indirect
155151
github.com/gosuri/uitable v0.0.4 // indirect
156152
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
153+
github.com/hashicorp/golang-lru v0.5.4 // indirect
157154
github.com/huandu/xstrings v1.3.2 // indirect
158155
github.com/imdario/mergo v0.3.13 // indirect
159156
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -241,6 +238,8 @@ require (
241238
google.golang.org/api v0.126.0 // indirect
242239
google.golang.org/appengine v1.6.7 // indirect
243240
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
241+
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
242+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
244243
google.golang.org/grpc v1.55.0 // indirect
245244
google.golang.org/protobuf v1.31.0 // indirect
246245
gopkg.in/inf.v0 v0.9.1 // indirect
@@ -257,8 +256,7 @@ require (
257256
kmodules.xyz/apiversion v0.2.0 // indirect
258257
kmodules.xyz/apply v0.25.0 // indirect
259258
kmodules.xyz/offshoot-api v0.25.0 // indirect
260-
kmodules.xyz/resource-metadata v0.17.18 // indirect
261-
kmodules.xyz/resource-metrics v0.25.2 // indirect
259+
kmodules.xyz/resource-metrics v0.25.7 // indirect
262260
oras.land/oras-go v1.2.0 // indirect
263261
sigs.k8s.io/cli-utils v0.34.0 // indirect
264262
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect

go.sum

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA
637637
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
638638
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
639639
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
640+
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
640641
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
641642
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
642643
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
@@ -1750,10 +1751,10 @@ kmodules.xyz/custom-resources v0.25.1 h1:0qHPTxbT/q0afl2GCOnwPFaoxKziRIPXgVu77Yw
17501751
kmodules.xyz/custom-resources v0.25.1/go.mod h1:ULwzvLmOqZJcPSXKI7iLclYL5eYRlKx8Nbex28Ht19E=
17511752
kmodules.xyz/offshoot-api v0.25.0 h1:Svq9da/+sg5afOjpgo9vx2J/Lu90Mo0aFxkdQmgKnGI=
17521753
kmodules.xyz/offshoot-api v0.25.0/go.mod h1:ysEBn7LJuT3+s8ynAQA/OG0BSsJugXa6KGtDLMRjlKo=
1753-
kmodules.xyz/resource-metadata v0.17.18 h1:mlCsR4VQX0R9l0+gZeErbQ1UOR+T49+7ox4LstDRVFU=
1754-
kmodules.xyz/resource-metadata v0.17.18/go.mod h1:UTlIPNpIvl9jbLdTrLznCx8dLJO0Z798bcQi6SSovlo=
1755-
kmodules.xyz/resource-metrics v0.25.2 h1:BwCb6qyunvQBa0u8UUkw+wYG5/T4qtNtAKcHjSsk0JU=
1756-
kmodules.xyz/resource-metrics v0.25.2/go.mod h1:ZK/52NLuwMk+Jt0bmUtGQHtSxPLYYpsFILG7SJhYPg0=
1754+
kmodules.xyz/resource-metadata v0.17.32 h1:BNNMUDyX/SPMXGWXV0xFWgVKamUB9W4mYDdfEzTxXeo=
1755+
kmodules.xyz/resource-metadata v0.17.32/go.mod h1:CD/2w4nUcoL9tyRiI+J6LtRckOa6QXE4M+bxI3vsdYE=
1756+
kmodules.xyz/resource-metrics v0.25.7 h1:ne2cK/dlnfYcuu0+pHX15Y53rcKBQq9DuCtQVcx6rY8=
1757+
kmodules.xyz/resource-metrics v0.25.7/go.mod h1:y7pDmTWuVLNGSjwckKCwJFhCgi5fhbwS7PAcH2rmGcY=
17571758
kmodules.xyz/schema-checker v0.4.1 h1:V5UEjR6UMAXf307lTgw+9rDRfHLTNA8g/q9DngqYI9M=
17581759
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a h1:yZ+9LE3hPmNK1TOQYXKZRffqAzmthDzgd+PBt7TMS9A=
17591760
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a/go.mod h1:+xr9fH5yMN6OAaxHjODVIsxdfGmpB1h67Noj77CwBdg=
@@ -1784,5 +1785,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ih
17841785
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
17851786
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
17861787
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
1787-
x-helm.dev/apimachinery v0.0.12 h1:lEuGH5F+6xqL7/uL+SsoOUXeJZFgC8c2OQgtMMj/fQM=
1788-
x-helm.dev/apimachinery v0.0.12/go.mod h1:jjkebU6uv/cS/8pQGE8tbgK/rB39yh4ETiAglPbDWZc=
1788+
x-helm.dev/apimachinery v0.0.15 h1:+q1bdvVdDC311RRboRcWk0P2aaM5ZyOhxN/H+VJzJTs=
1789+
x-helm.dev/apimachinery v0.0.15/go.mod h1:wpYBmu0U/uETX6Kv6TXequ9FPmhI24KquLK2B30wOs8=

pkg/link/lib.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ import (
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/types"
32-
kmapi "kmodules.xyz/client-go/api/v1"
32+
"kmodules.xyz/resource-metadata/hub"
3333
"kubepack.dev/kubepack/pkg/lib"
3434
"kubepack.dev/lib-helm/pkg/repo"
35+
"sigs.k8s.io/controller-runtime/pkg/client"
3536
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
3637
)
3738

38-
func Generate(bs *lib.BlobStore, reg repo.IRegistry, cv kubeops.ClusterConnectorSpec) (*shared.Link, error) {
39-
order, err := NewOrder(shared.ConnectorChartURL, shared.ConnectorChartName, shared.ConnectorChartVersion, cv)
39+
func Generate(kc client.Client, bs *lib.BlobStore, reg repo.IRegistry, cv kubeops.ClusterConnectorSpec) (*shared.Link, error) {
40+
order, err := NewOrder(kc, cv)
4041
if err != nil {
4142
return nil, err
4243
}
@@ -59,7 +60,7 @@ func NewBlobStore() (*lib.BlobStore, error) {
5960
}, nil
6061
}
6162

62-
func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*releasesapi.Order, error) {
63+
func NewOrder(kc client.Client, cc kubeops.ClusterConnectorSpec) (*releasesapi.Order, error) {
6364
if len(cc.LinkID) == 0 {
6465
cc.LinkID = xid.New().String()
6566
}
@@ -74,7 +75,7 @@ func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*rele
7475
APIVersion: releasesapi.GroupVersion.String(),
7576
Kind: releasesapi.ResourceKindOrder,
7677
}, ObjectMeta: metav1.ObjectMeta{
77-
Name: name,
78+
Name: shared.ChartClusterConnector,
7879
UID: types.UID(cc.LinkID), // using ulids instead of UUID
7980
CreationTimestamp: metav1.NewTime(time.Now()),
8081
},
@@ -83,17 +84,12 @@ func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*rele
8384
{
8485
Chart: &releasesapi.ChartSelection{
8586
ChartRef: releasesapi.ChartRef{
86-
Name: name,
87-
SourceRef: kmapi.TypedObjectReference{
88-
APIGroup: releasesapi.SourceGroupLegacy,
89-
Kind: releasesapi.SourceKindLegacy,
90-
Namespace: "",
91-
Name: url,
92-
},
87+
Name: shared.ChartClusterConnector,
88+
SourceRef: hub.BootstrapHelmRepository(kc),
9389
},
94-
Version: version,
95-
ReleaseName: name,
96-
Namespace: "kubeops", // change to kubeops or bytebuilders?
90+
Version: hub.FeatureVersion(kc, shared.ChartClusterConnector),
91+
ReleaseName: shared.ChartClusterConnector,
92+
Namespace: hub.BootstrapHelmRepositoryNamespace(),
9793
Bundle: nil,
9894
// ValuesFile: "values.yaml",
9995
ValuesPatch: &runtime.RawExtension{Raw: patch},

pkg/shared/connector.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ const (
3838
ConnectorLinkLifetime = 10 * time.Minute
3939
)
4040

41-
var (
42-
ConnectorChartURL = "https://charts.appscode.com/stable"
43-
ConnectorChartName = "cluster-connector"
44-
ConnectorChartVersion = "" // "v0.1.0"
45-
)
41+
var ChartClusterConnector = "cluster-connector"
4642

4743
const (
4844
ConnectorLinkManifestBucket = "gs://connect.bytebuilders.link"

vendor/github.com/hashicorp/golang-lru/.gitignore

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)