fix: Use range function properly (revert complex changes on item-templates)

Signed-off-by: Marco Maurer <mkilchhofer@users.noreply.github.com>
This commit is contained in:
Marco Maurer 2024-03-23 12:44:51 +01:00
parent ad82e5a7fa
commit 63c305c077
8 changed files with 121 additions and 127 deletions

View file

@ -31,7 +31,7 @@ $ helm install my-release argo/argocd-apps
| applications | object | `{}` (See [values.yaml]) | Deploy Argo CD Applications within this helm release | | applications | object | `{}` (See [values.yaml]) | Deploy Argo CD Applications within this helm release |
| applicationsets | object | `{}` (See [values.yaml]) | Deploy Argo CD ApplicationSets within this helm release | | applicationsets | object | `{}` (See [values.yaml]) | Deploy Argo CD ApplicationSets within this helm release |
| extensions | object | `{}` (See [values.yaml]) | DEPRECATED - Please refer [Deprecation Notice](https://github.com/argoproj-labs/argocd-extensions?tab=readme-ov-file#deprecation-notice) for more info. | | extensions | object | `{}` (See [values.yaml]) | DEPRECATED - Please refer [Deprecation Notice](https://github.com/argoproj-labs/argocd-extensions?tab=readme-ov-file#deprecation-notice) for more info. |
| itemTemplates | object | `{}` (See [values.yaml]) | Deploy Argo CD Applications/ApplicationSets/Projects within this helm release | | itemTemplates | list | `[]` (See [values.yaml]) | Deploy Argo CD Applications/ApplicationSets/Projects within this helm release |
| projects | object | `{}` (See [values.yaml]) | Deploy Argo CD Projects within this helm release | | projects | object | `{}` (See [values.yaml]) | Deploy Argo CD Projects within this helm release |
---------------------------------------------- ----------------------------------------------

View file

@ -1,6 +1,5 @@
itemTemplates: itemTemplates:
first: - items:
items:
- name: my-appset - name: my-appset
generators: &generators generators: &generators
- list: - list:
@ -30,8 +29,7 @@ itemTemplates:
destination: destination:
server: "{{`{{cluster}}`}}" server: "{{`{{cluster}}`}}"
namespace: guestbook namespace: guestbook
second: - items:
items:
- name: my-appset - name: my-appset
generators: generators:
- list: - list:

View file

@ -1,50 +1,50 @@
{{- range $k, $v:= .Values.applications }} {{- range $appName, $appData:= .Values.applications }}
--- ---
apiVersion: argoproj.io/v1alpha1 apiVersion: argoproj.io/v1alpha1
kind: Application kind: Application
metadata: metadata:
{{- with $v.additionalAnnotations }} {{- with $appData.additionalAnnotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with .additionalLabels }} {{- with $appData.additionalLabels }}
labels: labels:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
name: {{ $k }} name: {{ $appName }}
{{- with .namespace }} {{- with $appData.namespace }}
namespace: {{ . }} namespace: {{ . }}
{{- end }} {{- end }}
{{- with .finalizers }} {{- with $appData.finalizers }}
finalizers: finalizers:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
project: {{ tpl .project $ }} project: {{ tpl $appData.project $ }}
{{- with .source }} {{- with $appData.source }}
source: source:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .sources }} {{- with $appData.sources }}
sources: sources:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
destination: destination:
{{- toYaml .destination | nindent 4 }} {{- toYaml $appData.destination | nindent 4 }}
{{- with .syncPolicy }} {{- with $appData.syncPolicy }}
syncPolicy: syncPolicy:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .revisionHistoryLimit }} {{- with $appData.revisionHistoryLimit }}
revisionHistoryLimit: {{ . }} revisionHistoryLimit: {{ . }}
{{- end }} {{- end }}
{{- with .ignoreDifferences }} {{- with $appData.ignoreDifferences }}
ignoreDifferences: ignoreDifferences:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .info }} {{- with $appData.info }}
info: info:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}

