Skip to content

Commit be84e86

Browse files
committed
feat: multi-repo overlay architecture for addon values (cherry-pick from PR #628)
Add support for an optional overlay Git repository (GitLab) that provides value overrides for addons without modifying the source platform repo (GitHub). Changes: - bootstrap/addons.yaml: ref:values → ref:defaults + conditional ref:overlay - appset-chart: $values/ → $defaults/ + conditional $overlay/ paths - New valuesObject passes overlay repo coordinates to appset-chart - Fully backward-compatible: empty overlay_repo_url = no change in behavior
1 parent bec80ab commit be84e86

4 files changed

Lines changed: 51 additions & 18 deletions

File tree

gitops/bootstrap/addons.yaml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ spec:
2323
sources:
2424
- repoURL: '{{ .metadata.annotations.addonsRepoURL }}'
2525
targetRevision: '{{ .metadata.annotations.addonsRepoRevision }}'
26-
ref: values
26+
ref: defaults
27+
{{- if .metadata.annotations.overlay_repo_url }}
28+
- repoURL: '{{ .metadata.annotations.overlay_repo_url }}'
29+
targetRevision: '{{ .metadata.annotations.overlay_repo_revision }}'
30+
ref: overlay
31+
{{- end }}
2732
- repoURL: '{{ .metadata.annotations.addonsRepoURL }}'
2833
path: 'platform-charts/appset-chart'
2934
targetRevision: '{{ .metadata.annotations.addonsRepoRevision }}'
@@ -32,15 +37,23 @@ spec:
3237
ignoreMissingValueFiles: true
3338
valueFiles:
3439
- values.yaml
35-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/_defaults.yaml
36-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/core.yaml
37-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/gitops.yaml
38-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/security.yaml
39-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/observability.yaml
40-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/platform.yaml
41-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/ml.yaml
42-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}overlays/environments/{{ .metadata.labels.environment }}/overrides.yaml
43-
- $values/{{ .metadata.annotations.addonsRepoBasepath }}overlays/clusters/{{ .nameNormalized }}/overrides.yaml
40+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/_defaults.yaml
41+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/core.yaml
42+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/gitops.yaml
43+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/security.yaml
44+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/observability.yaml
45+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/platform.yaml
46+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}addons/registry/ml.yaml
47+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}overlays/environments/{{ .metadata.labels.environment }}/overrides.yaml
48+
- $defaults/{{ .metadata.annotations.addonsRepoBasepath }}overlays/clusters/{{ .nameNormalized }}/overrides.yaml
49+
{{- if .metadata.annotations.overlay_repo_url }}
50+
- $overlay/{{ .metadata.annotations.overlay_repo_basepath }}overlays/environments/{{ .metadata.labels.environment }}/overrides.yaml
51+
- $overlay/{{ .metadata.annotations.overlay_repo_basepath }}overlays/clusters/{{ .nameNormalized }}/overrides.yaml
52+
{{- end }}
53+
valuesObject:
54+
overlayRepoURLGit: '{{ default "" .metadata.annotations.overlay_repo_url }}'
55+
overlayRepoURLGitRevision: '{{ default "main" .metadata.annotations.overlay_repo_revision }}'
56+
overlayRepoURLGitBasePath: '{{ default "" .metadata.annotations.overlay_repo_basepath }}'
4457
destination:
4558
namespace: argocd
4659
name: '{{ .name }}'

