From c193cd8071459bfa009b976c7ace3658fa05d8d8 Mon Sep 17 00:00:00 2001 From: Waleed Malik Date: Wed, 21 Aug 2024 18:54:10 +0500 Subject: [PATCH] Fix flag parsing (#60) Signed-off-by: Waleed Malik --- cmd/ccm/main.go | 12 ++++++------ cmd/kubelb/main.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/ccm/main.go b/cmd/ccm/main.go index d583ad1..fe12e17 100644 --- a/cmd/ccm/main.go +++ b/cmd/ccm/main.go @@ -106,12 +106,6 @@ 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, @@ -119,6 +113,12 @@ func main() { 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))) diff --git a/cmd/kubelb/main.go b/cmd/kubelb/main.go index 5a92768..37c15ad 100644 --- a/cmd/kubelb/main.go +++ b/cmd/kubelb/main.go @@ -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") @@ -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,