From d79a20baf882f3c7c71250e78451efb84f3cee05 Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Mon, 9 Sep 2024 13:52:36 +0900 Subject: [PATCH] chore: Changed the process to expand yaml so that maxUnavailable, etc. can be used. Signed-off-by: kahirokunn --- cmd/build/helmify/kustomize-for-helm.yaml | 2 +- cmd/build/helmify/replacements.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/build/helmify/kustomize-for-helm.yaml b/cmd/build/helmify/kustomize-for-helm.yaml index 8e87903194c..cb885782b4d 100644 --- a/cmd/build/helmify/kustomize-for-helm.yaml +++ b/cmd/build/helmify/kustomize-for-helm.yaml @@ -310,7 +310,7 @@ metadata: name: gatekeeper-controller-manager namespace: gatekeeper-system spec: - minAvailable: HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE + minAvailable: HELMSUBST_PDB_CONTROLLER_MANAGER selector: matchLabels: control-plane: controller-manager diff --git a/cmd/build/helmify/replacements.go b/cmd/build/helmify/replacements.go index d95ed289c19..1e9fee8bda1 100644 --- a/cmd/build/helmify/replacements.go +++ b/cmd/build/helmify/replacements.go @@ -248,7 +248,17 @@ var replacements = map[string]string{ "HELMSUBST_MUTATING_WEBHOOK_MATCH_CONDITIONS": `{{ toYaml .Values.mutatingWebhookMatchConditions | nindent 4 }}`, - "HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE": `{{ .Values.pdb.controllerManager.minAvailable }}`, + "HELMSUBST_PDB_CONTROLLER_MANAGER": `{{- if and .Values.maxAvailable .Values.maxUnavailable }} + {{ fail "Only one of 'maxAvailable' or 'maxUnavailable' can be set, but not both" }} + {{- else if not (or .Values.maxAvailable .Values.maxUnavailable) }} + {{ fail "One of 'maxAvailable' or 'maxUnavailable' must be set" }} + {{- else }} + {{ if .Values.maxAvailable }} + maxAvailable: {{ .Values.maxAvailable }} + {{ else if .Values.maxUnavailable }} + maxUnavailable: {{ .Values.maxUnavailable }} + {{ end }} + {{- end }}`, `HELMSUBST_AUDIT_CONTROLLER_MANAGER_DEPLOYMENT_IMAGE_RELEASE: ""`: `{{- if .Values.image.release }} image: {{ .Values.image.repository }}:{{ .Values.image.release }}