Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

.env file, and configuration variables with newlines #891

Closed
JeanMertz opened this issue Jul 16, 2016 · 5 comments
Closed

.env file, and configuration variables with newlines #891

JeanMertz opened this issue Jul 16, 2016 · 5 comments

Comments

@JeanMertz
Copy link

JeanMertz commented Jul 16, 2016

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.

@helgi
Copy link
Contributor

helgi commented Jul 16, 2016

We have multiline tests for config:set https://github.com/deis/workflow-e2e/blob/master/tests/config_test.go#L120-L142 - Have you tried this with config:set to verify it would work that way?

We should move this to https://github.com/deis/workflow-cli since config:fetch is a CLI functionality that backs on to config:set

@JeanMertz
Copy link
Author

@helgi Thanks for the reply.

I know about test-case (I linked to it in my original post), but this is about config:push (sorry, I just noticed my original post mentioned config:fetch).

It's less about if the backend can handle newlines, and more about how I handle newlines in a .env file when using config:push. I don't think there's a test for that, and I don't think it actually works (at least, I haven't been able to get this to work).

@bacongobbler
Copy link
Member

The best way would be to base64 encode your environment variable and then decode it within your app. So far that's been the best way to preserve newline characters within environment variables.

@JeanMertz
Copy link
Author

The best way would be to base64 encode your environment variable

Yes, I mentioned that in my initial post:

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

But as I said, that seems more like a work-around, or are multiline values simply not supported in .env files?

I opened this issue, because there are test-cases for config:set with multiline variables, and I was under the impression that config:push was more of a "bulk-set" operation, but for that to be the case, it needs to support the same type of variables as set does.

@helgi
Copy link
Contributor

helgi commented Sep 8, 2016

Moved this to the CLI project deis/workflow-cli#228

@helgi helgi closed this as completed Sep 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants