build
build copied to clipboard
Improve support for environment variable as inputs
Many Build plugins use environment variables as inputs. Some because the value is confidential, others like to choice to either environment variables or inputs to users.
At the moment, our support for environment variables to configure Build plugins has some limitations:
- It is not declared in
manifest.yml
. Therefore we won't be able to show in the UI in the future, including adding thedescription
that normalinputs
have. Or we can't programmatically know which environment variable might be used for which plugin by our users. - It cannot use the
required
validation keyword and thedefault
keyword like normal inputs do. Because of this, configuration that is either an environment variable or a normal input cannot be put inmanifest.yml
, and some plugin authors have removedinputs
frommanifest.yml
for that reason.
One potential solution to this problem would be to add an env
property to inputs
in manifest.yml
:
name: netlify-plugin-example
inputs:
- name: myInput
env: EXAMPLE_INPUT
description: Description of my input
required: false
default: example
This property would only do the following: if the user has not specified the plugin input but has specified the environment variable name (process.env.EXAMPLE_INPUT
in above example), the value of the input is taken from the environment variable. required
and default
still apply normally.
What do you think?
That provides a pretty clean fallback - I like that! Since it's a common use case, it would be nice to have something built-in like this rather than requiring authors to implement their own fallback behaviors.
This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!
@ticachica @krider2010 is this issue useful at all in the context of SDK plans?
Not really as we are moving away from build plugins externally so want to deprecate that. And the SDK would enable it in a different way. Thank you for the ping!