Open helgi opened 8 years ago
@bacongobbler suggested we take a look at https://github.com/joho/godotenv to handle the env file parsing.
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.
Moving this on behalf of @JeanMertz from https://github.com/deis/controller/issues/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.