Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ update the --namespace <namespace> option to accept a comma-separated list for watching multiple selected namespaces #11397

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var (
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
watchNamespacesList []string
profilerAddress string
enableContentionProfiling bool
syncPeriod time.Duration
Expand Down Expand Up @@ -116,8 +116,8 @@ func InitFlags(fs *pflag.FlagSet) {
fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
fs.StringSliceVar(&watchNamespacesList, "namespace", nil,
"Comma-separated list of namespaces that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
Expand Down Expand Up @@ -212,9 +212,10 @@ func main() {
}

var watchNamespaces map[string]cache.Config
if watchNamespace != "" {
watchNamespaces = map[string]cache.Config{
watchNamespace: {},
if watchNamespacesList != nil {
watchNamespaces = map[string]cache.Config{}
for _, watchNamespace := range watchNamespacesList {
watchNamespaces[watchNamespace] = cache.Config{}
}
}

Expand Down
13 changes: 7 additions & 6 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var (
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
watchNamespacesList []string
profilerAddress string
enableContentionProfiling bool
syncPeriod time.Duration
Expand Down Expand Up @@ -125,8 +125,8 @@ func InitFlags(fs *pflag.FlagSet) {
fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 5*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
fs.StringSliceVar(&watchNamespacesList, "namespace", nil,
"Comma-separated list of namespaces that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
Expand Down Expand Up @@ -237,9 +237,10 @@ func main() {
}

var watchNamespaces map[string]cache.Config
if watchNamespace != "" {
watchNamespaces = map[string]cache.Config{
watchNamespace: {},
if watchNamespacesList != nil {
watchNamespaces = map[string]cache.Config{}
for _, watchNamespace := range watchNamespacesList {
watchNamespaces[watchNamespace] = cache.Config{}
}
}

Expand Down
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var (
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
watchNamespacesList []string
profilerAddress string
enableContentionProfiling bool
syncPeriod time.Duration
Expand Down Expand Up @@ -166,8 +166,8 @@ func InitFlags(fs *pflag.FlagSet) {
fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
fs.StringSliceVar(&watchNamespacesList, "namespace", nil,
"Comma-separated list of namespaces that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
Expand Down Expand Up @@ -317,9 +317,10 @@ func main() {
}

var watchNamespaces map[string]cache.Config
if watchNamespace != "" {
watchNamespaces = map[string]cache.Config{
watchNamespace: {},
if watchNamespacesList != nil {
watchNamespaces = map[string]cache.Config{}
for _, watchNamespace := range watchNamespacesList {
watchNamespaces[watchNamespace] = cache.Config{}
}
}

Expand Down
13 changes: 7 additions & 6 deletions test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var (
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
watchNamespacesList []string
profilerAddress string
enableContentionProfiling bool
syncPeriod time.Duration
Expand Down Expand Up @@ -123,8 +123,8 @@ func InitFlags(fs *pflag.FlagSet) {
fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
fs.StringSliceVar(&watchNamespacesList, "namespace", nil,
"Comma-separated list of namespaces that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
Expand Down Expand Up @@ -216,9 +216,10 @@ func main() {
}

var watchNamespaces map[string]cache.Config
if watchNamespace != "" {
watchNamespaces = map[string]cache.Config{
watchNamespace: {},
if watchNamespacesList != nil {
watchNamespaces = map[string]cache.Config{}
for _, watchNamespace := range watchNamespacesList {
watchNamespaces[watchNamespace] = cache.Config{}
}
}

Expand Down