View file

@ -1,44 +1,43 @@
{{- range $appSetName, $appSetData:= .Values.applicationsets }}
{{- range $k, _:= .Values.applicationsets }}
--- ---
apiVersion: argoproj.io/v1alpha1 apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet kind: ApplicationSet
metadata: metadata:
{{- with .additionalAnnotations }} {{- with $appSetData.additionalAnnotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with .additionalLabels }} {{- with $appSetData.additionalLabels }}
labels: labels:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
name: {{ $k }} name: {{ $appSetName }}
{{- with .namespace }} {{- with $appSetData.namespace }}
namespace: {{ . }} namespace: {{ . }}
{{- end }} {{- end }}
spec: spec:
{{- if hasKey . "goTemplate" }} {{- if hasKey $appSetData "goTemplate" }}
goTemplate: {{ .goTemplate }} goTemplate: {{ $appSetData.goTemplate }}
{{- end }} {{- end }}
{{- with .generators }} {{- with $appSetData.generators }}
generators: generators:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .ignoreApplicationDifferences }} {{- with $appSetData.ignoreApplicationDifferences }}
ignoreApplicationDifferences: ignoreApplicationDifferences:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .strategy }} {{- with $appSetData.strategy }}
strategy: strategy:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .syncPolicy }} {{- with $appSetData.syncPolicy }}
syncPolicy: syncPolicy:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .template }} {{- with $appSetData.template }}
template: template:
{{- with .metadata }} {{- with .metadata }}
metadata: metadata:
@ -84,7 +83,7 @@ spec:
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- end }} {{- end }}
{{- with .templatePatch }} {{- with $appSetData.templatePatch }}
templatePatch: | templatePatch: |
{{- . | nindent 4 }} {{- . | nindent 4 }}
{{- end }} {{- end }}

View file

@ -1,25 +1,25 @@
{{- range $k, _:= .Values.extensions }} {{- range $extensionName, $extensionData:= .Values.extensions }}
--- ---
apiVersion: argoproj.io/v1alpha1 apiVersion: argoproj.io/v1alpha1
kind: ArgoCDExtension kind: ArgoCDExtension
metadata: metadata:
name: {{ $k }} name: {{ $extensionName }}
{{- with .namespace }} {{- with $extensionData.namespace }}
namespace: {{ . }} namespace: {{ . }}
{{- end }} {{- end }}
finalizers: finalizers:
- extensions-finalizer.argocd.argoproj.io - extensions-finalizer.argocd.argoproj.io
{{- with .additionalLabels }} {{- with $extensionData.additionalLabels }}
labels: labels:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .additionalAnnotations }} {{- with $extensionData.additionalAnnotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with .sources }} {{- with $extensionData.sources }}
spec: spec:
sources: sources:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}

View file

@ -1,4 +1,4 @@
{{- range _, _:= .Values.itemTemplates }} {{- range .Values.itemTemplates }}
{{- if kindIs "string" .template }} {{- if kindIs "string" .template }}
{{- $template := .template -}} {{- $template := .template -}}
{{- range .items }} {{- range .items }}

View file

