From a8c19c84b34d581eb95ea9533ea15c614c1725b4 Mon Sep 17 00:00:00 2001 From: Samu Date: Wed, 24 Apr 2024 16:19:16 +0200 Subject: [PATCH] codegen: fix to prevent null strategy (#550) --- changelog/v0.38.6/fix-conditional-strategy.yaml | 7 +++++++ codegen/templates/chart/operator-deployment.yamltmpl | 2 +- .../templates/deployment.yaml | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog/v0.38.6/fix-conditional-strategy.yaml diff --git a/changelog/v0.38.6/fix-conditional-strategy.yaml b/changelog/v0.38.6/fix-conditional-strategy.yaml new file mode 100644 index 000000000..53c699489 --- /dev/null +++ b/changelog/v0.38.6/fix-conditional-strategy.yaml @@ -0,0 +1,7 @@ +changelog: + - type: FIX + issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/15710 + resolvesIssue: false + description: | + Avoid setting deployment strategy to null when no condition is evaluated. + skipCI: false diff --git a/codegen/templates/chart/operator-deployment.yamltmpl b/codegen/templates/chart/operator-deployment.yamltmpl index 5875d8dff..965053d30 100644 --- a/codegen/templates/chart/operator-deployment.yamltmpl +++ b/codegen/templates/chart/operator-deployment.yamltmpl @@ -65,9 +65,9 @@ spec: strategy: [[ toYaml $strategy | indent 4 ]] [[- else if $conditionalStrategy ]] - strategy: [[- range $s := $conditionalStrategy ]] {{- if [[ $s.Condition ]] }} + strategy: [[ toYaml $s.Strategy | indent 4 ]] {{- end }} [[- end ]] diff --git a/codegen/test/chart-conditional-deployment-strategy/templates/deployment.yaml b/codegen/test/chart-conditional-deployment-strategy/templates/deployment.yaml index f44f6b136..9c9ab1ae6 100644 --- a/codegen/test/chart-conditional-deployment-strategy/templates/deployment.yaml +++ b/codegen/test/chart-conditional-deployment-strategy/templates/deployment.yaml @@ -21,11 +21,12 @@ spec: selector: matchLabels: app: painter - strategy: {{- if $.Values.painter.condition }} + strategy: type: RollingUpdate {{- end }} {{- if not $.Values.painter.condition }} + strategy: type: Recreate {{- end }} template: