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 |
| 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. |
| 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 |
----------------------------------------------

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
# -- 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/
applications: {}
# guestbook:
@ -43,7 +43,7 @@ applications: {}
# value: https://argoproj.github.io/
# -- 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/
projects: {}
# guestbook:
@ -90,7 +90,7 @@ projects: {}
# - argocd
# -- 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/
applicationsets: {}
# guestbook:
@ -175,72 +175,70 @@ applicationsets: {}
# -- Deploy Argo CD Applications/ApplicationSets/Projects within this helm release
# @default -- `[]` (See [values.yaml])
## Ref: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/
itemTemplates: {}
# first:
# items:
# - name: my-appset
# generators: &generators
# - list:
# elements:
# - cluster: engineering-dev
# url: https://1.2.3.4
# - cluster: engineering-prod
# url: https://2.4.6.8
# - cluster: finance-preprod
# url: https://9.8.7.6
# template:
# apiVersion: argoproj.io/v1alpha1
# kind: ApplicationSet
# metadata:
# name: "{{ .name }}"
# spec:
# generators: *generators
# template:
# metadata:
# name: "{{`{{cluster}}`}}-guestbook"
# spec:
# project: my-project
# source:
# repoURL: https://github.com/infra-team/cluster-deployments.git
# targetRevision: HEAD
# path: guestbook/{{`{{cluster}}`}}
# destination:
# server: "{{`{{cluster}}`}}"
# namespace: guestbook
# second:
# items:
# - name: my-appset
# generators:
# - list:
# elements:
# - cluster: engineering-dev
# url: https://1.2.3.4
# - cluster: engineering-prod
# url: https://2.4.6.8
# - cluster: finance-preprod
# url: https://9.8.7.6
# template: |-
# apiVersion: argoproj.io/v1alpha1
# kind: ApplicationSet
# metadata:
# name: {{ .name }}
# spec:
# generators: {{ toYaml .generators | nindent 4 }}
# template:
# metadata:
# name: '{{`{{cluster}}`}}-guestbook'
# spec:
# project: my-project
# source:
# repoURL: https://github.com/infra-team/cluster-deployments.git
# targetRevision: HEAD
# path: guestbook/{{`{{cluster}}`}}
# destination:
# server: '{{`{{cluster}}`}}'
# namespace: guestbook
itemTemplates: []
# - items:
# - name: my-appset
# generators: &generators
# - list:
# elements:
# - cluster: engineering-dev
# url: https://1.2.3.4
# - cluster: engineering-prod
# url: https://2.4.6.8
# - cluster: finance-preprod
# url: https://9.8.7.6
# template:
# apiVersion: argoproj.io/v1alpha1
# kind: ApplicationSet
# metadata:
# name: "{{ .name }}"
# spec:
# generators: *generators
# template:
# metadata:
# name: "{{`{{cluster}}`}}-guestbook"
# spec:
# project: my-project
# source:
# repoURL: https://github.com/infra-team/cluster-deployments.git
# targetRevision: HEAD
# path: guestbook/{{`{{cluster}}`}}
# destination:
# server: "{{`{{cluster}}`}}"
# namespace: guestbook
# - items:
# - name: my-appset
# generators:
# - list:
# elements:
# - cluster: engineering-dev
# url: https://1.2.3.4
# - cluster: engineering-prod
# url: https://2.4.6.8
# - cluster: finance-preprod
# url: https://9.8.7.6
# template: |-
# apiVersion: argoproj.io/v1alpha1
# kind: ApplicationSet
# metadata:
# name: {{ .name }}
# spec:
# generators: {{ toYaml .generators | nindent 4 }}
# template:
# metadata:
# name: '{{`{{cluster}}`}}-guestbook'
# spec:
# project: my-project
# source:
# repoURL: https://github.com/infra-team/cluster-deployments.git
# targetRevision: HEAD
# path: guestbook/{{`{{cluster}}`}}
# destination:
# 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.
# @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.
## Ref: https://github.com/argoproj-labs/argocd-extensions
extensions: {}
@ -253,4 +251,3 @@ extensions: {}
# url: https://github.com/argoproj-labs/argocd-example-extension.git
# - web:
# url: https://github.com/argoproj-labs/argocd-example-extension/releases/download/v0.1.0/extension.tar
#