@ -1,72 +1,72 @@
{{- range $k, _:= .Values.projects }} {{- range $projectName, $projectData := .Values.projects }}
--- ---
apiVersion: argoproj.io/v1alpha1 apiVersion: argoproj.io/v1alpha1
kind: AppProject kind: AppProject
metadata: metadata:
{{- with .additionalAnnotations }} {{- with $projectData.additionalAnnotations }}
annotations: annotations:
{{- range $key, $value := . }} {{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with .additionalLabels }} {{- with $projectData.additionalLabels }}
labels: labels:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
name: {{ $k }} name: {{ $projectName }}
{{- with .namespace }} {{- with $projectData.namespace }}
namespace: {{ . }} namespace: {{ . }}
{{- end }} {{- end }}
{{- with .finalizers }} {{- with $projectData.finalizers }}
finalizers: finalizers:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- with .permitOnlyProjectScopedClusters }} {{- with $projectData.permitOnlyProjectScopedClusters }}
permitOnlyProjectScopedClusters: {{ . }} permitOnlyProjectScopedClusters: {{ . }}
{{- end }} {{- end }}
description: {{ .description }} description: {{ $projectData.description }}
{{- with .sourceRepos }} {{- with $projectData.sourceRepos }}
sourceRepos: sourceRepos:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .destinations }} {{- with $projectData.destinations }}
destinations: destinations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .clusterResourceWhitelist }} {{- with $projectData.clusterResourceWhitelist }}
clusterResourceWhitelist: clusterResourceWhitelist:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .clusterResourceBlacklist }} {{- with $projectData.clusterResourceBlacklist }}
clusterResourceBlacklist: clusterResourceBlacklist:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .namespaceResourceBlacklist }} {{- with $projectData.namespaceResourceBlacklist }}
namespaceResourceBlacklist: namespaceResourceBlacklist:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .namespaceResourceWhitelist }} {{- with $projectData.namespaceResourceWhitelist }}
namespaceResourceWhitelist: namespaceResourceWhitelist:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .orphanedResources }} {{- with $projectData.orphanedResources }}
orphanedResources: orphanedResources:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .roles }} {{- with $projectData.roles }}
roles: roles:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .syncWindows }} {{- with $projectData.syncWindows }}
syncWindows: syncWindows:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .signatureKeys }} {{- with $projectData.signatureKeys }}
signatureKeys: signatureKeys:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with .sourceNamespaces }} {{- with $projectData.sourceNamespaces }}
sourceNamespaces: sourceNamespaces:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}

View file

