From 46f163cad98366b3b0884f672bc6c0ea42899525 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Mon, 13 Feb 2023 14:37:59 +0200 Subject: [PATCH] fix nil pointers --- library/common/1.0.0/templates/lib/workload/_daemonsetSpec.tpl | 3 +++ .../common/1.0.0/templates/lib/workload/_deployementSpec.tpl | 3 +++ .../common/1.0.0/templates/lib/workload/_statefulsettSpec.tpl | 3 +++ 3 files changed, 9 insertions(+) diff --git a/library/common/1.0.0/templates/lib/workload/_daemonsetSpec.tpl b/library/common/1.0.0/templates/lib/workload/_daemonsetSpec.tpl index c0cace1a83..83e68471b1 100644 --- a/library/common/1.0.0/templates/lib/workload/_daemonsetSpec.tpl +++ b/library/common/1.0.0/templates/lib/workload/_daemonsetSpec.tpl @@ -14,6 +14,9 @@ revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }} updateStrategy: type: {{ $objectData.strategy | default "RollingUpdate" }} {{- if eq $objectData.strategy "RollingUpdate" }} + {{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}} + {{- $_ := set $objectData "rollingUpdate" dict -}} + {{- end }} rollingUpdate: maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable }} maxSurge: {{ $objectData.rollingUpdate.maxSurge | default $rootCtx.Values.fallbackDefaults.maxSurge }} diff --git a/library/common/1.0.0/templates/lib/workload/_deployementSpec.tpl b/library/common/1.0.0/templates/lib/workload/_deployementSpec.tpl index 75a73b0f0a..7a219b0b33 100644 --- a/library/common/1.0.0/templates/lib/workload/_deployementSpec.tpl +++ b/library/common/1.0.0/templates/lib/workload/_deployementSpec.tpl @@ -15,6 +15,9 @@ revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }} strategy: type: {{ $objectData.strategy | default "Recreate" }} {{- if eq $objectData.strategy "RollingUpdate" }} + {{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}} + {{- $_ := set $objectData "rollingUpdate" dict -}} + {{- end }} rollingUpdate: maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable }} maxSurge: {{ $objectData.rollingUpdate.maxSurge | default $rootCtx.Values.fallbackDefaults.maxSurge }} diff --git a/library/common/1.0.0/templates/lib/workload/_statefulsettSpec.tpl b/library/common/1.0.0/templates/lib/workload/_statefulsettSpec.tpl index 8fc1494c4e..488c727c05 100644 --- a/library/common/1.0.0/templates/lib/workload/_statefulsettSpec.tpl +++ b/library/common/1.0.0/templates/lib/workload/_statefulsettSpec.tpl @@ -17,6 +17,9 @@ updateStrategy: type: {{ $objectData.strategy | default "RollingUpdate" }} {{- if eq $objectData.strategy "RollingUpdate" }} rollingUpdate: + {{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}} + {{- $_ := set $objectData "rollingUpdate" dict -}} + {{- end }} maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable }} partition: {{ $objectData.rollingUpdate.partition | default $rootCtx.Values.fallbackDefaults.partition }} {{- end -}}