platform-charts/appset-chart/templates/_application_set.tpl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Layering order:
5454
2. Per-addon custom valueFiles (from chartConfig.valueFiles)
5555
3. Environment overlay values (from overlayBasePath/environments/<env>/<addon>/values.yaml)
5656
4. Cluster overlay values (from overlayBasePath/clusters/<cluster>/<addon>/values.yaml)
57+
5. External overlay repo values (from overlayRepoURLGitBasePath, if configured)
5758
All paths use ignoreMissingValueFiles: true so missing files are silently skipped.
5859
*/}}
5960
{{- define "application-sets.valueFiles" -}}
@@ -65,22 +66,28 @@ All paths use ignoreMissingValueFiles: true so missing files are silently skippe
6566
{{/* 1. Default addon config values */}}
6667
{{- with .valueFiles }}
6768
{{- range . }}
68-
- $values/{{ $values.repoURLGitBasePath }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}{{ . }}{{ end }}
69+
- $defaults/{{ $values.repoURLGitBasePath }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}{{ . }}{{ end }}
6970
{{- if $values.useValuesFilePrefix }}
70-
- $values/{{ $values.repoURLGitBasePath }}/{{ $values.valuesFilePrefix }}{{ . }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}values.yaml{{ end }}
71+
- $defaults/{{ $values.repoURLGitBasePath }}/{{ $values.valuesFilePrefix }}{{ . }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}values.yaml{{ end }}
7172
{{- end }}
7273
{{- end }}
7374
{{- end }}
7475
{{/* 2. Per-addon custom valueFiles */}}
7576
{{- with $chartConfig.valueFiles }}
7677
{{- range . }}
77-
- $values/{{ $values.repoURLGitBasePath }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}{{ . }}{{ end }}
78+
- $defaults/{{ $values.repoURLGitBasePath }}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/{{ if $chartConfig.valuesFileName }}{{ $chartConfig.valuesFileName }}{{ else }}{{ . }}{{ end }}
7879
{{- end }}
7980
{{- end }}
80-
{{/* 3. Environment overlay values */}}
81+
{{/* 3. Environment overlay values (same repo) */}}
8182
{{- if $values.overlayBasePath }}
82-
- $values/{{ $values.overlayBasePath }}/environments/{{`{{.metadata.labels.environment}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
83-
{{/* 4. Cluster overlay values */}}
84-
- $values/{{ $values.overlayBasePath }}/clusters/{{`{{.nameNormalized}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
83+
- $defaults/{{ $values.overlayBasePath }}/environments/{{`{{.metadata.labels.environment}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
84+
{{/* 4. Cluster overlay values (same repo) */}}
85+
- $defaults/{{ $values.overlayBasePath }}/clusters/{{`{{.nameNormalized}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
86+
{{- end }}
87+
{{/* 5. External overlay repo values */}}
88+
{{- if $values.overlayRepoURLGit }}
89+
- $overlay/{{ $values.overlayRepoURLGitBasePath }}configs/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
90+
- $overlay/{{ $values.overlayRepoURLGitBasePath }}overlays/environments/{{`{{.metadata.labels.environment}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
91+
- $overlay/{{ $values.overlayRepoURLGitBasePath }}overlays/clusters/{{`{{.nameNormalized}}`}}/{{ $nameNormalize }}{{ if $chartType }}/{{ $chartType }}{{ end }}/values.yaml
8592
{{- end }}
8693
{{- end }}

platform-charts/appset-chart/templates/application-set.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
{{- $repoURLGit := .Values.repoURLGit -}}
88
{{- $repoURLGitRevision := .Values.repoURLGitRevision -}}
99
{{- $repoURLGitBasePath := .Values.repoURLGitBasePath -}}
10+
{{- $overlayRepoURLGit := .Values.overlayRepoURLGit -}}
11+
{{- $overlayRepoURLGitRevision := .Values.overlayRepoURLGitRevision -}}
12+
{{- $overlayRepoURLGitBasePath := .Values.overlayRepoURLGitBasePath -}}
1013
{{- $valueFiles := .Values.valueFiles -}}
1114
{{- $valuesFilePrefix := .Values.valuesFilePrefix -}}
1215
{{- $useValuesFilePrefix := (default false .Values.useValuesFilePrefix ) -}}
@@ -129,7 +132,12 @@ spec:
129132
sources:
130133
- repoURL: {{ $repoURLGit | squote}}
131134
targetRevision: {{ $repoURLGitRevision | squote }}
132-
ref: values
135+
ref: defaults
136+
{{- if $overlayRepoURLGit }}
137+
- repoURL: {{ $overlayRepoURLGit | squote }}
138+
targetRevision: {{ $overlayRepoURLGitRevision | squote }}
139+
ref: overlay
140+
{{- end }}
133141
{{- if eq (toString $chartConfig.enableAckPodIdentity) "true" }}
134142
{{ include "application-sets.pod-identity" (dict
135143
"chartName" ($chartConfig.chartName | default $nameNormalize)

platform-charts/appset-chart/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ repoURLGit: "{{.metadata.annotations.addonsRepoURL}}"
2828
repoURLGitRevision: "{{.metadata.annotations.addonsRepoRevision}}"
2929
repoURLGitBasePath: "{{.metadata.annotations.addonsRepoBasepath}}"
3030
overlayBasePath: ""
31+
32+
# Overlay multi-repo (optional, injected by bootstrap/addons.yaml valuesObject)
33+
overlayRepoURLGit: ""
34+
overlayRepoURLGitRevision: "main"
35+
overlayRepoURLGitBasePath: ""

0 commit comments

Comments
 (0)