INNER CODE UNIT · Go
isWatchedNamespace
airwallex/k8s-pod-restart-info-collector · helpers.go:63
func isWatchedNamespace(namespace string) bool {
watchedNamespacesEnv := os.Getenv("WATCHED_NAMESPACES")
if watchedNamespacesEnv == "" {
return true
}
watchedNamespaces := strings.Split(watchedNamespacesEnv, ",")
for _, watchedNamespace := range watchedNamespaces {
match, _ := regexp.MatchString(watchedNamespace, namespace)
if match {
return true
}
}
// Turn off logging as there are too many logs.
// klog.Infof("Ignore: namespace %s is not on the watched namespace list\n", namespace)
return false
}