-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: support for using global variables in config file #393
Comments
Wait for more comments about |
If there are global variables, will there be local variables in each plugin scope to override the global variables? |
Good thinking. However, there are very few scenarios in which a configuration item needs to be repeatedly used in one plugin at present. It may be considered later when this scenario is more often. I think we can start by supporting global variables first. |
ProposalExample:
varNameA: A
varNameB: B
tools:
- name: app
plugin: some-plug-in
options:
variablesReferenceExampleA: [[ .varNameA ]]
variablesReferenceExampleB: some_prefix/[[ .varNameB ]]/some_suffix
outputsReferenceExample: ${{ name.plugin.outputs.key }} 1 How to Render VariablesWe want to use Go's It's the most simple way. After reading variables.yaml into a struct and config into bytes, before unmarshal config into a struct, we use Go's template to replace those vars. 2 Variables Naming ConventionUse 3 DelimitersBecause our output's syntax is "${{ name.plugin.outputs.key }}", we can't use "${{" and "}}" as delimiters any more. We can use "{{" and "}}" (Go template's default delimiters), but they are too similar to our output's syntax. So, we use "[[" and "]]" as delimiters. 4 Where to Define VariablesWe define variables in a separate file, rather than keeping it in the config. Reasons:
|
@daniel-hutao @imxw please review this simple design. |
Great design! @IronCore864 Can we use the "[[ varNameA ]]" without "." ? Anyway, I think many users will be confused with the "." |
I think we must have the dot:
Regex is a good idea. Let's try using |
lgtm |
Description
We sometimes need to use a configuration item multiple times in the config file, such as
github.owner
. If it can be configured through a variable, it will simplify the maintenance of the config file.Describe the Proposal
maybe:
The text was updated successfully, but these errors were encountered: