build icon indicating copy to clipboard operation
build copied to clipboard

Improve support for environment variable as inputs

Open ehmicky opened this issue 4 years ago • 1 comments

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 the description that normal inputs 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 the default keyword like normal inputs do. Because of this, configuration that is either an environment variable or a normal input cannot be put in manifest.yml, and some plugin authors have removed inputs from manifest.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?

ehmicky avatar Jun 01 '20 21:06 ehmicky

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.

verythorough avatar Jun 01 '20 23:06 verythorough

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!

github-actions[bot] avatar Mar 25 '23 14:03 github-actions[bot]

@ticachica @krider2010 is this issue useful at all in the context of SDK plans?

verythorough avatar Mar 27 '23 20:03 verythorough

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!

krider2010 avatar Mar 30 '23 13:03 krider2010