@@ -162,6 +162,7 @@ applicationsets:
162
162
name: "{{`{{ .values.clusterName }}-{{ .values.appInstance }}`}}"
163
163
labels:
164
164
debug: "{{`{{ . | toYaml }}`}}"
165
+ baseApp: "{{`{{ .baseApp }}`}}"
165
166
spec:
166
167
project: default # {{"{{ or .project \"default\" }}"}}
167
168
destination:
@@ -173,126 +174,31 @@ applicationsets:
173
174
templatePatch: |
174
175
spec:
175
176
sources:
176
- {{`{{- if .baseApp }}`}}
177
+ # If the app is using a helmfile.yaml containing upstream charts, we need to add the upstream source
178
+ {{`{{- if and (eq .appSettings.path.filename "helmfile.yaml") .releases }}`}}
179
+ {{`{{- range $release := .releases }}`}}
180
+ {{`{{- if eq $release.chart "./" }}`}}
181
+ # Local chart source
177
182
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
178
183
targetRevision: HEAD
179
- path: {{ `apps/{{ .baseApp }}` }}
184
+ path: "{{ `apps/{{ $.baseApp }}` }}"
185
+ {{`{{- else }}`}}
186
+ # Upstream chart source
187
+ {{`{{- $repoName := (index (splitList "/" $release.chart) 0) }}`}}
188
+ {{`{{- $repoURL := "" }}`}}
189
+ {{`{{- range $repo := $.repositories }}`}}
190
+ {{`{{- if eq $repo.name $repoName }}`}}
191
+ {{`{{- $repoURL = $repo.url }}`}}
192
+ {{`{{- end }}`}}
193
+ {{`{{- end }}`}}
194
+ - repoURL: {{`{{ $repoURL }}`}}
195
+ targetRevision: {{`{{ $release.version }}`}}
196
+ chart: {{`{{ $release.chart }}`}}
197
+ helm:
198
+ valueFiles:
199
+ - {{`{{ $.values.appInstancePath }}/values.yaml`}}
200
+ {{`{{- end }}`}}
180
201
{{`{{- end }}`}}
181
- - repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
182
- targetRevision: HEAD
183
- path: {{`{{ .values.appInstancePath }}`}}
184
-
185
-
186
- root:
187
- namespace: argocd
188
- finalizers:
189
- - resources-finalizer.argocd.argoproj.io
190
- goTemplate: true
191
- goTemplateOptions: ["missingkey=invalid"]
192
-
193
- generators:
194
- - matrix:
195
- generators:
196
- # Original app deployment generators
197
- - matrix:
198
- generators:
199
- - clusters:
200
- selectors:
201
- values:
202
- clusterGroup: "{{`{{ or .metadata.labels.clusterGroup nil }}`}}"
203
- clusterName: "{{`{{ or .metadata.labels.clusterId .name }}`}}"
204
- clusterSlug: "{{`{{ if .metadata.labels.clusterGroup }}{{ .metadata.labels.clusterGroup }}-{{ end }}{{ or .metadata.labels.clusterId .name }}`}}"
205
-
206
- - git:
207
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
208
- revision: HEAD
209
- directories:
210
- # global - on every cluster
211
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}/apps/*"
212
- # per clusterGroup - on every cluster in a group
213
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/*`}}"
214
- # on a specific single cluster, either grouped or ungrouped
215
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/*`}}"
216
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/*`}}"
217
- values:
218
- appInstance: '{{ printf "%s" "{{- printf `{{ .path.basename }}` -}}" }}'
219
- appInstancePath: '{{ printf "%s" "{{- printf `{{ .path.path }}` -}}" }}'
220
-
221
- - merge:
222
- mergeKeys:
223
- - values
224
- generators:
225
- - git:
226
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
227
- revision: HEAD
228
- files:
229
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}/config.yaml" # 2. Universe globals
230
- values:
231
- selector: config
232
-
233
- - git:
234
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
235
- revision: HEAD
236
- files:
237
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/config.yaml`}}" # 3. Constellation globals
238
- values:
239
- selector: config
240
-
241
- - git:
242
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
243
- revision: HEAD
244
- files:
245
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
246
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/config.yaml`}}" # 4. Cluster globals
247
- values:
248
- selector: config
249
-
250
- - git:
251
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
252
- revision: HEAD
253
- files:
254
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/apps/{{ .values.appInstance }}/config.yaml`}}" # 5. Universe-wide app settings
255
- values:
256
- selector: config
257
-
258
- - git:
259
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
260
- revision: HEAD
261
- files:
262
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 6. Constellation-wide app settings
263
- values:
264
- selector: config
265
-
266
- - git:
267
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
268
- revision: HEAD
269
- files:
270
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
271
- - path: "{{ .Values | get "baseDir" "baseDir missing" }}{{`/{{ .values.clusterGroup }}/{{ .values.clusterName }}/apps/{{ .values.appInstance }}/config.yaml`}}" # 7. Cluster-specific app settings
272
- values:
273
- selector: config
274
- selector:
275
- matchExpressions:
276
- - key: baseApp
277
- operator: Exists
278
- template:
279
- metadata:
280
- name: "{{`{{ .values.clusterName }}-{{ .values.appInstance }}`}}"
281
- spec:
282
- project: default # {{"{{ or .project \"default\" }}"}}
283
- destination:
284
- name: "{{`{{ .values.clusterSlug }}`}}"
285
- namespace: "{{`{{ or .namespace .values.appInstance }}`}}"
286
- syncPolicy:
287
- syncOptions:
288
- - CreateNamespace=true
289
- templatePatch: |
290
- spec:
291
- sources:
292
- {{`{{- if .baseApp }}`}}
293
- - repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
294
- targetRevision: HEAD
295
- path: {{ `apps/{{ .baseApp }}` }}
296
202
{{`{{- end }}`}}
297
203
- repoURL: {{ .Values | get "repoUrl" "repoUrl missing"}}
298
204
targetRevision: HEAD
0 commit comments