Skip to content

Commit 885edec

Browse files
andrewlecuyerjkatz
authored andcommitted
Ensure Default NS Always Set
This commit ensures that the namespace specified for the Operator via env var PGO_OPERATOR_NAMESPACE is always set as the default watched namespace for the Operator install when the NAMESPACE env var is empty.
1 parent e667a58 commit 885edec

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ns/nslogic.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,13 @@ func ValidateNamespacesWatched(clientset *kubernetes.Clientset,
677677
}
678678

679679
// getNamespacesFromEnv returns a slice containing the namespaces strored the NAMESPACE env var in
680-
// csv format.
680+
// csv format. If NAMESPACE is empty, then the Operator namespace as specified in env var
681+
// PGO_OPERATOR_NAMESPACE is returned.
681682
func getNamespacesFromEnv() []string {
682683
namespaceEnvVar := os.Getenv("NAMESPACE")
683684
if namespaceEnvVar == "" {
684-
return nil
685+
defaultNs := os.Getenv("PGO_OPERATOR_NAMESPACE")
686+
return []string{defaultNs}
685687
}
686688
return strings.Split(namespaceEnvVar, ",")
687689
}
@@ -982,10 +984,5 @@ func GetInitialNamespaceList(clientset *kubernetes.Clientset,
982984
}
983985
}
984986

985-
// default to the namespace for the Operator install if the namespace list is still empty
986-
if len(namespaceList) == 0 {
987-
namespaceList = append(namespaceList, pgoNamespace)
988-
}
989-
990987
return namespaceList, nil
991988
}

0 commit comments

Comments
 (0)