--- charts-original/templates/configmap.yaml +++ charts/templates/configmap.yaml @@ -5,16 +5,18 @@ {{- if and .Values.prom2teams.connector (hasKey .Values.prom2teams.connectors "Connector") -}} {{- fail "Invalid configuration: prom2teams.connectors can't have a connector named Connector when prom2teams.connector is set"}} {{- end -}} -{{- if and (not .Values.prom2teams.connector) (not .Values.prom2teams.connectors) -}} -{{- fail "Invalid configuration: At least one connector must be provided"}} -{{- end -}} +{{/* Create the configmap when the operation is helm install and the target configmap does not exist. */}} +{{- if not (lookup "v1" "ConfigMap" (include "prom2teams.namespace" . ) (include "prom2teams.fullname" .)) }} apiVersion: v1 kind: ConfigMap metadata: - name: prom2teams-config - labels: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} + namespace: {{ include "prom2teams.namespace" . }} + name: {{ include "prom2teams.fullname" . }} + labels: {{ include "prom2teams.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": pre-install, pre-upgrade + "helm.sh/hook-weight": "3" + "helm.sh/resource-policy": keep data: config.ini: |- [HTTP Server] @@ -33,4 +35,5 @@ Level: {{ .Values.prom2teams.loglevel }} [Template] Path: {{ .Values.prom2teams.templatepath }} - teams.j2: {{ .Files.Get "files/teams.j2" | quote }} \ No newline at end of file + teams.j2: {{ .Files.Get "files/teams.j2" | quote }} + {{- end -}}