Skip to content

Instantly share code, notes, and snippets.

@beekhof
Last active August 11, 2022 16:38
Show Gist options
  • Save beekhof/8e4dee2234d03f741b66bc3bf8a58884 to your computer and use it in GitHub Desktop.
Save beekhof/8e4dee2234d03f741b66bc3bf8a58884 to your computer and use it in GitHub Desktop.
diff --git a/clustergroup/templates/applications.yaml b/clustergroup/templates/applications.yaml
index 7e17afc..4952f06 100644
--- a/clustergroup/templates/applications.yaml
+++ b/clustergroup/templates/applications.yaml
@@ -33,17 +33,17 @@ spec:
{{- end }}
# Watch the progress of https://issues.redhat.com/browse/GITOPS-891 and update accordingly
parameters:
- - name: global.repoURL
+ - name: {{ default "global.repoURL" .repoField }}
value: $ARGOCD_APP_SOURCE_REPO_URL
- - name: global.targetRevision
+ - name: {{ default "global.targetRevision" .targetRevisionField }}
value: $ARGOCD_APP_SOURCE_TARGET_REVISION
- - name: global.namespace
+ - name: {{ default "global.namespace" .namespaceField }}
value: $ARGOCD_APP_NAMESPACE
- - name: global.pattern
+ - name: {{ default "global.pattern" .patternNameField }}
value: {{ $.Values.global.pattern }}
- - name: global.hubClusterDomain
+ - name: {{ default "global.hubClusterDomain" .hubClusterDomainField }}
value: {{ $.Values.global.hubClusterDomain }}
- - name: global.localClusterDomain
+ - name: {{ default "global.localClusterDomain" .domainField }}
value: {{ coalesce $.Values.global.localClusterDomain $.Values.global.hubClusterDomain }}
{{- range .overrides }}
- name: {{ .name }}
@mhjacks
Copy link

mhjacks commented Aug 11, 2022

OK - I read this differently, initially. I read it as "we should offer the ability to have different override values for the "global" pattern variables we normally set in the pattern framework. So, I definitely see a use for that if you want to refer to a different URL than the "self" repo (for lack of a better term; the gitops repo that primarily drives the pattern).

But upon looking at this more closely, it's clear that this approach would be allowing us to change the names of the overrides, and I'm struggling a bit to see a reason we'd want to do that. It would have to be a scenario where we want one of the "implicit" values we set, but the name of the override for it would have to change. (And, that would be exclusive of using the usual name of the override.) Which might be weird.

So, I can see why this might be helpful for domain (in particular, but possibly in an "additiive" way), for example:

- name: global.localClusterDomain
  value: {{ coalesce $.Values.global.localClusterDomain $.Values.global.hubClusterDomain }}
- name: {{ .domainField }}
  value: {{ coalesce $.Values.global.localClusterDomain $.Values.global.hubClusterDomain }}

And I think in practice we'd want to conditionalize it so that if not .domainField the section gets skipped entirely. The idea might generalize like this:

{{- range .domainFields }}
- name: {{ . }}
  value: {{ coalesce $.Values.global.localClusterDomain $.Values.global.hubClusterDomain }}
{{- end }}

Which avoids a lot of (imo) ugly conditionals, while still allowing multiple overrides per field, and not violating a potential user expectation about variables the pattern sets implicitly.

I see potential of mischief if we wind up undefining the clusterdomain variables in particular; several patterns use those, and I could definitely see those being co-opted into other charts in this way. (It's a neat dodge, allowing for the manipulation of values without actually templating the values file itself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment