Skip to content

Commit 1125d13

Browse files
authored
Merge pull request #374 from beekhof/template-values
Template values
2 parents 5a64bfb + 7cda9c4 commit 1125d13

13 files changed

Lines changed: 238 additions & 81 deletions

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,18 @@ argo-healthcheck: ## Checks if all argo applications are synced
150150

151151
CHARTS=$(shell find . -type f -iname 'Chart.yaml' -exec dirname "{}" \; | grep -v examples | sed -e 's/.\///')
152152
# Section related to tests and linting
153-
TEST_OPTS= -f values-global.yaml --set global.repoURL="https://github.com/pattern-clone/mypattern" \
154-
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" --set main.git.revision=main --set global.pattern="mypattern" \
155-
--set global.namespace="pattern-namespace" --set global.hubClusterDomain=apps.hub.example.com --set global.localClusterDomain=apps.region.example.com --set global.clusterDomain=region.example.com\
156-
--set "clusterGroup.imperative.jobs[0].name"="test" --set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
153+
TEST_OPTS= -f values-global.yaml \
154+
--set global.repoURL="https://github.com/pattern-clone/mypattern" \
155+
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" \
156+
--set main.git.revision=main --set global.pattern="mypattern" \
157+
--set global.namespace="pattern-namespace" \
158+
--set global.hubClusterDomain=apps.hub.example.com \
159+
--set global.localClusterDomain=apps.region.example.com \
160+
--set global.clusterDomain=region.example.com \
161+
--set global.clusterVersion="4.12" \
162+
--set global.clusterPlatform=aws \
163+
--set "clusterGroup.imperative.jobs[0].name"="test" \
164+
--set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
157165
PATTERN_OPTS=-f common/examples/values-example.yaml
158166
EXECUTABLES=git helm oc ansible
159167

clustergroup/templates/plumbing/applications.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ spec:
5959
ignoreMissingValueFiles: true
6060
valueFiles:
6161
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 12 }}
62-
{{- range .extraValueFiles }}
63-
- {{ . | quote }}
62+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
63+
- {{ tpl $valueFile $ | quote }}
64+
{{- end }}
65+
{{- range $valueFile := .extraValueFiles }}
66+
- {{ tpl $valueFile $ | quote }}
6467
{{- end }}
6568
{{- if .useGeneratorValues }}
6669
values: |-
@@ -147,8 +150,11 @@ spec:
147150
ignoreMissingValueFiles: true
148151
valueFiles:
149152
{{- include "clustergroup.app.globalvalues.prefixedvaluefiles" $ | nindent 8 }}
153+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
154+
- {{ tpl $valueFile $ | quote }}
155+
{{- end }}
150156
{{- range $valueFile := .extraValueFiles }}
151-
- {{ $valueFile | quote }}
157+
- {{ tpl $valueFile $ | quote }}
152158
{{- end }}
153159
parameters:
154160
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}
@@ -211,8 +217,11 @@ spec:
211217
ignoreMissingValueFiles: true
212218
valueFiles:
213219
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 6 }}
220+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
221+
- {{ tpl $valueFile $ | quote }}
222+
{{- end }}
214223
{{- range $valueFile := .extraValueFiles }}
215-
- {{ $valueFile | quote }}
224+
- {{ tpl $valueFile $ | quote }}
216225
{{- end }}
217226
parameters:
218227
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}

