Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
m1kola committed Mar 4, 2024
1 parent 0e621b2 commit 919369a
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,41 @@ func main() {
URL: *storageURL,
}

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
cacheOptions := cache.Options{
Scheme: scheme,
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultNamespaces: map[string]cache.Config{
systemNamespace: {},
cache.AllNamespaces: {LabelSelector: dependentSelector},
},
ByObject: map[client.Object]cache.ByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultNamespaces: map[string]cache.Config{
systemNamespace: {},
cache.AllNamespaces: {LabelSelector: dependentSelector},
},
}
cache, err := cache.New(cfg, cacheOptions)
if err != nil {
setupLog.Error(err, "unable to create cache for the manager")
os.Exit(1)
}

clientOptions := client.Options{
Scheme: scheme,
Cache: &client.CacheOptions{
Reader: cache,
},
}
client, err := client.New(cfg, clientOptions)
if err != nil {
setupLog.Error(err, "unable to create client for the manager")
os.Exit(1)
}

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Cache: cacheOptions,
Client: clientOptions,
// TODO: Consider using a closure for NewCache
// TODO: Consider using a closure for NewClient
Metrics: server.Options{
BindAddress: httpBindAddr,
ExtraHandlers: map[string]http.Handler{
Expand All @@ -160,7 +183,7 @@ func main() {
// controller-runtime runs when MetricsBindAddress is configured on the
// manager.
"/bundles/": httpLogger(localStorage),
"/uploads/": httpLogger(uploadmgr.NewUploadHandler(mgr.GetClient(), uploadStorageDirectory)),
"/uploads/": httpLogger(uploadmgr.NewUploadHandler(client, uploadStorageDirectory)),
},
},
HealthProbeBindAddress: probeAddr,
Expand Down

0 comments on commit 919369a

Please sign in to comment.