🍀 Proposal
: Support different types of variables in yaml such as env
#1211
Labels
enhancement
New feature or request
What Would You Like to Add? Why Is This Needed?
Now, we already have a way to render variables in
yaml
like this:However, sometimes we can't write the original configuration to the yaml file because of data sensitivity, or for some other reason.
For example, when we want to access
GITHUB_TOKEN
, we will read it from the environment variable. But the problem is that we just tell the user "need to set this environment variable" in the plugin documentation, and we don't write the name in the yaml file, which will cause trouble for the user.Also, the current environment variables are hard-coded in the code, which can cause difficulties if the user's own environment variables conflict.
Design
Support different types of variables in yaml.
Since we have already used
go template
to render configs, why not use more features ofgo template
.We could use
[FuncMap](https://pkg.go.dev/text/template#FuncMap)
to define custom functions such asenv
.e.g.
Furthermore, we could validate all
env
as soon as configs were loaded to avoid the plugin from running halfway prompting that “the environment variable is not configured”Anything else
There are times when we may use logic: "takes the first data that is not empty".
For example, first from the output of the previous plugin, then from the environment variable, and then from K8s' Secret. (Getting data from K8s' Secret can also be defined as a go template custom function)
We should consider this at a later stage. Either define a new "use the first data that is not empty" function, or not support this complex definition in the configuration function and write the logic in the code and tell the user our fetching strategy.
The text was updated successfully, but these errors were encountered: