Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template values #374

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,18 @@ argo-healthcheck: ## Checks if all argo applications are synced

CHARTS=$(shell find . -type f -iname 'Chart.yaml' -exec dirname "{}" \; | grep -v examples | sed -e 's/.\///')
# Section related to tests and linting
TEST_OPTS= -f values-global.yaml --set global.repoURL="https://github.com/pattern-clone/mypattern" \
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" --set main.git.revision=main --set global.pattern="mypattern" \
--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\
--set "clusterGroup.imperative.jobs[0].name"="test" --set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
TEST_OPTS= -f values-global.yaml \
--set global.repoURL="https://github.com/pattern-clone/mypattern" \
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" \
--set main.git.revision=main --set global.pattern="mypattern" \
--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 \
--set global.clusterVersion="4.12" \
--set global.clusterPlatform=aws \
--set "clusterGroup.imperative.jobs[0].name"="test" \
--set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
PATTERN_OPTS=-f common/examples/values-example.yaml
EXECUTABLES=git helm oc ansible

Expand Down
17 changes: 13 additions & 4 deletions clustergroup/templates/plumbing/applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 12 }}
{{- range .extraValueFiles }}
- {{ . | quote }}
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
{{- range $valueFile := .extraValueFiles }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
{{- if .useGeneratorValues }}
values: |-
Expand Down Expand Up @@ -147,8 +150,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
{{- include "clustergroup.app.globalvalues.prefixedvaluefiles" $ | nindent 8 }}
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
{{- range $valueFile := .extraValueFiles }}
- {{ $valueFile | quote }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
parameters:
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}
Expand Down Expand Up @@ -211,8 +217,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 6 }}
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
{{- range $valueFile := .extraValueFiles }}
- {{ $valueFile | quote }}
- {{ tpl $valueFile $ | quote }}
{{- end }}
parameters:
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}
Expand Down
4 changes: 4 additions & 0 deletions clustergroup/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@
"type": "boolean",
"description": "If set to true the values is used to identify whether this is the hub cluster or an edge/spoke cluster configuration."
},
"sharedValueFiles": {
"type": "array",
"description": "Templated value file paths."
},
"namespaces": {
"type": "array",
"description": "This is the array of namespaces that the VP framework will create. In addition, operator groups will also be created for each namespace.",
Expand Down
2 changes: 2 additions & 0 deletions clustergroup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ global:
installPlanApproval: Automatic
applicationRetryLimit: 20


enabled: "all"

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

imperative:
jobs: []
Expand Down
5 changes: 5 additions & 0 deletions examples/values-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ clusterGroup:
name: example
#insecureUnsealVaultInsideCluster: false
isHubCluster: true
sharedValueFiles:
- /values/{{ .Values.global.clusterPlatform }}.yaml
- /values/{{ .Values.global.clusterVersion }}.yaml

namespaces:
- open-cluster-management:
Expand Down Expand Up @@ -63,6 +66,8 @@ clusterGroup:
namespace: application-ci
project: datacenter
path: charts/datacenter/pipelines
extraValueFiles:
- /values/{{ .Values.global.clusterVersion }}/{{ .Values.global.clusterPlatform }}.yaml

imperative:
namespace: imperative
Expand Down
2 changes: 1 addition & 1 deletion tests/acm-industrial-edge-hub.expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ spec:
- name: global.clusterVersion
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) }}'
- name: global.clusterPlatform
value:
value: aws
- name: clusterGroup.name
value: factory
- name: clusterGroup.isHubCluster
Expand Down
2 changes: 1 addition & 1 deletion tests/acm-medical-diagnosis-hub.expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ spec:
- name: global.clusterVersion
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) }}'
- name: global.clusterPlatform
value:
value: aws
- name: clusterGroup.name
value: region-one
- name: clusterGroup.isHubCluster
Expand Down
4 changes: 2 additions & 2 deletions tests/acm-normal.expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ spec:
- name: global.clusterVersion
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) }}'
- name: global.clusterPlatform
value:
value: aws
- name: clusterGroup.name
value: acm-edge
- name: clusterGroup.isHubCluster
Expand Down Expand Up @@ -722,7 +722,7 @@ spec:
- name: global.clusterVersion
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) }}'
- name: global.clusterPlatform
value:
value: aws
- name: clusterGroup.name
value: acm-provision-edge
- name: clusterGroup.isHubCluster
Expand Down
16 changes: 13 additions & 3 deletions tests/clustergroup-industrial-edge-factory.expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ data:
- manuela-factory-ml-workspace
projects:
- factory
sharedValueFiles: []
subscriptions:
- channel: stable
name: opendatahub-operator
Expand All @@ -135,7 +136,12 @@ data:
targetCluster: in-cluster
enabled: all
global:
Template:
BasePath: global-vars.yml
Name: global-vars
clusterDomain: region.example.com
clusterPlatform: aws
clusterVersion: "4.12"
extraValueFiles: []
git:
account: hybrid-cloud-patterns
Expand Down Expand Up @@ -412,7 +418,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-factory.yaml"
- "/values-factory.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-factory.yaml"
- "/values-4.12-factory.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -425,9 +435,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down
76 changes: 55 additions & 21 deletions tests/clustergroup-industrial-edge-hub.expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ data:
- production-datalake
- golang-external-secrets
- vault
sharedValueFiles: []
subscriptions:
acm:
channel: release-2.6
Expand Down Expand Up @@ -296,7 +297,12 @@ data:
targetCluster: in-cluster
enabled: all
global:
Template:
BasePath: global-vars.yml
Name: global-vars
clusterDomain: region.example.com
clusterPlatform: aws
clusterVersion: "4.12"
extraValueFiles: []
git:
account: hybrid-cloud-patterns
Expand Down Expand Up @@ -685,7 +691,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -698,9 +708,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -742,7 +752,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -755,9 +769,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -790,7 +804,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -803,9 +821,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -838,7 +856,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -851,9 +873,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -916,7 +938,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -929,9 +955,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -964,7 +990,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -977,9 +1007,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down Expand Up @@ -1039,7 +1069,11 @@ spec:
ignoreMissingValueFiles: true
valueFiles:
- "/values-global.yaml"
- "/values-datacenter.yaml"
- "/values-datacenter.yaml"
- "/values-aws.yaml"
- "/values-aws-4.12.yaml"
- "/values-aws-datacenter.yaml"
- "/values-4.12-datacenter.yaml"
parameters:
- name: global.repoURL
value: $ARGOCD_APP_SOURCE_REPO_URL
Expand All @@ -1052,9 +1086,9 @@ spec:
- name: global.clusterDomain
value: region.example.com
- name: global.clusterVersion
value: ""
value: "4.12"
- name: global.clusterPlatform
value: ""
value: "aws"
- name: global.hubClusterDomain
value: apps.hub.example.com
- name: global.localClusterDomain
Expand Down
Loading
Loading