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
feat: support branch values for environment variable contexts #4977
Conversation
📊 Benchmark resultsComparing with 2c337b0 Package size: 222 MB(no change)
Legend
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Left one suggestion (in two places)
docs/commands/env.md
Outdated
**Examples** | ||
|
||
```bash | ||
netlify env:list # list dev context and any scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[sand] suggestion to elaborate a bit, similar to the example you used for get:
netlify env:list # list dev context and any scope | |
netlify env:list # list variables with values in the dev context and with any scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I assume this is auto-generated, I'll leave this comment in the JS file :)
src/commands/env/env-list.js
Outdated
) | ||
.addOption( | ||
new Option('-s, --scope <scope>', 'Specify a scope') | ||
.choices(['builds', 'functions', 'post_processing', 'runtime', 'any']) | ||
.default('any'), | ||
) | ||
.addExamples([ | ||
'netlify env:list # list dev context and any scope', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[sand] suggestion to elaborate a bit, similar to the example you used for get:
'netlify env:list # list dev context and any scope', | |
'netlify env:list # list variables with values in the dev context and with any scope', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All my feedback from issues has been addressed, thanks! LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refreshing my approval status after the copy updates, LGTM! 🚀
@@ -144,7 +144,7 @@ const createEnvListCommand = (program) => | |||
.default('any'), | |||
) | |||
.addExamples([ | |||
'netlify env:list # list dev context and any scope', | |||
'netlify env:list # list variables with values in the dev context and with any scope', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
e136c43
* feat: support branch values in env:list * feat: support branch values in env:get * feat: support branch values for contexts in build and dev * feat: support branch values for contexts in env:set * feat: support branch values for contexts in env:unset * test: fix some tests * fix: remove cruft * docs: npm run docs * chore: update logs to print either `context` or `branch` correctly * test: update tests * fix: fix example help text in `env:get --help` * fix: fix netlify/pillar-workflow#818 * fix: fix netlify/pillar-workflow#815 * fix: fix netlify/pillar-workflow#816 and fix netlify/pillar-workflow#817 * docs: addressing uma's feedback * chore: update contributors field Co-authored-by: jasonbarry <jasonbarry@users.noreply.github.com>
Summary
Fixes https://github.com/netlify/pillar-workflow/issues/814
This PR lets users specify branches as contexts for the various
env
commands.netlify build
allows using a--context
flag to build a site using env vars specified in the toml file as under[context.<thing>.environment]
, where<thing>
is either a reserved context keyword (likedev
,production
, ordeploy-preview
), or any string, which corresponds to a git branch.We've ported over that functionality to the UI to allow these types of branch overrides to be more specific than contexts when the git branch matches. For example, if you set
FOO=bar
for thebranch-deploy
context, and also have a branch-specific value ofFOO=bang
on thestaging
branch, the value ofbang
will take precedence when you visit thestaging
branch's branch deploy.This PR brings parity to the CLI so that you can use
env
,build
, anddev
commands to get/set environment variable values to have a branch-specific value.You can use branch-specific values simply by using a non-reserved context keyword like
ntl env:get --context staging
, or by prepending thebranch:
prefix, likentl env:get --context branch:staging
, for clarity.Branch names are normalized using commander's custom option processing.
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)