Skip to content

Commit

Permalink
fix: prefer pvcMutatingWebhookEnabled over webhookEnabled
Browse files Browse the repository at this point in the history
Signed-off-by: wparr-circle <william.parr@circle.com>
  • Loading branch information
wparr-circle committed Jul 12, 2024
1 parent 0edd9f0 commit 65a6dcc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
27 changes: 14 additions & 13 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 65a6dcc

Please sign in to comment.