Skip to content

Commit

Permalink
Enhance GetWatchNamespace func
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Lehtonen <markus.lehtonen@intel.com>
  • Loading branch information
ArangoGutierrez and marquiz committed Feb 8, 2022
1 parent 7c09709 commit d22a5a6
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ limitations under the License.
package utils

import (
"fmt"
"os"
)

// GetWatchNamespace returns the Namespace the operator should be watching for changes
func GetWatchNamespace() (string, error) {
// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
// which specifies the Namespace to watch.
// An empty value means the operator is running with cluster scope.
var watchNamespaceEnvVar = "WATCH_NAMESPACE"

ns, found := os.LookupEnv(watchNamespaceEnvVar)
if !found {
return "", fmt.Errorf("%s must be set", watchNamespaceEnvVar)
}
// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
// which specifies the Namespace to watch.
// An empty value means the operator is running with cluster scope.
const WatchNamespaceEnvVar = "WATCH_NAMESPACE"

return ns, nil
// GetWatchNamespace returns the Namespace the operator should be watching for changes
func GetWatchNamespace() (string, bool) {
return os.LookupEnv(WatchNamespaceEnvVar)
}

0 comments on commit d22a5a6

Please sign in to comment.