@ -1,5 +1,5 @@
# -- Deploy Argo CD Applications within this helm release # -- Deploy Argo CD Applications within this helm release
# @default -- `[]` (See [values.yaml]) # @default -- `{}` (See [values.yaml])
## Ref: https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/ ## Ref: https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/
applications: {} applications: {}
# guestbook: # guestbook:
@ -43,7 +43,7 @@ applications: {}
# value: https://argoproj.github.io/ # value: https://argoproj.github.io/
# -- Deploy Argo CD Projects within this helm release # -- Deploy Argo CD Projects within this helm release
# @default -- `[]` (See [values.yaml]) # @default -- `{}` (See [values.yaml])
## Ref: https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/ ## Ref: https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/
projects: {} projects: {}
# guestbook: # guestbook:
@ -90,7 +90,7 @@ projects: {}
# - argocd # - argocd
# -- Deploy Argo CD ApplicationSets within this helm release # -- Deploy Argo CD ApplicationSets within this helm release
# @default -- `[]` (See [values.yaml]) # @default -- `{}` (See [values.yaml])
## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/ ## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/
applicationsets: {} applicationsets: {}
# guestbook: # guestbook:
@ -175,72 +175,70 @@ applicationsets: {}
# -- Deploy Argo CD Applications/ApplicationSets/Projects within this helm release # -- Deploy Argo CD Applications/ApplicationSets/Projects within this helm release
# @default -- `[]` (See [values.yaml]) # @default -- `[]` (See [values.yaml])
## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/ ## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/
itemTemplates: {} itemTemplates: []
# first: # - items:
# items: # - name: my-appset
# - name: my-appset # generators: &generators
# generators: &generators # - list:
# - list: # elements:
# elements: # - cluster: engineering-dev
# - cluster: engineering-dev # url: https://1.2.3.4
# url: https://1.2.3.4 # - cluster: engineering-prod
# - cluster: engineering-prod # url: https://2.4.6.8
# url: https://2.4.6.8 # - cluster: finance-preprod
# - cluster: finance-preprod # url: https://9.8.7.6
# url: https://9.8.7.6 # template:
# template: # apiVersion: argoproj.io/v1alpha1
# apiVersion: argoproj.io/v1alpha1 # kind: ApplicationSet
# kind: ApplicationSet # metadata:
# metadata: # name: "{{ .name }}"
# name: "{{ .name }}" # spec:
# spec: # generators: *generators
# generators: *generators # template:
# template: # metadata:
# metadata: # name: "{{`{{cluster}}`}}-guestbook"
# name: "{{`{{cluster}}`}}-guestbook" # spec:
# spec: # project: my-project
# project: my-project # source:
# source: # repoURL: https://github.com/infra-team/cluster-deployments.git
# repoURL: https://github.com/infra-team/cluster-deployments.git # targetRevision: HEAD
# targetRevision: HEAD # path: guestbook/{{`{{cluster}}`}}
# path: guestbook/{{`{{cluster}}`}} # destination:
# destination: # server: "{{`{{cluster}}`}}"
# server: "{{`{{cluster}}`}}" # namespace: guestbook
# namespace: guestbook # - items:
# second: # - name: my-appset
# items: # generators:
# - name: my-appset # - list:
# generators: # elements:
# - list: # - cluster: engineering-dev
# elements: # url: https://1.2.3.4
# - cluster: engineering-dev # - cluster: engineering-prod
# url: https://1.2.3.4 # url: https://2.4.6.8
# - cluster: engineering-prod # - cluster: finance-preprod
# url: https://2.4.6.8 # url: https://9.8.7.6
# - cluster: finance-preprod # template: |-
# url: https://9.8.7.6 # apiVersion: argoproj.io/v1alpha1
# template: |- # kind: ApplicationSet
# apiVersion: argoproj.io/v1alpha1 # metadata:
# kind: ApplicationSet # name: {{ .name }}
# metadata: # spec:
# name: {{ .name }} # generators: {{ toYaml .generators | nindent 4 }}
# spec: # template:
# generators: {{ toYaml .generators | nindent 4 }} # metadata:
# template: # name: '{{`{{cluster}}`}}-guestbook'
# metadata: # spec:
# name: '{{`{{cluster}}`}}-guestbook' # project: my-project
# spec: # source:
# project: my-project # repoURL: https://github.com/infra-team/cluster-deployments.git
# source: # targetRevision: HEAD
# repoURL: https://github.com/infra-team/cluster-deployments.git # path: guestbook/{{`{{cluster}}`}}
# targetRevision: HEAD # destination:
# path: guestbook/{{`{{cluster}}`}} # server: '{{`{{cluster}}`}}'
# destination: # namespace: guestbook
# server: '{{`{{cluster}}`}}'
# namespace: guestbook
# -- DEPRECATED - Please refer [Deprecation Notice](https://github.com/argoproj-labs/argocd-extensions?tab=readme-ov-file#deprecation-notice) for more info. # -- DEPRECATED - Please refer [Deprecation Notice](https://github.com/argoproj-labs/argocd-extensions?tab=readme-ov-file#deprecation-notice) for more info.
# @default -- `[]` (See [values.yaml]) # @default -- `{}` (See [values.yaml])
## This function in tech preview stage, do expect unstability or breaking changes in newer versions. Bump image.tag if necessary. ## This function in tech preview stage, do expect unstability or breaking changes in newer versions. Bump image.tag if necessary.
## Ref: https://github.com/argoproj-labs/argocd-extensions ## Ref: https://github.com/argoproj-labs/argocd-extensions
extensions: {} extensions: {}
@ -253,4 +251,3 @@ extensions: {}
# url: https://github.com/argoproj-labs/argocd-example-extension.git # url: https://github.com/argoproj-labs/argocd-example-extension.git
# - web: # - web:
# url: https://github.com/argoproj-labs/argocd-example-extension/releases/download/v0.1.0/extension.tar # url: https://github.com/argoproj-labs/argocd-example-extension/releases/download/v0.1.0/extension.tar
#