Skip to content

Commit c1c0eb0

Browse files
committed
fix: backport changes from #64
1 parent 31e827d commit c1c0eb0

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

api/v2/config/controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ func (c *NewControllerConfig) validate() error {
132132
if c.SeedConfig == nil {
133133
return fmt.Errorf("seed config must be specified")
134134
}
135-
if c.SeedNamespace == "" {
136-
return fmt.Errorf("seed namespace must be specified")
137-
}
138135
if c.SeedAPIServerURL == "" {
139136
return fmt.Errorf("seed api server url must be specified")
140137
}

api/v2/validation/firewalldeployment.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ func (*firewallDeploymentValidator) validateSpec(log logr.Logger, f *v2.Firewall
4949
})
5050
if err != nil {
5151
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), f.Selector, ""))
52-
}
53-
54-
if !selector.Empty() {
52+
} else if !selector.Empty() {
5553
labels := labels.Set(f.Template.Labels)
5654
if !selector.Matches(labels) {
5755
allErrs = append(allErrs, field.Invalid(fldPath.Child("template", "metadata", "labels"), f.Template.Labels, "`selector` does not match template `labels`"))

main.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func main() {
110110
log.Fatalf("unable to create metal client %v", err)
111111
}
112112

113-
seedMgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
113+
mgrConfig := ctrl.Options{
114114
Scheme: scheme,
115115
Metrics: server.Options{
116116
BindAddress: metricsAddr,
@@ -121,15 +121,21 @@ func main() {
121121
}),
122122
Cache: cache.Options{
123123
SyncPeriod: &reconcileInterval,
124-
DefaultNamespaces: map[string]cache.Config{
125-
namespace: {},
126-
},
127124
},
128125
HealthProbeBindAddress: healthAddr,
129126
LeaderElection: enableLeaderElection,
130127
LeaderElectionID: "firewall-controller-manager-leader-election",
131128
GracefulShutdownTimeout: &gracefulShutdownTimeout,
132-
})
129+
}
130+
131+
if namespace != "" {
132+
l.Info("running in dedicated namespace only", "namespace", namespace)
133+
mgrConfig.Cache.DefaultNamespaces = map[string]cache.Config{
134+
namespace: {},
135+
}
136+
}
137+
138+
seedMgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), mgrConfig)
133139
if err != nil {
134140
log.Fatalf("unable to setup firewall-controller-manager %v", err)
135141
}

0 commit comments

Comments
 (0)