Skip to content

Commit

Permalink
Detect connector regsitry from cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 28, 2023
1 parent 2017859 commit eb11a69
Show file tree
Hide file tree
Showing 5,175 changed files with 1,169,759 additions and 1,385 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion cmd/demo-server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var links = map[string]shared.LinkData{}
func genLink(fs blobfs.Interface, bs *lib.BlobStore, reg repo.IRegistry, u shared.User, req shared.LinkRequest) (*shared.Link, error) {
now := time.Now()

l, err := link.Generate(bs, reg, kubeops.ClusterConnectorSpec{
l, err := link.Generate(nil, bs, reg, kubeops.ClusterConnectorSpec{
LinkID: "",
Nats: kubeops.ClusterConnectorNats{},
})
Expand Down
16 changes: 7 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ require (
k8s.io/klog/v2 v2.80.1
kmodules.xyz/client-go v0.25.39
kmodules.xyz/custom-resources v0.25.1
kmodules.xyz/resource-metadata v0.17.32
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a
kubepack.dev/kubepack v0.7.1-0.20231006154337-32460f637e2c
kubepack.dev/lib-helm v0.7.3
sigs.k8s.io/controller-runtime v0.13.1
x-helm.dev/apimachinery v0.0.12
)

require (
github.com/google/s2a-go v0.1.4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
x-helm.dev/apimachinery v0.0.15
)

require (
Expand Down Expand Up @@ -146,6 +141,7 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-containerregistry v0.13.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/wire v0.5.0 // indirect
Expand All @@ -154,6 +150,7 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down Expand Up @@ -241,6 +238,8 @@ require (
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -257,8 +256,7 @@ require (
kmodules.xyz/apiversion v0.2.0 // indirect
kmodules.xyz/apply v0.25.0 // indirect
kmodules.xyz/offshoot-api v0.25.0 // indirect
kmodules.xyz/resource-metadata v0.17.18 // indirect
kmodules.xyz/resource-metrics v0.25.2 // indirect
kmodules.xyz/resource-metrics v0.25.7 // indirect
oras.land/oras-go v1.2.0 // indirect
sigs.k8s.io/cli-utils v0.34.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
13 changes: 7 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
Expand Down Expand Up @@ -1750,10 +1751,10 @@ kmodules.xyz/custom-resources v0.25.1 h1:0qHPTxbT/q0afl2GCOnwPFaoxKziRIPXgVu77Yw
kmodules.xyz/custom-resources v0.25.1/go.mod h1:ULwzvLmOqZJcPSXKI7iLclYL5eYRlKx8Nbex28Ht19E=
kmodules.xyz/offshoot-api v0.25.0 h1:Svq9da/+sg5afOjpgo9vx2J/Lu90Mo0aFxkdQmgKnGI=
kmodules.xyz/offshoot-api v0.25.0/go.mod h1:ysEBn7LJuT3+s8ynAQA/OG0BSsJugXa6KGtDLMRjlKo=
kmodules.xyz/resource-metadata v0.17.18 h1:mlCsR4VQX0R9l0+gZeErbQ1UOR+T49+7ox4LstDRVFU=
kmodules.xyz/resource-metadata v0.17.18/go.mod h1:UTlIPNpIvl9jbLdTrLznCx8dLJO0Z798bcQi6SSovlo=
kmodules.xyz/resource-metrics v0.25.2 h1:BwCb6qyunvQBa0u8UUkw+wYG5/T4qtNtAKcHjSsk0JU=
kmodules.xyz/resource-metrics v0.25.2/go.mod h1:ZK/52NLuwMk+Jt0bmUtGQHtSxPLYYpsFILG7SJhYPg0=
kmodules.xyz/resource-metadata v0.17.32 h1:BNNMUDyX/SPMXGWXV0xFWgVKamUB9W4mYDdfEzTxXeo=
kmodules.xyz/resource-metadata v0.17.32/go.mod h1:CD/2w4nUcoL9tyRiI+J6LtRckOa6QXE4M+bxI3vsdYE=
kmodules.xyz/resource-metrics v0.25.7 h1:ne2cK/dlnfYcuu0+pHX15Y53rcKBQq9DuCtQVcx6rY8=
kmodules.xyz/resource-metrics v0.25.7/go.mod h1:y7pDmTWuVLNGSjwckKCwJFhCgi5fhbwS7PAcH2rmGcY=
kmodules.xyz/schema-checker v0.4.1 h1:V5UEjR6UMAXf307lTgw+9rDRfHLTNA8g/q9DngqYI9M=
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a h1:yZ+9LE3hPmNK1TOQYXKZRffqAzmthDzgd+PBt7TMS9A=
kubeops.dev/installer v0.0.0-20231014011242-de802328b14a/go.mod h1:+xr9fH5yMN6OAaxHjODVIsxdfGmpB1h67Noj77CwBdg=
Expand Down Expand Up @@ -1784,5 +1785,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ih
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
x-helm.dev/apimachinery v0.0.12 h1:lEuGH5F+6xqL7/uL+SsoOUXeJZFgC8c2OQgtMMj/fQM=
x-helm.dev/apimachinery v0.0.12/go.mod h1:jjkebU6uv/cS/8pQGE8tbgK/rB39yh4ETiAglPbDWZc=
x-helm.dev/apimachinery v0.0.15 h1:+q1bdvVdDC311RRboRcWk0P2aaM5ZyOhxN/H+VJzJTs=
x-helm.dev/apimachinery v0.0.15/go.mod h1:wpYBmu0U/uETX6Kv6TXequ9FPmhI24KquLK2B30wOs8=
26 changes: 11 additions & 15 deletions pkg/link/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/resource-metadata/hub"
"kubepack.dev/kubepack/pkg/lib"
"kubepack.dev/lib-helm/pkg/repo"
"sigs.k8s.io/controller-runtime/pkg/client"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
)

func Generate(bs *lib.BlobStore, reg repo.IRegistry, cv kubeops.ClusterConnectorSpec) (*shared.Link, error) {
order, err := NewOrder(shared.ConnectorChartURL, shared.ConnectorChartName, shared.ConnectorChartVersion, cv)
func Generate(kc client.Client, bs *lib.BlobStore, reg repo.IRegistry, cv kubeops.ClusterConnectorSpec) (*shared.Link, error) {
order, err := NewOrder(kc, cv)
if err != nil {
return nil, err
}
Expand All @@ -59,7 +60,7 @@ func NewBlobStore() (*lib.BlobStore, error) {
}, nil
}

func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*releasesapi.Order, error) {
func NewOrder(kc client.Client, cc kubeops.ClusterConnectorSpec) (*releasesapi.Order, error) {
if len(cc.LinkID) == 0 {
cc.LinkID = xid.New().String()
}
Expand All @@ -74,7 +75,7 @@ func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*rele
APIVersion: releasesapi.GroupVersion.String(),
Kind: releasesapi.ResourceKindOrder,
}, ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: shared.ChartClusterConnector,
UID: types.UID(cc.LinkID), // using ulids instead of UUID
CreationTimestamp: metav1.NewTime(time.Now()),
},
Expand All @@ -83,17 +84,12 @@ func NewOrder(url, name, version string, cc kubeops.ClusterConnectorSpec) (*rele
{
Chart: &releasesapi.ChartSelection{
ChartRef: releasesapi.ChartRef{
Name: name,
SourceRef: kmapi.TypedObjectReference{
APIGroup: releasesapi.SourceGroupLegacy,
Kind: releasesapi.SourceKindLegacy,
Namespace: "",
Name: url,
},
Name: shared.ChartClusterConnector,
SourceRef: hub.BootstrapHelmRepository(kc),
},
Version: version,
ReleaseName: name,
Namespace: "kubeops", // change to kubeops or bytebuilders?
Version: hub.FeatureVersion(kc, shared.ChartClusterConnector),
ReleaseName: shared.ChartClusterConnector,
Namespace: hub.BootstrapHelmRepositoryNamespace(),
Bundle: nil,
// ValuesFile: "values.yaml",
ValuesPatch: &runtime.RawExtension{Raw: patch},
Expand Down
6 changes: 1 addition & 5 deletions pkg/shared/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ const (
ConnectorLinkLifetime = 10 * time.Minute
)

var (
ConnectorChartURL = "https://charts.appscode.com/stable"
ConnectorChartName = "cluster-connector"
ConnectorChartVersion = "" // "v0.1.0"
)
var ChartClusterConnector = "cluster-connector"

const (
ConnectorLinkManifestBucket = "gs://connect.bytebuilders.link"
Expand Down
23 changes: 23 additions & 0 deletions vendor/github.com/hashicorp/golang-lru/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb11a69

Please sign in to comment.