Files

65 lines
2.9 KiB
YAML

{{- range $key,$val := .Values.applications }}
{{- /*
in order to use tpl within a range, _and_ have the key/val available to sub-templates,
need to add some variables to the root context.
*/ -}}
{{- $_ := set $ "curAppName" (print $.Values.envName "-" $key) }}
{{- if $val.enabled }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
{{- if $.Values.envSuffix }}
name: {{ printf "%s-%s" $key $.Values.envSuffix }}
{{- else }}
name: {{ $key }}
{{- end }}
namespace: {{ $.Values.default.app.metadata.namespace }}
annotations:
{{- if default false $val.cdEnabled }}
{{- with $val.imageList }}
argocd-image-updater.argoproj.io/image-list: |-
{{ join ", " . }}
{{- end }}
{{- toYaml $val.imageNamesAndTags | nindent 4 }}
argocd-image-updater.argoproj.io/git-branch: main
argocd-image-updater.argoproj.io/write-back-method: git:secret:argocd/git-creds
{{- end }}
{{- if default false $val.enableArgoNotifications }}
notifications.argoproj.io/subscribe.on-deployed.slack: {{ $.Values.argoNotificationsSlackChannel }}
notifications.argoproj.io/subscribe.on-health-degraded.slack: {{ $.Values.argoNotificationsSlackChannel }}
notifications.argoproj.io/subscribe.on-sync-failed.slack: {{ $.Values.argoNotificationsSlackChannel }}
{{- end }}
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: {{ $val.destination.namespace | default $.Values.default.app.destination.namespace | required (printf "No destination.namespace specified for %s" $key ) }}
server: {{ $val.destination.server | default $.Values.default.app.destination.server | required (printf "No destination.server specified for %s" $key ) }}
{{- if $.Values.projectOverride }}
project: {{ $.Values.projectOverride }}
{{- else }}
project: {{ $val.project | default $.Values.default.app.project | required (printf "No project specified for %s" $key ) }}
{{- end }}
{{- if $val.enableAutoSync | default $.Values.default.app.enableAutoSync }}
syncPolicy:
automated:
prune: {{ $val.autoSyncPrune | default $.Values.default.app.autoSyncPrune | default true }}
{{- end }}
source:
path: {{ tpl $val.source.path $ }}
repoURL: {{ $val.source.repoURL | default $.Values.default.app.source.repoURL | required (printf "No source.repoURL specified for %s" $key ) }}
targetRevision: {{ $.Values.default.app.source.targetRevision | default $val.source.targetRevision | required (printf "No source.targetRevision specified for %s" $key ) }}
{{- if $val.source.extraSourceFields }}
{{ tpl $val.source.extraSourceFields $ | indent 4 }}
{{- else if $.Values.default.app.source.extraSourceFields }}
{{ tpl $.Values.default.app.source.extraSourceFields $ | indent 4 }}
{{- end }}
{{- if $val.extraFields }}
{{ tpl $val.extraFields $ | indent 2 }}
{{- else if $.Values.default.app.extraFields }}
{{ tpl $.Values.default.app.extraFields $ | indent 2 }}
{{- end }}
{{- end }}
{{- end }}