Skip to content
Merged
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
10 changes: 9 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ import (
func main() {
klog.InitFlags(nil)
flag.Set("logtostderr", "true")
watchNamespace := flag.String("namespace", "",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we define this outside the main function instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had more cli flags, it would make sense to create a CliFlags struct and parse the flags in a separate function that would return the CliFlags struct. Considering we have just one flag other than the logtostderr this should be good.

"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
flag.Parse()

cfg := config.GetConfigOrDie()

// Setup a Manager
mgr, err := manager.New(cfg, manager.Options{})
var opts manager.Options
if *watchNamespace != "" {
opts.Namespace = *watchNamespace
klog.Infof("Watching cluster-api objects only in namespace %q for reconciliation.", opts.Namespace)
}

mgr, err := manager.New(cfg, opts)
if err != nil {
klog.Fatalf("Failed to set up overall controller manager: %v", err)
}
Expand Down