From 65a6dcc03d6ea465294b151cd801e438bf32e921 Mon Sep 17 00:00:00 2001 From: wparr-circle Date: Fri, 12 Jul 2024 14:13:35 +0100 Subject: [PATCH] fix: prefer pvcMutatingWebhookEnabled over webhookEnabled Signed-off-by: wparr-circle --- .../templates/controller/deployment.yaml | 2 +- cmd/main.go | 27 ++++++++++--------- cmd/run.go | 6 ++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/charts/pvc-autoresizer/templates/controller/deployment.yaml b/charts/pvc-autoresizer/templates/controller/deployment.yaml index e2ff621..4899910 100644 --- a/charts/pvc-autoresizer/templates/controller/deployment.yaml +++ b/charts/pvc-autoresizer/templates/controller/deployment.yaml @@ -43,7 +43,7 @@ spec: {{ toYaml . | nindent 12 }} {{- end }} {{- if not .Values.webhook.pvcMutatingWebhook.enabled }} - - --webhook-enabled=false + - --pvc-mutating-webhook-enabled=false {{- end}} image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" {{- with .Values.image.pullPolicy }} diff --git a/cmd/main.go b/cmd/main.go index f8c2dca..c952542 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -13,18 +13,18 @@ import ( ) var config struct { - certDir string - webhookAddr string - metricsAddr string - healthAddr string - namespaces []string - watchInterval time.Duration - prometheusURL string - useK8sMetricsApi bool - skipAnnotation bool - development bool - zapOpts zap.Options - webhookEnabled bool + certDir string + webhookAddr string + metricsAddr string + healthAddr string + namespaces []string + watchInterval time.Duration + prometheusURL string + useK8sMetricsApi bool + skipAnnotation bool + development bool + zapOpts zap.Options + pvcMutatingWebhookEnabled bool } // rootCmd represents the base command when called without any subcommands @@ -59,7 +59,8 @@ func init() { fs.BoolVar(&config.useK8sMetricsApi, "use-k8s-metrics-api", false, "Use Kubernetes metrics API instead of Prometheus") fs.BoolVar(&config.skipAnnotation, "no-annotation-check", false, "Skip annotation check for StorageClass") fs.BoolVar(&config.development, "development", false, "Use development logger config") - fs.BoolVar(&config.webhookEnabled, "webhook-enabled", true, "Enable the webhook endpoint") + fs.BoolVar(&config.pvcMutatingWebhookEnabled, "pvc-mutating-webhook-enabled", true, + "Enable the pvc mutating webhook endpoint") goflags := flag.NewFlagSet("zap", flag.ExitOnError) config.zapOpts.BindFlags(goflags) diff --git a/cmd/run.go b/cmd/run.go index 2e78d99..17f3bfa 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -41,7 +41,7 @@ func subMain() error { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&config.zapOpts))) var webhookServer webhook.Server - if config.webhookEnabled { + if config.pvcMutatingWebhookEnabled { hookHost, portStr, err := net.SplitHostPort(config.webhookAddr) if err != nil { setupLog.Error(err, "invalid webhook addr") @@ -106,7 +106,7 @@ func subMain() error { if err := mgr.AddReadyzCheck("ping", healthz.Ping); err != nil { return err } - if config.webhookEnabled { + if config.pvcMutatingWebhookEnabled { if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil { return err } @@ -140,7 +140,7 @@ func subMain() error { return err } - if config.webhookEnabled { + if config.pvcMutatingWebhookEnabled { dec := admission.NewDecoder(scheme) if err = hooks.SetupPersistentVolumeClaimWebhook(mgr, dec, ctrl.Log.WithName("hooks")); err != nil { setupLog.Error(err, "unable to create PersistentVolumeClaim webhook")