Skip to content

Commit

Permalink
if list of controllers only contains disabled controllers, implicitly…
Browse files Browse the repository at this point in the history
… enable all default controllers

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon authored and cert-manager-bot committed May 28, 2024
1 parent dadd37d commit dfce6b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/controller/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions cmd/controller/app/options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dfce6b9

Please sign in to comment.