if list of controllers only contains disabled controllers, implicitly enable all default controllers

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
This commit is contained in:
Tim Ramlot 2024-05-24 09:03:15 +02:00
parent a2a06a1d12
commit 985607b08c
No known key found for this signature in database
GPG Key ID: 47428728E0C2878D
2 changed files with 13 additions and 0 deletions

View File

@ -243,6 +243,11 @@ func EnabledControllers(o *config.ControllerConfiguration) sets.Set[string] {
}
}
// Detect if "*" was implied (in case only disabled controllers were specified)
if len(disabled) > 0 && len(enabled) == 0 {
enabled = enabled.Insert(defaults.DefaultEnabledControllers...)
}
enabled = enabled.Delete(disabled...)
if utilfeature.DefaultFeatureGate.Enabled(feature.ExperimentalCertificateSigningRequestControllers) {

View File

@ -50,6 +50,14 @@ func TestEnabledControllers(t *testing.T) {
controllers: []string{"*", "-clusterissuers", "-issuers"},
expEnabled: sets.New(defaults.DefaultEnabledControllers...).Delete("clusterissuers", "issuers"),
},
"if only disabled controllers are specified, implicitly enable all default controllers": {
controllers: []string{"-clusterissuers", "-issuers"},
expEnabled: sets.New(defaults.DefaultEnabledControllers...).Delete("clusterissuers", "issuers"),
},
"if both enabled and disabled controllers are specified, return specified controllers": {
controllers: []string{"foo", "-bar"},
expEnabled: sets.New("foo"),
},
}
for name, test := range tests {