Skip to content
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

Add mechanism to sync site env vars to local process #142

Closed
DavidWells opened this issue Oct 9, 2018 · 10 comments
Closed

Add mechanism to sync site env vars to local process #142

DavidWells opened this issue Oct 9, 2018 · 10 comments

Comments

@DavidWells
Copy link
Contributor

We need a way to sync the Remote netlify sites build enviroment variables down to the local terminal process.env

Not sure what the command is but something like

netlify env:sync # ¯\_(ツ)_/¯

This would use the API to call into the site ID and pull back all the build env variables on process.env of the current terminal session.

@verythorough
Copy link
Contributor

verythorough commented Oct 9, 2018

Hehe, this is what I thought #134 was talking about, mostly because I was reading into it the idea I already had in my head. Now, this is what I actually had in mind!

I was thinking of some similar possible commands, like env:list (to see in terminal but not change files), and possibly env:push and env:pull.

I've been toying with how to handle variables you don't want syncing with Netlify. Possibly a comment wrapper to limit the syncing to a section of the file.

I also like the fact that you're authenticated as your Netlify user, so permissions are pretty clear - if you have permission to see/edit the variables in the Netlify UI, you have permission to sync them with the CLI.

@kinduff
Copy link

kinduff commented Oct 10, 2018

Love this idea. As a contribution to this conversation, I love how Kontena handles this.

Here's my idea as a heavy cmdline user:

$ netlify env:write FOO=bar # creates or overrides
$ netlify env:write BAZ=candy
$ netlify env:read FOO
FOO=bar
$ netlify env:ls
FOO=bar
BAZ=candy
$ netlify env:rm BAR
$ netlify env:push /path/to/env_in # overrides all
# or even $ netlify env:push | cat /path/to/env_in
$ netlify env:pull /path/to/env_out

@bcomnes
Copy link
Contributor

bcomnes commented Oct 23, 2018

I like it, wouldn't be hard to add.

@DavidWells
Copy link
Contributor Author

Yeah it makes sense! Very similar to how heroku env vars work https://devcenter.heroku.com/articles/config-vars#accessing-config-var-values-from-code

# Set vars
netlify env:set FOO=bar BAZ=lol

# Get vars
netlify env:get FOO
# Get vars output to json for piping
netlify env:get FOO --json

# List all vars
netlify env:list
netlify env:list --json
netlify env:list --output file/path

# Sync vars. Syncs remote vars with terminal process.env
netlify env:sync

(^ something like this)

We want to try and keep command semantics similar. IE netlify sites:list and netlify env:list etc. This is to keep the API easy to reason about when switching between commands

@muhajirdev
Copy link

Any progress on this?

@bcomnes
Copy link
Contributor

bcomnes commented Feb 20, 2019

@muhajirframe Not yet, sorry.

@seawatts
Copy link

@bcomnes how about now? Happy new year! 🥳

@RaeesBhatti
Copy link
Contributor

An app running in the terminal can't really manipulate terminal's env variables. You can just print them but the user will have to set them manually. Or they would need to do run $(netlify env:sync), where netlify env:sync would just print export SOMETHING=ELSE.

@RaeesBhatti
Copy link
Contributor

We already have mechanisms for setting the remote env variables to Netlify Dev in both app server and functions server. Not sure what purpose this would serve.

@RaeesBhatti
Copy link
Contributor

Closing this because a similar functionality already exists. (Read above 👆🏽). Feel free to reopen if not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants