Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pv-532
Browse files Browse the repository at this point in the history
  • Loading branch information
filariow committed Sep 23, 2024
2 parents 306b6d6 + cbd0f40 commit fd3e191
Show file tree
Hide file tree
Showing 17 changed files with 1,073 additions and 759 deletions.
33 changes: 18 additions & 15 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/registration-service/pkg/auth"
"github.com/codeready-toolchain/registration-service/pkg/configuration"
"github.com/codeready-toolchain/registration-service/pkg/informers"
"github.com/codeready-toolchain/registration-service/pkg/log"
"github.com/codeready-toolchain/registration-service/pkg/proxy"
"github.com/codeready-toolchain/registration-service/pkg/proxy/metrics"
Expand Down Expand Up @@ -85,12 +84,7 @@ func main() {
}
}

informer, informerShutdown, err := informers.StartInformer(cfg)
if err != nil {
panic(err.Error())
}

app, err := server.NewInClusterApplication(*informer)
app, err := server.NewInClusterApplication(cl)
if err != nil {
panic(err.Error())
}
Expand Down Expand Up @@ -121,11 +115,6 @@ func main() {
}
proxySrv := p.StartProxy(proxy.DefaultPort)

// stop the informer when proxy server shuts down
proxySrv.RegisterOnShutdown(func() {
informerShutdown <- struct{}{}
})

// ---------------------------------------------
// Registration Service
// ---------------------------------------------
Expand Down Expand Up @@ -202,9 +191,23 @@ func newCachedClient(ctx context.Context, cfg *rest.Config) (client.Client, erro

// populate the cache backed by shared informers that are initialized lazily on the first call
// for the given GVK with all resources we are interested in from the host-operator namespace
objectsToList := []client.ObjectList{&toolchainv1alpha1.ToolchainConfigList{}, &corev1.SecretList{}}
for i := range objectsToList {
if err := hostCluster.GetClient().List(ctx, objectsToList[i], client.InNamespace(configuration.Namespace())); err != nil {
objectsToList := map[string]client.ObjectList{
"MasterUserRecord": &toolchainv1alpha1.MasterUserRecordList{},
"Space": &toolchainv1alpha1.SpaceList{},
"SpaceBinding": &toolchainv1alpha1.SpaceBindingList{},
"ToolchainStatus": &toolchainv1alpha1.ToolchainStatusList{},
"UserSignup": &toolchainv1alpha1.UserSignupList{},
"ProxyPlugin": &toolchainv1alpha1.ProxyPluginList{},
"NSTemplateTier": &toolchainv1alpha1.NSTemplateTierList{},
"ToolchainConfig": &toolchainv1alpha1.ToolchainConfigList{},
"BannedUser": &toolchainv1alpha1.BannedUserList{},
"ToolchainCluster": &toolchainv1alpha1.ToolchainClusterList{},
"Secret": &corev1.SecretList{}}

for resourceName := range objectsToList {
log.Infof(nil, "Syncing informer cache with %s resources", resourceName)
if err := hostCluster.GetClient().List(ctx, objectsToList[resourceName], client.InNamespace(configuration.Namespace())); err != nil {
log.Errorf(nil, err, "Informer cache sync failed for %s", resourceName)
return nil, err
}
}
Expand Down
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ require (
cloud.google.com/go/auth v0.3.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
Expand All @@ -67,6 +71,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/huandu/xstrings v1.3.1 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
Expand All @@ -77,7 +82,12 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/migueleliasweb/go-github-mock v0.0.18 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/redhat-cop/operator-utils v1.3.3-0.20220121120056-862ef22b8cdf // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
Expand All @@ -94,6 +104,7 @@ require (
google.golang.org/grpc v1.63.2 // indirect
k8s.io/apiextensions-apiserver v0.25.0 // indirect
k8s.io/component-base v0.25.0 // indirect
k8s.io/kubectl v0.24.0 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
)

Expand Down
Loading

0 comments on commit fd3e191

Please sign in to comment.