Give component user control for input / variable expansion behavior
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Note
Originated in https://gitlab.slack.com/archives/C06AQBJETRR/p1741706165927669 which may or may not be available when you click this link.
With the current feature set component authors can use expand_vars and with that "control" if an input should be taking literally or if it should expand variables when rendering.
However, most often it's the component user that knows if the input value should be expanded or not.
For example, in the OpenTofu CI/CD we currently have a request that "all" inputs should make use of expand_vars. While this may desirable for some users it may not be for others who expect the input values to be taken literally (for example they want to delay the expansion to be done for their shell in the job). Currently, there is no way to support both use cases for a component author.
There are related scenarios:
- sending the variable name and use as it is (no expansion anywhere)
- sending the variable name and expand_var (expansion in the component)
- sending the variable value (not available yet)
- sending the variable value and make it available as a variable in another name in the component (not available yet (discussion))
Ideas for giving control to the component user
Let a component user decide the expansion behavior per-input when they include the component:
include:
- component: gitlab.com/components/opentofu@1.0
inputs:
some_input:
value: $MY_VAR
expand_vars: true
another_input:
value: $ANOTHER_VAR # literal interpolation
Another option could be to support "functions" outside of components (this would probably be more involved):
include:
- component: gitlab.com/components/opentofu@1.0
inputs:
some_input:
value: $[[ $MY_VAR | expand_vars ]]
another_input:
value: $ANOTHER_VAR # literal interpolation