geofffranks / spruce

A BOSH template merge tool
MIT License
426 stars 77 forks source link

feature-request: allow referencing environment variables using configurable set of prefixes #373

Open dikderoy opened 1 year ago

dikderoy commented 1 year ago

Hi there.

I would love it if spruce could refer to env variables using not only $VAR_NAME but also other prefixes (which could be fixed or passed as an option from CMD.

Use-case:

I use spruce extensively on CI environments to produce configurations dynamically.

In cases when spruce configurations are passed around inside CI, it is not always possible to disable variable expansion. Sometimes I even want some parts to be expanded while others should remain unexpanded - specifically spruce operators like (( grab $VAR_NAME )).

If it would be possible to define alternative prefixes that would not trigger shell expansion by themselves, it would've been great!

So ideally I would want to see an option to define a list of prefixes to use like:

spruce --env-prefixes="%,$,@" ... 

or just support for alternative prefixes - % and @ as potential options.

so that following spruce operators perform identically:

data1: ((grab $VAR_NAME))
data2: ((grab %VAR_NAME))