Skip to content

Commit b31e9e8

Browse files
committed
Improve testing
1 parent 94f14d1 commit b31e9e8

File tree

9 files changed

+345
-453
lines changed

9 files changed

+345
-453
lines changed

.cursor/rules/meta.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This project aims to provide a gitops-style approach to argo-cd deployments.
1010

1111
The main entrypoint is [helmfile.yaml](mdc:helmfile.yaml). It's used for bootstrapping new deployments for the very first time, as well as for updating the applicationSets in argo-cd handling all other deployments afterwards.
1212

13-
[root.yaml](mdc:clusters/root.yaml) is used to define all applicationSets that are used to generate the actual argo-cd apps.
13+
[appSets.yaml.gotmpl](mdc:appSets.yaml.gotmpl) is used to define all applicationSets that are used to generate the actual argo-cd apps.
1414

1515
The `clusters/` directory contains a specific directory structure to define clusters or constellations (logical groups of clusters with similar tasks, deployments or just to show a common owner) with clusters.
1616

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ chartstorage
33
switch-config.yaml
44
charts/
55
dist/
6-
test-results/
6+
testing-output/

appSets.yaml.gotmpl

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
applicationsets:
2+
# New ApplicationSet for plain deployments
3+
plain:
4+
namespace: argocd
5+
finalizers:
6+
- resources-finalizer.argocd.argoproj.io
7+
goTemplate: false
8+
goTemplateOptions: ["missingkey=invalid"]
9+
applyNestedSelectors: true
10+
11+
generators:
12+
- matrix:
13+
generators:
14+
# Original app deployment generators
15+
- matrix:
16+
generators:
17+
- clusters:
18+
selectors:
19+
values:
20+
clusterGroup: "{{`{{ or .metadata.labels.clusterGroup nil }}`}}"
21+
clusterName: "{{`{{ or .metadata.labels.clusterId .name }}`}}"
22+
clusterSlug: "{{`{{ if .metadata.labels.clusterGroup }}{{ .metadata.labels.clusterGroup }}-{{ end }}{{ or .metadata.labels.clusterId .name }}`}}"
23+
24+
- git:
25+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
26+
revision: HEAD
27+
directories:
28+
# global - on every cluster
29+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}/apps/*"
30+
# per clusterGroup - on every cluster in a group
31+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/*`}}"
32+
# on a specific single cluster, either grouped or ungrouped
33+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/*`}}"
34+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/*`}}"
35+
values:
36+
appInstance: "{{`{{- printf '{{ .path.basename }}' -}}`}}"
37+
appInstancePath: "{{`{{- printf '{{ .path.path }}' -}}`}}"
38+
39+
- merge:
40+
mergeKeys:
41+
- values
42+
generators:
43+
- git:
44+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
45+
revision: HEAD
46+
files:
47+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}/config.yaml" # 2. Universe globals
48+
values:
49+
selector: config
50+
51+
- git:
52+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
53+
revision: HEAD
54+
files:
55+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/config.yaml`}}" # 3. Constellation globals
56+
values:
57+
selector: config
58+
59+
- git:
60+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
61+
revision: HEAD
62+
files:
63+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
64+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
65+
values:
66+
selector: config
67+
68+
- git:
69+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
70+
revision: HEAD
71+
files:
72+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/apps/{{ .values.appInstance }}/config.yaml`}}" # 5. Universe-wide app settings
73+
values:
74+
selector: config
75+
76+
- git:
77+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
78+
revision: HEAD
79+
files:
80+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 6. Constellation-wide app settings
81+
values:
82+
selector: config
83+
84+
- git:
85+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing" }}
86+
revision: HEAD
87+
files:
88+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
89+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
90+
values:
91+
selector: config
92+
selector:
93+
matchExpressions:
94+
- key: baseApp
95+
operator: DoesNotExist
96+
template:
97+
metadata:
98+
name: "{{`{{ .values.clusterName }}-{{ .values.appInstance }}`}}"
99+
spec:
100+
project: default
101+
destination:
102+
name: "{{`{{ .values.clusterSlug }}`}}"
103+
namespace: "{{`{{ or .namespace .values.appInstance }}`}}"
104+
syncPolicy:
105+
syncOptions:
106+
- CreateNamespace=true
107+
templatePatch: |
108+
spec:
109+
sources:
110+
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
111+
targetRevision: HEAD
112+
path: "{{`{{ .values.appInstancePath }}`}}"
113+
114+
root:
115+
namespace: argocd
116+
finalizers:
117+
- resources-finalizer.argocd.argoproj.io
118+
goTemplate: false
119+
goTemplateOptions: ["missingkey=invalid"]
120+
121+
generators:
122+
- matrix:
123+
generators:
124+
# Original app deployment generators
125+
- matrix:
126+
generators:
127+
- clusters:
128+
selectors:
129+
values:
130+
clusterGroup: "{{`{{ or .metadata.labels.clusterGroup nil }}`}}"
131+
clusterName: "{{`{{ or .metadata.labels.clusterId .name }}`}}"
132+
clusterSlug: "{{`{{ if .metadata.labels.clusterGroup }}{{ .metadata.labels.clusterGroup }}-{{ end }}{{ or .metadata.labels.clusterId .name }}`}}"
133+
134+
- git:
135+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
136+
revision: HEAD
137+
directories:
138+
# global - on every cluster
139+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}/apps/*"
140+
# per clusterGroup - on every cluster in a group
141+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/*`}}"
142+
# on a specific single cluster, either grouped or ungrouped
143+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/*`}}"
144+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/*`}}"
145+
values:
146+
appInstance: "{{`{{- printf '{{ .path.basename }}' -}}`}}"
147+
appInstancePath: "{{`{{- printf '{{ .path.path }}' -}}`}}"
148+
149+
- merge:
150+
mergeKeys:
151+
- values
152+
generators:
153+
- git:
154+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
155+
revision: HEAD
156+
files:
157+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}/config.yaml" # 2. Universe globals
158+
values:
159+
selector: config
160+
161+
- git:
162+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
163+
revision: HEAD
164+
files:
165+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/config.yaml`}}" # 3. Constellation globals
166+
values:
167+
selector: config
168+
169+
- git:
170+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
171+
revision: HEAD
172+
files:
173+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
174+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
175+
values:
176+
selector: config
177+
178+
- git:
179+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
180+
revision: HEAD
181+
files:
182+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/apps/{{ .values.appInstance }}/config.yaml`}}" # 5. Universe-wide app settings
183+
values:
184+
selector: config
185+
186+
- git:
187+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
188+
revision: HEAD
189+
files:
190+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 6. Constellation-wide app settings
191+
values:
192+
selector: config
193+
194+
- git:
195+
repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
196+
revision: HEAD
197+
files:
198+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
199+
- path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
200+
values:
201+
selector: config
202+
selector:
203+
matchExpressions:
204+
- key: baseApp
205+
operator: Exists
206+
template:
207+
metadata:
208+
name: "{{`{{ .values.clusterName }}-{{ .values.appInstance }}`}}"
209+
spec:
210+
project: default # {{"{{ or .project \"default\" }}"}}
211+
destination:
212+
name: "{{`{{ .values.clusterSlug }}`}}"
213+
namespace: "{{`{{ or .namespace .values.appInstance }}`}}"
214+
syncPolicy:
215+
syncOptions:
216+
- CreateNamespace=true
217+
templatePatch: |
218+
spec:
219+
sources:
220+
{{`{{- if .baseApp }}`}}
221+
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
222+
targetRevision: HEAD
223+
path: {{`{{ .Values | get "baseDir" "baseDir missing" }}/apps/{{ .baseApp }}`}}
224+
{{`{{- end }}`}}
225+
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
226+
targetRevision: HEAD
227+
path: {{`{{ .values.appInstancePath }}`}}

0 commit comments

Comments
 (0)