engswee / flashpipe

The CI/CD Companion for SAP Integration Suite
https://engswee.github.io/flashpipe/
Apache License 2.0
33 stars 11 forks source link

dir-* flags: support environment variable substitution #32

Closed vadimklimov closed 4 months ago

vadimklimov commented 5 months ago

When passing configuration parameters as flags to the FlashPipe CLI, it is finely possible to use environment variables as parts of the configuration parameters' values as they will get transparently substituted with corresponding environment variables' values with the help of Shell expansions.

In contrast, when sourcing configuration from the configuration file, Shell expansions don't get executed and configuration parameters' values are read as-is.

Example: set $TMPDIR/flashpipe value for the dir-work configuration parameter, or $HOME/workspace/cpi-tenant value for the dir-git-repo configuration parameter - firstly, using CLI arguments, and then using the configuration file.

I can think of parameter and variable expansions as those that can become convenient, but this can further include some other Shell expansions - for example, tilde expansion, to reference the $HOME directory.

If such behaviour is not intended to be applied to configuration parameters' values when using the configuration file, then it may be worth mentioning this in the documentation.

On the other hand, if such an enhancement makes sense here, then environment variables expansion can be added with the help of os.ExpandEnv(). It may extend the existing implementation of config.GetString() functions. Or, not to mix it with existing config.Get*() functions, it may get implemented in a dedicated util function.

engswee commented 5 months ago

Thanks for sharing your idea on this. Haven't considered this use case, but it definitely makes sense ๐Ÿ‘๐Ÿป

Would you be interested to make the required changes and contribute them to the repository? ๐Ÿ˜‰

I think not all parameters need Shell expansions, so it's probably better having a separate function that is only called where it is needed. When handling Shell expansions, it'll probably be important to validate them as described in issue https://github.com/engswee/flashpipe/issues/3

vadimklimov commented 5 months ago

Thank you for your comments @engswee. I have submitted a pull request #33 for this change.

engswee commented 4 months ago

Support for shell expansion now included in release v3.4.0.

Thanks a lot for your contribution! ๐Ÿ˜‰