Skip to content

Commit

Permalink
Fix configuration merging when using `existingCommunicationsSecretNam…
Browse files Browse the repository at this point in the history
…e` (#1274)

* Fix configuration merging when using `existingCommunicationsSecretName`
* Do not create unused ConfigMaps for remote config
  • Loading branch information
pkosiec authored Sep 26, 2023
1 parent a331e14 commit fdb389c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helm/botkube/templates/communicationsecret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if not .Values.existingCommunicationsSecretName -}}
{{- if and (not .Values.existingCommunicationsSecretName) (not (include "botkube.remoteConfigEnabled" $)) -}}
apiVersion: v1
kind: Secret
metadata:
Expand Down
4 changes: 3 additions & 1 deletion helm/botkube/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ spec:
- name: cache
mountPath: "/.kube/cache"
env:
{{- if not (include "botkube.remoteConfigEnabled" $) }}
- name: BOTKUBE_CONFIG_PATHS
value: "/config/global_config.yaml,/config/comm_config.yaml,/config/{{ .Values.settings.persistentConfig.runtime.fileName}},/startup-config/{{ .Values.settings.persistentConfig.startup.fileName}}"
{{- end }}
- name: BOTKUBE_SETTINGS_METRICS__PORT
value: {{ .Values.service.targetPort | quote }}
{{- if .Values.kubeconfig.enabled }}
Expand Down Expand Up @@ -207,7 +209,7 @@ spec:
- name: startup-config
configMap:
name: {{ .Values.settings.persistentConfig.startup.configMap.name }}
{{ end}}
{{ end }}
{{- with .Values.extraVolumes }}
{{ toYaml . | nindent 8 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions helm/botkube/templates/global-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not (include "botkube.remoteConfigEnabled" $) }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -42,3 +43,4 @@ data:
analytics:
disable: {{ .Values.analytics.disable }}
{{- end }}
12 changes: 10 additions & 2 deletions helm/botkube/templates/persistent-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{{- if not (include "botkube.remoteConfigEnabled" $) }}
{{- $runtimeStateCfgMap := .Values.settings.persistentConfig.runtime.configMap.name -}}
{{- $communications := .Values.communications }}
{{- if .Values.existingCommunicationsSecretName }}
{{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.existingCommunicationsSecretName | default dict }}
{{- $data := b64dec (index $secret.data "comm_config.yaml") -}}
{{- $dataYaml := $data | fromYaml -}}
{{- $communications = $dataYaml.communications }}
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -16,7 +24,7 @@ metadata:
data:
{{- $prevRuntimeCfgMap := lookup "v1" "ConfigMap" .Release.Namespace $runtimeStateCfgMap | default dict }}
{{- $prevRuntimeFile := index ( $prevRuntimeCfgMap.data | default dict ) .Values.settings.persistentConfig.runtime.fileName | default "" | fromYaml -}}
{{- $mergedRuntimeCommunications := mustMergeOverwrite (mustDeepCopy (default (dict) $prevRuntimeFile.communications )) (mustDeepCopy .Values.communications) }}
{{- $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.
{{ .Values.settings.persistentConfig.runtime.fileName }}: |
Expand Down Expand Up @@ -97,4 +105,4 @@ data:
{{/* MS Teams doesn't support notification configuration via Botkube commands. */}}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit fdb389c

Please sign in to comment.