From 32dc1787f45e6344daab629ae601db41e71e2111 Mon Sep 17 00:00:00 2001 From: vikaschoudhary16 Date: Wed, 24 Apr 2019 15:33:45 +0530 Subject: [PATCH] Add support for passing namespace using manager cmdline flag --- pkg/client/config/config.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/client/config/config.go b/pkg/client/config/config.go index 8d022c5cfa..faa58d65c1 100644 --- a/pkg/client/config/config.go +++ b/pkg/client/config/config.go @@ -29,8 +29,8 @@ import ( ) var ( - kubeconfig, apiServerURL string - log = logf.RuntimeLog.WithName("client").WithName("config") + kubeconfig, apiServerURL, namespace string + log = logf.RuntimeLog.WithName("client").WithName("config") ) func init() { @@ -42,6 +42,10 @@ func init() { flag.StringVar(&apiServerURL, "master", "", "(Deprecated: switch to `--kubeconfig`) The address of the Kubernetes API server. Overrides any value in kubeconfig. "+ "Only required if out-of-cluster.") + + flag.StringVar(&namespace, "namespace", "", + "Namespace if specified restricts the manager's cache to watch objects in the desired namespace. "+ + "Otherwise objects will be watched in all the namespaces.") } // GetConfig creates a *rest.Config for talking to a Kubernetes API server. @@ -112,3 +116,9 @@ func GetConfigOrDie() *rest.Config { } return config } + +// GetNamespaceConfig returns the name of the namespace which is used to restrict +// the manager's cache to watch objects in this namespace +func GetNamespaceConfig() string { + return namespace +}