Skip to content

Commit

Permalink
Fix flag parsing (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: Waleed Malik <ahmedwaleedmalik@gmail.com>
  • Loading branch information
ahmedwaleedmalik committed Aug 21, 2024
1 parent ff43150 commit c193cd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cmd/ccm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ func main() {
flag.BoolVar(&enableSecretSynchronizer, "enable-secret-synchronizer", false, "Enable to automatically convert Secrets labelled with `kubelb.k8c.io/managed-by: kubelb` to Sync Secrets. This is used to sync secrets from tenants to the LB cluster in a controlled and secure way.")
flag.BoolVar(&enableGatewayAPI, "enable-gateway-api", false, "Enable the Gateway APIs and controllers. By default Gateway API is disabled since without Gateway API CRDs installed the controller cannot start.")

if enableGatewayAPI {
utilruntime.Must(gwapiv1.Install(scheme))
}

disableGatewayAPI := !enableGatewayAPI

opts := zap.Options{
Development: false,
TimeEncoder: zapcore.ISO8601TimeEncoder,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()

if enableGatewayAPI {
utilruntime.Must(gwapiv1.Install(scheme))
}

disableGatewayAPI := !enableGatewayAPI

kubeconfig = flag.Lookup("kubeconfig").Value.(flag.Getter).Get().(string)

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
Expand Down
12 changes: 6 additions & 6 deletions cmd/kubelb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ func main() {
flag.StringVar(&opt.kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
}

if opt.enableGatewayAPI {
utilruntime.Must(gwapiv1.Install(scheme))
}

disableGatewayAPI := !opt.enableGatewayAPI

if len(opt.namespace) == 0 {
// Retrieve controller namespace
ns, _ := os.LookupEnv("NAMESPACE")
Expand All @@ -105,6 +99,12 @@ func main() {
opts.BindFlags(flag.CommandLine)
flag.Parse()

if opt.enableGatewayAPI {
utilruntime.Must(gwapiv1.Install(scheme))
}

disableGatewayAPI := !opt.enableGatewayAPI

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Expand Down

0 comments on commit c193cd8

Please sign in to comment.