vals icon indicating copy to clipboard operation
vals copied to clipboard

Support nested expressions

Open jkroepke opened this issue 5 months ago • 4 comments

Hi,

I would like to use environment variables inside ref expression.

As I know, I can use ref+envsubst://$var to lookup environment variables. Now I would like to use within another expression, like:

ref+vault://ref+envsubst://$var/foo as native alternative to ref+vault://${var}/foo.

Is this supported by vals?

jkroepke avatar Sep 15 '25 16:09 jkroepke

I hacked something like this using refs and secretrefs, in two passes, in the past. Not ideal tho

aslafy-z avatar Sep 15 '25 17:09 aslafy-z

Since I looking for environment variables, what did you think about an CLI flag which enables expand env, before pass values to the backends?

jkroepke avatar Sep 15 '25 18:09 jkroepke

What about something like --max-passes that would configure how many level of interpolation could be done in a single call?

Interpoling variables in the "shell" format may cause issues with other tools.

My previous use case pulled up the ref backend "prefix" from a configuration file, so it could be generalized in some backend agnostic configuration. eg:

# config.yml
vals_prefix: ref+gcpsecrets://project/prefix_
vals_suffix: ?param=foo+
# manifest.yml
access_key: ref+file:///config.yml#/vals_prefix+access_keyref+file:///config.yml#/vals_suffix+

If such option was available, I could have run vals a single time with something like --max-passes=2

I know this does not look that good but it was the best solution that fitted my constraints I was able to find at the time.

aslafy-z avatar Sep 15 '25 18:09 aslafy-z

Hm, refer any external files (includes same) would not work well inside a Helm values.yaml executed on ArgoCD, because workdir is unknown

jkroepke avatar Sep 15 '25 18:09 jkroepke