@@ -23,6 +23,7 @@ import (
23
23
"strconv"
24
24
"strings"
25
25
"time"
26
+ "unicode"
26
27
27
28
"go.opentelemetry.io/otel"
28
29
"k8s.io/apimachinery/pkg/util/validation"
@@ -89,8 +90,29 @@ func initManager() (runtime.Options, error) {
89
90
options .LeaderElectionNamespace = os .Getenv ("PGO_NAMESPACE" )
90
91
}
91
92
92
- if namespace := os .Getenv ("PGO_TARGET_NAMESPACE" ); len (namespace ) > 0 {
93
- options .Cache .DefaultNamespaces = map [string ]runtime.CacheConfig {namespace : {}}
93
+ // Check PGO_TARGET_NAMESPACE for backwards compatibility with
94
+ // "singlenamespace" installations
95
+ singlenamespace := strings .TrimSpace (os .Getenv ("PGO_TARGET_NAMESPACE" ))
96
+
97
+ // Check PGO_TARGET_NAMESPACES for non-cluster-wide, multi-namespace
98
+ // installations
99
+ multinamespace := strings .TrimSpace (os .Getenv ("PGO_TARGET_NAMESPACES" ))
100
+
101
+ // Initialize DefaultNamespaces if any target namespaces are set
102
+ if len (singlenamespace ) > 0 || len (multinamespace ) > 0 {
103
+ options .Cache .DefaultNamespaces = map [string ]runtime.CacheConfig {}
104
+ }
105
+
106
+ if len (singlenamespace ) > 0 {
107
+ options .Cache .DefaultNamespaces [singlenamespace ] = runtime.CacheConfig {}
108
+ }
109
+
110
+ if len (multinamespace ) > 0 {
111
+ for _ , namespace := range strings .FieldsFunc (multinamespace , func (c rune ) bool {
112
+ return c != '-' && ! unicode .IsLetter (c ) && ! unicode .IsNumber (c )
113
+ }) {
114
+ options .Cache .DefaultNamespaces [namespace ] = runtime.CacheConfig {}
115
+ }
94
116
}
95
117
96
118
options .Controller .GroupKindConcurrency = map [string ]int {
0 commit comments