This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 277
Proposal: Allow variable interpolation in generator values
field
#371
Labels
enhancement
New feature or request
Comments
Hey, sorry for the bump. Just want to check if you're on board with this before I write code for it. @jgwest can I take the addition of the |
blakepettersson
added a commit
to blakepettersson/argo-cd
that referenced
this issue
Apr 29, 2022
Allow the interpolation of `values` found in the cluster generator. This allows interpolation of `{{name}}`, `{{server}}`, `{{metadata.labels.*}}` and `{{metadata.annotations.*}}`. See argoproj/applicationset#371. This interpolation could potentially be extended to the list and duck-type generators if desired.
10 tasks
blakepettersson
added a commit
to blakepettersson/argo-cd
that referenced
this issue
Jun 24, 2022
Allow the interpolation of `values` found in the cluster generator. This allows interpolation of `{{name}}`, `{{server}}`, `{{metadata.labels.*}}` and `{{metadata.annotations.*}}`. See argoproj/applicationset#371. This interpolation could potentially be extended to the list and duck-type generators if desired. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
crenshaw-dev
pushed a commit
to argoproj/argo-cd
that referenced
this issue
Jun 27, 2022
* feat: allow interpolation of generator values Allow the interpolation of `values` found in the cluster generator. This allows interpolation of `{{name}}`, `{{server}}`, `{{metadata.labels.*}}` and `{{metadata.annotations.*}}`. See argoproj/applicationset#371. This interpolation could potentially be extended to the list and duck-type generators if desired. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com> * docs: add values interpolation usage instructions Add a basic example of how values interpolation can be used with the cluster generator. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com> * fix: remove billion-laughs attack vector The previous implementation was vulnerable to a billion-laughs attack, where someone could interpolate values based upon other values, something like: ```yaml values: lol1: lol lol2: '{{values.lol1}}{{values.lol1}}' # lol3: '{{values.lol2}}{{values.lol2}}{{values.lol2}}{{values.lol2}}' ``` To counteract that, instead of directly manipulating the `params` map, we create a map to keep track of the interpolated values, and only template the values which have been previously whitelisted. Once we go through all the values, we then merge the interpolated values map back to the `params` map. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Context
While using the cluster generator, we recently ran into a situation where being able to template the contents of the
values
map based on the parameters of each cluster.The specific situation was that we wanted to make it possible for devs to opt into deploying an environment-specific image from a branch, somewhat like this example from the docs, but where the environment and branch are per-developer.
For anyone not opted in, they hit a different
selector
and fall back to images built from themain
branch.Current workaround
Ideally, we would be able to construct the image URL as a value based on the cluster parameters (we're using the environment name for it). That would make it easy to supply a different, hardcoded value of
main
for any deployments that aren't opted into environment-specific images.The workaround we're currently using is to have different generator templates on the two selectors, which leads to a fair amount of duplication due to the way the merge algorithm works.
Proposal
We would like to add the same parameter templating that's available in in the
template
itself to the map values in thevalues
key of the selector. Running with the example from the cluster generator docs, it would look something like:If you're on board with the idea, I'm happy to go ahead and put a PR together that adds this functionality to the controller!
The text was updated successfully, but these errors were encountered: