Skip to content

Commit

Permalink
fixed breaking changes in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
asiyani committed Sep 11, 2023
1 parent 61a4648 commit 21072b1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
runTimeMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

tfaplv1beta1 "github.com/utilitywarehouse/terraform-applier/api/v1beta1"
"github.com/utilitywarehouse/terraform-applier/controllers"
Expand Down Expand Up @@ -498,8 +499,7 @@ func run(c *cli.Context) {

options := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: c.String("metrics-bind-address"),
Port: 9443,
Metrics: metricsserver.Options{BindAddress: c.String("metrics-bind-address")},
HealthProbeBindAddress: c.String("health-probe-bind-address"),
LeaderElection: c.Bool("leader-elect"),
LeaderElectionID: electionID,
Expand All @@ -510,13 +510,20 @@ func run(c *cli.Context) {
labelSelector = labels.Set{labelSelectorKey: labelSelectorValue}.AsSelector()
}

// if watchNamespaces specified only watch/cache modules form those namespaces
var namespaces map[string]cache.Config
if len(watchNamespaces) > 0 {
namespaces = make(map[string]cache.Config)
for _, wn := range watchNamespaces {
namespaces[wn] = cache.Config{}
}
}

options.Cache = cache.Options{
Scheme: scheme,
Namespaces: watchNamespaces,
Scheme: scheme,
DefaultLabelSelector: labelSelector,
ByObject: map[client.Object]cache.ByObject{
&tfaplv1beta1.Module{}: {
Label: labelSelector,
},
&tfaplv1beta1.Module{}: {Namespaces: namespaces},
},
}

Expand Down

0 comments on commit 21072b1

Please sign in to comment.