From 0ce72e302863304e33a04aa7718436c574864b86 Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Mon, 20 Dec 2021 19:17:54 +0100 Subject: [PATCH] feat(argocd-notifications): Support new notification controller features from argoproj-labs/argocd-notifications#77 (#1066) * Support setting secret name Signed-off-by: Hendrik Maus * Support setting configmap name Signed-off-by: Hendrik Maus * Use the fullname template for secret name Signed-off-by: Hendrik Maus * Use the fullname template for configmap name Signed-off-by: Hendrik Maus * Bump chart version 1.6.1 -> 1.7.0 Signed-off-by: Hendrik Maus * Update changelog Signed-off-by: Hendrik Maus * Update README Signed-off-by: Hendrik Maus Co-authored-by: Marko Bevc --- charts/argocd-notifications/Chart.yaml | 4 ++-- charts/argocd-notifications/README.md | 2 ++ .../templates/_helpers.tpl | 23 +++++++++++++++++++ .../templates/configmap.yaml | 2 +- .../templates/deployment.yaml | 2 ++ .../templates/secret.yaml | 2 +- charts/argocd-notifications/values.yaml | 8 +++++++ 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/charts/argocd-notifications/Chart.yaml b/charts/argocd-notifications/Chart.yaml index 9b1d08b2..1c1fa2b5 100644 --- a/charts/argocd-notifications/Chart.yaml +++ b/charts/argocd-notifications/Chart.yaml @@ -3,7 +3,7 @@ appVersion: v1.2.1 description: A Helm chart for ArgoCD notifications, an add-on to ArgoCD. name: argocd-notifications type: application -version: 1.6.1 +version: 1.7.0 home: https://github.com/argoproj/argo-helm icon: https://argocd-notifications.readthedocs.io/en/stable/assets/logo.png keywords: @@ -15,4 +15,4 @@ maintainers: - name: andyfeller annotations: artifacthub.io/changes: | - - "[Changed]: Update to app version v1.2.1" + - "[Added]: Support for dynamic Secret and ConfigMap names" diff --git a/charts/argocd-notifications/README.md b/charts/argocd-notifications/README.md index bdc7af40..81bd8358 100644 --- a/charts/argocd-notifications/README.md +++ b/charts/argocd-notifications/README.md @@ -23,6 +23,7 @@ docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:late | affinity | object | `{}` | Assign custom [affinity] rules | | argocdUrl | string | `nil` | ArgoCD dashboard url; used in place of {{.context.argocdUrl}} in templates | | cm.create | bool | `true` | Whether helm chart creates controller config map | +| cm.name | string | `""` | The name of the config map to use. | | containerSecurityContext | object | `{}` | Container Security Context | | context | object | `{}` | Define user-defined context | | extraArgs | list | `[]` | Extra arguments to provide to the controller | @@ -48,6 +49,7 @@ docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:late | secret.annotations | object | `{}` | key:value pairs of annotations to be added to the secret | | secret.create | bool | `true` | Whether helm chart creates controller secret | | secret.items | object | `{}` | Generic key:value pairs to be inserted into the secret | +| secret.name | string | `""` | The name of the secret to use. | | securityContext | object | `{"runAsNonRoot":true}` | Pod Security Context | | serviceAccount.annotations | object | `{}` | Annotations applied to created service account | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | diff --git a/charts/argocd-notifications/templates/_helpers.tpl b/charts/argocd-notifications/templates/_helpers.tpl index 373c5495..fa7d89d0 100644 --- a/charts/argocd-notifications/templates/_helpers.tpl +++ b/charts/argocd-notifications/templates/_helpers.tpl @@ -113,3 +113,26 @@ Create the name of the bot service account to use {{ default "default" .Values.bots.slack.serviceAccount.name }} {{- end -}} {{- end -}} + +{{/* +Create the name of the secret to use +*/}} +{{- define "argocd-notifications.secretName" -}} +{{- if .Values.secret.create -}} + {{ default (printf "%s-secret" (include "argocd-notifications.fullname" .)) .Values.secret.name }} +{{- else -}} + {{ default "argocd-notifications-secret" .Values.secret.name }} +{{- end -}} +{{- end -}} + + +{{/* +Create the name of the configmap to use +*/}} +{{- define "argocd-notifications.configMapName" -}} +{{- if .Values.cm.create -}} + {{ default (printf "%s-cm" (include "argocd-notifications.fullname" .)) .Values.cm.name }} +{{- else -}} + {{ default "argocd-notifications-cm" .Values.cm.name }} +{{- end -}} +{{- end -}} diff --git a/charts/argocd-notifications/templates/configmap.yaml b/charts/argocd-notifications/templates/configmap.yaml index 7b5186c0..a9c00b6f 100644 --- a/charts/argocd-notifications/templates/configmap.yaml +++ b/charts/argocd-notifications/templates/configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: argocd-notifications-cm + name: {{ include "argocd-notifications.configMapName" . }} labels: {{- include "argocd-notifications.labels" . | nindent 4 }} data: diff --git a/charts/argocd-notifications/templates/deployment.yaml b/charts/argocd-notifications/templates/deployment.yaml index 0a91b0ac..b7458166 100644 --- a/charts/argocd-notifications/templates/deployment.yaml +++ b/charts/argocd-notifications/templates/deployment.yaml @@ -45,6 +45,8 @@ spec: {{- if .Values.metrics.enabled }} - --metrics-port={{ .Values.metrics.port }} {{- end }} + - --secret-name={{ include "argocd-notifications.secretName" . }} + - --config-map-name={{ include "argocd-notifications.configMapName" . }} {{- range .Values.extraArgs }} - {{ . | squote }} {{- end }} diff --git a/charts/argocd-notifications/templates/secret.yaml b/charts/argocd-notifications/templates/secret.yaml index ea1569c7..38dadadf 100644 --- a/charts/argocd-notifications/templates/secret.yaml +++ b/charts/argocd-notifications/templates/secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: - name: argocd-notifications-secret + name: {{ include "argocd-notifications.secretName" . }} labels: {{- include "argocd-notifications.labels" . | nindent 4 }} {{- if .Values.secret.annotations }} diff --git a/charts/argocd-notifications/values.yaml b/charts/argocd-notifications/values.yaml index f3d32c66..054faffe 100644 --- a/charts/argocd-notifications/values.yaml +++ b/charts/argocd-notifications/values.yaml @@ -41,6 +41,10 @@ secret: # -- key:value pairs of annotations to be added to the secret annotations: {} + # -- The name of the secret to use. + ## If not set and create is true, the default name 'argocd-notifications-secret' is used + name: "" + # -- Generic key:value pairs to be inserted into the secret ## Can be used for templates, notification services etc. Some examples given below. ## For more information: https://argocd-notifications.readthedocs.io/en/stable/services/overview/ @@ -129,6 +133,10 @@ cm: # -- Whether helm chart creates controller config map create: true + # -- The name of the config map to use. + ## If not set and create is true, the default name 'argocd-notifications-cm' is used + name: "" + # -- Contains centrally managed global application subscriptions ## For more information: https://argocd-notifications.readthedocs.io/en/stable/subscriptions/ subscriptions: {}