@@ -40,7 +40,6 @@ import (
40
40
"sigs.k8s.io/node-feature-discovery-operator/internal/deployment"
41
41
"sigs.k8s.io/node-feature-discovery-operator/internal/job"
42
42
"sigs.k8s.io/node-feature-discovery-operator/internal/status"
43
- "sigs.k8s.io/node-feature-discovery-operator/pkg/utils"
44
43
"sigs.k8s.io/node-feature-discovery-operator/pkg/version"
45
44
// +kubebuilder:scaffold:imports
46
45
)
52
51
53
52
const (
54
53
// ProgramName is the canonical name of this program
55
- ProgramName = "nfd-operator"
54
+ ProgramName = "nfd-operator"
55
+ watchNamespaceEnvVar = "WATCH_NAMESPACE"
56
56
)
57
57
58
58
// operatorArgs holds command line arguments
@@ -96,10 +96,10 @@ func main() {
96
96
os .Exit (0 )
97
97
}
98
98
99
- watchNamespace , envSet := utils . GetWatchNamespace ()
100
- if ! envSet {
101
- setupLogger .Info ( "unable to get WatchNamespace, " +
102
- "the manager will watch and manage resources in all namespaces" )
99
+ watchNamespace , err := getWatchNamespace ()
100
+ if err != nil {
101
+ setupLogger .Error ( err , "WatchNamespaceEnvVar is not set" )
102
+ os . Exit ( 1 )
103
103
}
104
104
105
105
// Create a new manager to manage the operator
@@ -184,3 +184,12 @@ func initFlags(flagset *flag.FlagSet) *operatorArgs {
184
184
185
185
return & args
186
186
}
187
+
188
+ // getWatchNamespace returns the Namespace the operator should be watching for changes
189
+ func getWatchNamespace () (string , error ) {
190
+ value , present := os .LookupEnv (watchNamespaceEnvVar )
191
+ if ! present {
192
+ return "" , fmt .Errorf ("environment variable %s is not defined" , watchNamespaceEnvVar )
193
+ }
194
+ return value , nil
195
+ }
0 commit comments