Skip to content

Commit

Permalink
Adding the good constant + env
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas committed May 20, 2021
1 parent 02294b6 commit 5486932
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/k8s/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"time"

//"github.com/keel-hq/keel/constants"
"github.com/keel-hq/keel/constants"
"github.com/keel-hq/keel/internal/workgroup"
"github.com/sirupsen/logrus"

Expand All @@ -18,8 +18,6 @@ import (
"k8s.io/client-go/tools/cache"
)

const EnvNamespaceInstall = "NAMESPACE_INSTALL"

// WatchDeployments creates a SharedInformer for apps/v1.Deployments and registers it with g.
func WatchDeployments(g *workgroup.Group, client *kubernetes.Clientset, log logrus.FieldLogger, rs ...cache.ResourceEventHandler) {
watch(g, client.AppsV1().RESTClient(), log, "deployments", new(apps_v1.Deployment), rs...)
Expand All @@ -41,16 +39,18 @@ func WatchCronJobs(g *workgroup.Group, client *kubernetes.Clientset, log logrus.
}

func watch(g *workgroup.Group, c cache.Getter, log logrus.FieldLogger, resource string, objType runtime.Object, rs ...cache.ResourceEventHandler) {
namespace_scan := EnvNamespaceInstall
if os.Getenv(EnvNamespaceInstall) == "keel" {
//Check if the env var RESTRICTED_NAMESPACE is empty or equal to keel
// If equal to keel or empty, the scan will be over all the cluster
// If RESTRICTED_NAMESPACE is different than keel or empty, keel will scan in the defined namespace
namespace_scan := "keel"
if os.Getenv(constants.EnvRestrictedNamespace) == "keel" {
namespace_scan = v1.NamespaceAll
} else if os.Getenv(EnvNamespaceInstall) == "" {
} else if os.Getenv(constants.EnvRestrictedNamespace) == "" {
namespace_scan = v1.NamespaceAll
} else {
namespace_scan = os.Getenv(EnvNamespaceInstall)
namespace_scan = os.Getenv(constants.EnvRestrictedNamespace)
}

//ethos_namespace := "ns-team-3di-services-stage"
lw := cache.NewListWatchFromClient(c, resource, namespace_scan, fields.Everything())
sw := cache.NewSharedInformer(lw, objType, 30*time.Minute)
for _, r := range rs {
Expand Down

0 comments on commit 5486932

Please sign in to comment.