clustergroup/values.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@
234234
"type": "boolean",
235235
"description": "If set to true the values is used to identify whether this is the hub cluster or an edge/spoke cluster configuration."
236236
},
237+
"sharedValueFiles": {
238+
"type": "array",
239+
"description": "Templated value file paths."
240+
},
237241
"namespaces": {
238242
"type": "array",
239243
"description": "This is the array of namespaces that the VP framework will create. In addition, operator groups will also be created for each namespace.",

clustergroup/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ global:
88
installPlanApproval: Automatic
99
applicationRetryLimit: 20
1010

11+
1112
enabled: "all"
1213

1314
# Note that sometimes changing helm values might require a hard refresh (https://github.com/helm/helm/issues/3486)
1415
clusterGroup:
1516
name: example
1617
isHubCluster: true
1718
targetCluster: in-cluster
19+
sharedValueFiles: []
1820

1921
imperative:
2022
jobs: []

examples/values-example.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ clusterGroup:
1111
name: example
1212
#insecureUnsealVaultInsideCluster: false
1313
isHubCluster: true
14+
sharedValueFiles:
15+
- /values/{{ .Values.global.clusterPlatform }}.yaml
16+
- /values/{{ .Values.global.clusterVersion }}.yaml
1417

1518
namespaces:
1619
- open-cluster-management:
@@ -63,6 +66,8 @@ clusterGroup:
6366
namespace: application-ci
6467
project: datacenter
6568
path: charts/datacenter/pipelines
69+
extraValueFiles:
70+
- /values/{{ .Values.global.clusterVersion }}/{{ .Values.global.clusterPlatform }}.yaml
6671

6772
imperative:
6873
namespace: imperative

tests/acm-industrial-edge-hub.expected.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ spec:
234234
- name: global.clusterVersion
235235
value: '{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}'
236236
- name: global.clusterPlatform
237-
value:
237+
value: aws
238238
- name: clusterGroup.name
239239
value: factory
240240
- name: clusterGroup.isHubCluster

tests/acm-medical-diagnosis-hub.expected.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ spec:
225225
- name: global.clusterVersion
226226
value: '{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}'
227227
- name: global.clusterPlatform
228-
value:
228+
value: aws
229229
- name: clusterGroup.name
230230
value: region-one
231231
- name: clusterGroup.isHubCluster

tests/acm-normal.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ spec:
628628
- name: global.clusterVersion
629629
value: '{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}'
630630
- name: global.clusterPlatform
631-
value:
631+
value: aws
632632
- name: clusterGroup.name
633633
value: acm-edge
634634
- name: clusterGroup.isHubCluster
@@ -722,7 +722,7 @@ spec:
722722
- name: global.clusterVersion
723723
value: '{{ printf "%d.%d" ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Major) ((semver (lookup "operator.openshift.io/v1" "OpenShiftControllerManager" "" "cluster").status.version).Minor) }}'
724724
- name: global.clusterPlatform
725-
value:
725+
value: aws
726726
- name: clusterGroup.name
727727
value: acm-provision-edge
728728
- name: clusterGroup.isHubCluster

tests/clustergroup-industrial-edge-factory.expected.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ data:
115115
- manuela-factory-ml-workspace
116116
projects:
117117
- factory
118+
sharedValueFiles: []
118119
subscriptions:
119120
- channel: stable
120121
name: opendatahub-operator
@@ -135,7 +136,12 @@ data:
135136
targetCluster: in-cluster
136137
enabled: all
137138
global:
139+
Template:
140+
BasePath: global-vars.yml
141+
Name: global-vars
138142
clusterDomain: region.example.com
143+
clusterPlatform: aws
144+
clusterVersion: "4.12"
139145
extraValueFiles: []
140146
git:
141147
account: hybrid-cloud-patterns
@@ -412,7 +418,11 @@ spec:
412418
ignoreMissingValueFiles: true
413419
valueFiles:
414420
- "/values-global.yaml"
415-
- "/values-factory.yaml"
421+
- "/values-factory.yaml"
422+
- "/values-aws.yaml"
423+
- "/values-aws-4.12.yaml"
424+
- "/values-aws-factory.yaml"
425+
- "/values-4.12-factory.yaml"
416426
parameters:
417427
- name: global.repoURL
418428
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -425,9 +435,9 @@ spec:
425435
- name: global.clusterDomain
426436
value: region.example.com
427437
- name: global.clusterVersion
428-
value: ""
438+
value: "4.12"
429439
- name: global.clusterPlatform
430-
value: ""
440+
value: "aws"
431441
- name: global.hubClusterDomain
432442
value: apps.hub.example.com
433443
- name: global.localClusterDomain

tests/clustergroup-industrial-edge-hub.expected.yaml

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ data:
257257
- production-datalake
258258
- golang-external-secrets
259259
- vault
260+
sharedValueFiles: []
260261
subscriptions:
261262
acm:
262263
channel: release-2.6
@@ -296,7 +297,12 @@ data:
296297
targetCluster: in-cluster
297298
enabled: all
298299
global:
300+
Template:
301+
BasePath: global-vars.yml
302+
Name: global-vars
299303
clusterDomain: region.example.com
304+
clusterPlatform: aws
305+
clusterVersion: "4.12"
300306
extraValueFiles: []
301307
git:
302308
account: hybrid-cloud-patterns
@@ -685,7 +691,11 @@ spec:
685691
ignoreMissingValueFiles: true
686692
valueFiles:
687693
- "/values-global.yaml"
688-
- "/values-datacenter.yaml"
694+
- "/values-datacenter.yaml"
695+
- "/values-aws.yaml"
696+
- "/values-aws-4.12.yaml"
697+
- "/values-aws-datacenter.yaml"
698+
- "/values-4.12-datacenter.yaml"
689699
parameters:
690700
- name: global.repoURL
691701
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -698,9 +708,9 @@ spec:
698708
- name: global.clusterDomain
699709
value: region.example.com
700710
- name: global.clusterVersion
701-
value: ""
711+
value: "4.12"
702712
- name: global.clusterPlatform
703-
value: ""
713+
value: "aws"
704714
- name: global.hubClusterDomain
705715
value: apps.hub.example.com
706716
- name: global.localClusterDomain
@@ -742,7 +752,11 @@ spec:
742752
ignoreMissingValueFiles: true
743753
valueFiles:
744754
- "/values-global.yaml"
745-
- "/values-datacenter.yaml"
755+
- "/values-datacenter.yaml"
756+
- "/values-aws.yaml"
757+
- "/values-aws-4.12.yaml"
758+
- "/values-aws-datacenter.yaml"
759+
- "/values-4.12-datacenter.yaml"
746760
parameters:
747761
- name: global.repoURL
748762
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -755,9 +769,9 @@ spec:
755769
- name: global.clusterDomain
756770
value: region.example.com
757771
- name: global.clusterVersion
758-
value: ""
772+
value: "4.12"
759773
- name: global.clusterPlatform
760-
value: ""
774+
value: "aws"
761775
- name: global.hubClusterDomain
762776
value: apps.hub.example.com
763777
- name: global.localClusterDomain
@@ -790,7 +804,11 @@ spec:
790804
ignoreMissingValueFiles: true
791805
valueFiles:
792806
- "/values-global.yaml"
793-
- "/values-datacenter.yaml"
807+
- "/values-datacenter.yaml"
808+
- "/values-aws.yaml"
809+
- "/values-aws-4.12.yaml"
810+
- "/values-aws-datacenter.yaml"
811+
- "/values-4.12-datacenter.yaml"
794812
parameters:
795813
- name: global.repoURL
796814
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -803,9 +821,9 @@ spec:
803821
- name: global.clusterDomain
804822
value: region.example.com
805823
- name: global.clusterVersion
806-
value: ""
824+
value: "4.12"
807825
- name: global.clusterPlatform
808-
value: ""
826+
value: "aws"
809827
- name: global.hubClusterDomain
810828
value: apps.hub.example.com
811829
- name: global.localClusterDomain
@@ -838,7 +856,11 @@ spec:
838856
ignoreMissingValueFiles: true
839857
valueFiles:
840858
- "/values-global.yaml"
841-
- "/values-datacenter.yaml"
859+
- "/values-datacenter.yaml"
860+
- "/values-aws.yaml"
861+
- "/values-aws-4.12.yaml"
862+
- "/values-aws-datacenter.yaml"
863+
- "/values-4.12-datacenter.yaml"
842864
parameters:
843865
- name: global.repoURL
844866
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -851,9 +873,9 @@ spec:
851873
- name: global.clusterDomain
852874
value: region.example.com
853875
- name: global.clusterVersion
854-
value: ""
876+
value: "4.12"
855877
- name: global.clusterPlatform
856-
value: ""
878+
value: "aws"
857879
- name: global.hubClusterDomain
858880
value: apps.hub.example.com
859881
- name: global.localClusterDomain
@@ -916,7 +938,11 @@ spec:
916938
ignoreMissingValueFiles: true
917939
valueFiles:
918940
- "/values-global.yaml"
919-
- "/values-datacenter.yaml"
941+
- "/values-datacenter.yaml"
942+
- "/values-aws.yaml"
943+
- "/values-aws-4.12.yaml"
944+
- "/values-aws-datacenter.yaml"
945+
- "/values-4.12-datacenter.yaml"
920946
parameters:
921947
- name: global.repoURL
922948
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -929,9 +955,9 @@ spec:
929955
- name: global.clusterDomain
930956
value: region.example.com
931957
- name: global.clusterVersion
932-
value: ""
958+
value: "4.12"
933959
- name: global.clusterPlatform
934-
value: ""
960+
value: "aws"
935961
- name: global.hubClusterDomain
936962
value: apps.hub.example.com
937963
- name: global.localClusterDomain
@@ -964,7 +990,11 @@ spec:
964990
ignoreMissingValueFiles: true
965991
valueFiles:
966992
- "/values-global.yaml"
967-
- "/values-datacenter.yaml"
993+
- "/values-datacenter.yaml"
994+
- "/values-aws.yaml"
995+
- "/values-aws-4.12.yaml"
996+
- "/values-aws-datacenter.yaml"
997+
- "/values-4.12-datacenter.yaml"
968998
parameters:
969999
- name: global.repoURL
9701000
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -977,9 +1007,9 @@ spec:
9771007
- name: global.clusterDomain
9781008
value: region.example.com
9791009
- name: global.clusterVersion
980-
value: ""
1010+
value: "4.12"
9811011
- name: global.clusterPlatform
982-
value: ""
1012+
value: "aws"
9831013
- name: global.hubClusterDomain
9841014
value: apps.hub.example.com
9851015
- name: global.localClusterDomain
@@ -1039,7 +1069,11 @@ spec:
10391069
ignoreMissingValueFiles: true
10401070
valueFiles:
10411071
- "/values-global.yaml"
1042-
- "/values-datacenter.yaml"
1072+
- "/values-datacenter.yaml"
1073+
- "/values-aws.yaml"
1074+
- "/values-aws-4.12.yaml"
1075+
- "/values-aws-datacenter.yaml"
1076+
- "/values-4.12-datacenter.yaml"
10431077
parameters:
10441078
- name: global.repoURL
10451079
value: $ARGOCD_APP_SOURCE_REPO_URL
@@ -1052,9 +1086,9 @@ spec:
10521086
- name: global.clusterDomain
10531087
value: region.example.com
10541088
- name: global.clusterVersion
1055-
value: ""
1089+
value: "4.12"
10561090
- name: global.clusterPlatform
1057-
value: ""
1091+
value: "aws"
10581092
- name: global.hubClusterDomain
10591093
value: apps.hub.example.com
10601094
- name: global.localClusterDomain

0 commit comments

Comments
 (0)