Skip to content

Commit

Permalink
ensure we do not append anything to the managed namespaces when it's …
Browse files Browse the repository at this point in the history
…empty (managing all namespaces)
  • Loading branch information
naemono committed Dec 13, 2021
1 parent 62804ac commit 9f83fff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controller/common/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ type namespaceAwareController struct {
// namespaced events outside of managed namespaces, and the operator namespace.
func newNamespaceAwareWatchersController(c controller.Controller, managedNamespaces []string, operatorNamespace string) controller.Controller {
watchedNamespaces := managedNamespaces
if !slices.Contains(watchedNamespaces, operatorNamespace) {
// if the length of watchedNamespaces is 0, then we're watching all namespaces, and shouldn't append anything to the slice, as
// it will just cause issues wth the managed namespaces predicate.
if len(watchedNamespaces) > 0 && !slices.Contains(watchedNamespaces, operatorNamespace) {
watchedNamespaces = append(watchedNamespaces, operatorNamespace)
}
return &namespaceAwareController{
Expand Down

0 comments on commit 9f83fff

Please sign in to comment.