Skip to content

Commit

Permalink
Fix Helm chart upgrade when lookup is not supported (#1408)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec authored Mar 7, 2024
1 parent ced876d commit 027883f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions helm/botkube/templates/persistent-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- if not (include "botkube.remoteConfigEnabled" $) }}
{{- $runtimeStateCfgMap := .Values.settings.persistentConfig.runtime.configMap.name -}}
{{- $communications := .Values.communications }}
{{- $communications := .Values.communications | default dict }}
{{- if .Values.existingCommunicationsSecretName }}
{{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.existingCommunicationsSecretName | default dict }}
{{- $secretData := $secret.data | default dict -}}
{{- $data := b64dec (index $secretData "comm_config.yaml" | default "") -}}
{{- $dataYaml := $data | fromYaml -}}
{{- $communications = $dataYaml.communications }}
{{- $dataYaml := $data | fromYaml | default dict -}}
{{- $communications = $dataYaml.communications | default dict }}
{{- end }}
apiVersion: v1
kind: ConfigMap
Expand All @@ -24,7 +24,7 @@ metadata:
botkube.io/config-watch: "true"
data:
{{- $prevRuntimeCfgMap := lookup "v1" "ConfigMap" .Release.Namespace $runtimeStateCfgMap | default dict }}
{{- $prevRuntimeFile := index ( $prevRuntimeCfgMap.data | default dict ) .Values.settings.persistentConfig.runtime.fileName | default "" | fromYaml -}}
{{- $prevRuntimeFile := index ( $prevRuntimeCfgMap.data | default dict ) .Values.settings.persistentConfig.runtime.fileName | default "" | fromYaml | default dict -}}
{{- $mergedRuntimeCommunications := mustMergeOverwrite (mustDeepCopy (default (dict) $prevRuntimeFile.communications )) (mustDeepCopy $communications) }}
{{- $mergedRuntimeAction := mustMergeOverwrite (mustDeepCopy (default (dict) $prevRuntimeFile.actions )) (mustDeepCopy .Values.actions) }}
# This file has a special prefix to load it as the last config file during Botkube startup.
Expand Down Expand Up @@ -75,7 +75,7 @@ metadata:
botkube.io/config-watch: "false" # Explicitly don't watch this ConfigMap
data:
{{- $prevStartupCfgMap := lookup "v1" "ConfigMap" .Release.Namespace $startupStateCfgMap | default dict }}
{{- $prevStartupFile := index ( $prevStartupCfgMap.data | default dict ) .Values.settings.persistentConfig.startup.fileName | default "" | fromYaml -}}
{{- $prevStartupFile := index ( $prevStartupCfgMap.data | default dict ) .Values.settings.persistentConfig.startup.fileName | default "" | fromYaml | default dict -}}
{{- $mergedStartupCommunications := mustMergeOverwrite (mustDeepCopy (default (dict) $prevStartupFile.communications )) (mustDeepCopy .Values.communications) }}
# This file has a special prefix to load it as the last config file during Botkube startup.
{{ .Values.settings.persistentConfig.startup.fileName }}: |
Expand Down

0 comments on commit 027883f

Please sign in to comment.