Skip to content

Commit dfce6b9

Browse files
inteoncert-manager-bot
authored andcommitted
if list of controllers only contains disabled controllers, implicitly enable all default controllers
Signed-off-by: Tim Ramlot <[email protected]>
1 parent dadd37d commit dfce6b9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/controller/app/options/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ func EnabledControllers(o *config.ControllerConfiguration) sets.Set[string] {
243243
}
244244
}
245245

246+
// Detect if "*" was implied (in case only disabled controllers were specified)
247+
if len(disabled) > 0 && len(enabled) == 0 {
248+
enabled = enabled.Insert(defaults.DefaultEnabledControllers...)
249+
}
250+
246251
enabled = enabled.Delete(disabled...)
247252

248253
if utilfeature.DefaultFeatureGate.Enabled(feature.ExperimentalCertificateSigningRequestControllers) {

cmd/controller/app/options/options_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ func TestEnabledControllers(t *testing.T) {
5050
controllers: []string{"*", "-clusterissuers", "-issuers"},
5151
expEnabled: sets.New(defaults.DefaultEnabledControllers...).Delete("clusterissuers", "issuers"),
5252
},
53+
"if only disabled controllers are specified, implicitly enable all default controllers": {
54+
controllers: []string{"-clusterissuers", "-issuers"},
55+
expEnabled: sets.New(defaults.DefaultEnabledControllers...).Delete("clusterissuers", "issuers"),
56+
},
57+
"if both enabled and disabled controllers are specified, return specified controllers": {
58+
controllers: []string{"foo", "-bar"},
59+
expEnabled: sets.New("foo"),
60+
},
5361
}
5462

5563
for name, test := range tests {

0 commit comments

Comments
 (0)