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

.env file, and configuration variables with newlines #228

Open
helgi opened this issue Sep 8, 2016 · 2 comments
Open

.env file, and configuration variables with newlines #228

helgi opened this issue Sep 8, 2016 · 2 comments
Assignees

Comments

@helgi
Copy link
Contributor

helgi commented Sep 8, 2016

Moving this on behalf of @JeanMertz from deis/controller#891


I've seen this issue being tested in #268, except that that involves deis config:set, not deis config:push.

I have a .env file, that I want to contain a public key:

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMF802GSVwt2ZsFlmYR6Yy4rzZR8A
o5XaElze2V5JBjeT4fUnGrK0mjvYK/CTaCVHTwq8QsC1osfN7OifH4R+fQ==
-----END PUBLIC KEY-----
The question is: how to I get this into a .env file, and have it loaded properly as an environment variable? My attempts so far have failed.

I tried:

PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMF802GSVwt2ZsFlmYR6Yy4rzZR8A
o5XaElze2V5JBjeT4fUnGrK0mjvYK/CTaCVHTwq8QsC1osfN7OifH4R+fQ==
-----END PUBLIC KEY-----"
PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMF802GSVwt2ZsFlmYR6Yy4rzZR8A\no5XaElze2V5JBjeT4fUnGrK0mjvYK/CTaCVHTwq8QsC1osfN7OifH4R+fQ==\n-----END PUBLIC KEY-----"
and the same as above, but with single quotes.

None of these seem to do the trick.

I ended up base64 encoding the key, and decoding it on runtime, but that just seems like a workaround, not a proper solution.

@Joshua-Anderson
Copy link
Contributor

@bacongobbler suggested we take a look at https://github.com/joho/godotenv to handle the env file parsing.

@ultimateboy
Copy link
Member

ultimateboy commented Oct 4, 2016

I like the idea of using godotenv to replace some of the custom parsing logic of the .env file. Some initial testing shows that it does correctly handles \n within a quoted value (ie QUOTED_LINEBREAK="multiline\nstring") but quoted values bring up a potential additional bug and backwards compatibility question.

Quoted values (ie QUOTED_VAR="quoted string") currently include the quotes in the environment variable value. If we consider this a bug, then we can implement linebreak support without breaking backwards compatibility by implementing the above godotenv library.

If we want to maintain backwards compatibility with old .env files that might contain quotes, this gets complicated. I have a suspicion that we would have received a bug report if users were already trying to use quotes within a .env file and they noticed the quotes ended up within the environment variable values. So this feels like an acceptable solution to me.

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

3 participants