diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 4fd1b9564bf27a53334f07e9dd14f75f9202fe4d..3e8b6bbceb085d9c1587121f8e534c58cbfb1f2b 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -3,3 +3,20 @@ {{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }} {{- end }} {{- end }} + +{{/* +Build the appropriate spec.ref.{} given git branch, commit values +*/}} +{{- define "validRef" -}} +{{- if .commit -}} +{{- if not .branch -}} +{{- fail "A valid branch is required when a commit is specified!" -}} +{{- end -}} +branch: {{ .branch }} +commit: {{ .commit }} +{{- else if .tag -}} +tag: {{ .tag }} +{{- else -}} +branch: {{ .branch }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/chart/templates/clusterauditor/gitrepository.yaml b/chart/templates/clusterauditor/gitrepository.yaml index 96037b7fc5bf3d24946ffc618139a076b3e8c3a0..9fcdc95452577df56b6535cd6e63b8f1d72d6082 100644 --- a/chart/templates/clusterauditor/gitrepository.yaml +++ b/chart/templates/clusterauditor/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.clusterAuditor.git.commit }} - commit: {{ .Values.clusterAuditor.git.commit }} -{{- else if .Values.clusterAuditor.git.tag }} - tag: {{ .Values.clusterAuditor.git.tag }} -{{- else }} - branch: {{ .Values.clusterAuditor.git.branch }} -{{- end }} url: {{ .Values.clusterAuditor.git.repo }} + ref: + {{- include "validRef" .Values.clusterAuditor.git | nindent 4 }} {{- end }} diff --git a/chart/templates/gatekeeper/gitrepository.yaml b/chart/templates/gatekeeper/gitrepository.yaml index 76c391e936e1e9da01526267fba4d2a6b31cbfe8..b7561bca37a60c7b2ecb5af65c652d5033f0e70e 100644 --- a/chart/templates/gatekeeper/gitrepository.yaml +++ b/chart/templates/gatekeeper/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.gatekeeper.git.commit }} - commit: {{ .Values.gatekeeper.git.commit }} -{{- else if .Values.gatekeeper.git.tag }} - tag: {{ .Values.gatekeeper.git.tag }} -{{- else }} - branch: {{ .Values.gatekeeper.git.branch }} -{{- end }} url: {{ .Values.gatekeeper.git.repo }} + ref: + {{- include "validRef" .Values.gatekeeper.git | nindent 4 }} {{- end }} diff --git a/chart/templates/istio/gitrepository.yaml b/chart/templates/istio/gitrepository.yaml index e4164ef900120d7528e5f0c52dd5f062f7230a06..724309482fd9e322d70b824a969957832428ac16 100644 --- a/chart/templates/istio/gitrepository.yaml +++ b/chart/templates/istio/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.istio.git.commit }} - commit: {{ .Values.istio.git.commit }} -{{- else if .Values.istio.git.tag }} - tag: {{ .Values.istio.git.tag }} -{{- else }} - branch: {{ .Values.istio.git.branch }} -{{- end }} url: {{ .Values.istio.git.repo }} + ref: + {{- include "validRef" .Values.istio.git | nindent 4 }} {{- end }} diff --git a/chart/templates/logging/gitrepository.yaml b/chart/templates/logging/gitrepository.yaml index 2d6d4e7bf7a375c1d4d2419391696217a40ba924..3aadf178a171d4e581ae69124d80da822296d8f3 100644 --- a/chart/templates/logging/gitrepository.yaml +++ b/chart/templates/logging/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.logging.git.commit }} - commit: {{ .Values.logging.git.commit }} -{{- else if .Values.logging.git.tag }} - tag: {{ .Values.logging.git.tag }} -{{- else }} - branch: {{ .Values.logging.git.branch }} -{{- end }} url: {{ .Values.logging.git.repo }} + ref: + {{- include "validRef" .Values.logging.git | nindent 4 }} {{- end }} diff --git a/chart/templates/monitoring/gitrepository.yaml b/chart/templates/monitoring/gitrepository.yaml index 819543bbed44e5257d9c30db78787eb78ba08bc8..d638a84749868f5002429c22b0b76d812cb5d44a 100644 --- a/chart/templates/monitoring/gitrepository.yaml +++ b/chart/templates/monitoring/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.monitoring.git.commit }} - commit: {{ .Values.monitoring.git.commit }} -{{- else if .Values.monitoring.git.tag }} - tag: {{ .Values.monitoring.git.tag }} -{{- else }} - branch: {{ .Values.monitoring.git.branch }} -{{- end }} url: {{ .Values.monitoring.git.repo }} + ref: + {{- include "validRef" .Values.monitoring.git | nindent 4 }} {{- end }} diff --git a/chart/templates/twistlock/gitrepository.yaml b/chart/templates/twistlock/gitrepository.yaml index 1b835cab631e3e95969f28d034f82a8eef306839..971cdd71778d351837c8c8e592767605b3cffa9e 100644 --- a/chart/templates/twistlock/gitrepository.yaml +++ b/chart/templates/twistlock/gitrepository.yaml @@ -11,13 +11,7 @@ spec: /**/*.txt /**/*.sh interval: {{ .Values.flux.interval }} - ref: -{{- if .Values.twistlock.git.commit }} - commit: {{ .Values.twistlock.git.commit }} -{{- else if .Values.twistlock.git.tag }} - tag: {{ .Values.twistlock.git.tag }} -{{- else }} - branch: {{ .Values.twistlock.git.branch }} -{{- end }} url: {{ .Values.twistlock.git.repo }} + ref: + {{- include "validRef" .Values.twistlock.git | nindent 4 }} {{- end }} diff --git a/chart/values.yaml b/chart/values.yaml index c381e629ea54d28947c1e2b53a94f1fdfe266fdd..83d9b2bb7364f948cdc1d211e0f63c974310da08 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -27,8 +27,8 @@ istio: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/core/servicemesh.git branch: chart-release - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {} clusterAuditor: @@ -36,8 +36,8 @@ clusterAuditor: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/core/cluster-auditor.git branch: chart-release - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {} gatekeeper: @@ -45,8 +45,8 @@ gatekeeper: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/core/policy.git branch: chart-release - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {} logging: @@ -54,8 +54,8 @@ logging: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/core/logging.git branch: release-v0.2.x - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {} monitoring: @@ -63,8 +63,8 @@ monitoring: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/core/monitoring.git branch: release-v0.2.x - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {} twistlock: @@ -72,6 +72,6 @@ twistlock: git: repo: https://repo1.dsop.io/platform-one/big-bang/apps/security-tools/twistlock.git branch: chart-release - # commit: "" - # tag: "" +# commit: "" +# tag: "" values: {}