deis / workflow-cli

The CLI for Deis Workflow
http://deis.com
MIT License
31 stars 43 forks source link

config:push with .env does not support multline #291

Open deis-admin opened 7 years ago

deis-admin commented 7 years ago

From @sstarcher on September 19, 2015 18:38

If you have an environment variable with multiple lines config:push fails for that specific environment variable.

Copied from original issue: deis/deis#4512

deis-admin commented 7 years ago

From @benwilber on September 19, 2015 19:27

@sstarcher can you show an example of a multiline env variable? from the dotenv docs, you can double-quote multiline strings and use literal \n to separate lines:

FOO="bar\nbaz"

Or are you saying that this is what doesn't work?

deis-admin commented 7 years ago

From @sstarcher on September 19, 2015 21:35

@benwilber it seems that deis config:pull was not double quoting the multiline string.

deis-admin commented 7 years ago

From @sstarcher on September 19, 2015 23:48

I just tested adding a double quote to the .env file that was spit out by deis config:pull, it acts the same was as if no quotes exist and for each line of the multiline string it outputs the line and "does not match the pattern 'key=var', ex: MODE=test"

When the same multiline with double quote is done on the command line it works correctly.

deis-admin commented 7 years ago

From @benwilber on September 20, 2015 0:1

@sstarcher are you able to provide a couple quick examples of what you're seeing from deis config:pull and the same thing failing for deis config:push?

deis-admin commented 7 years ago

From @sstarcher on September 20, 2015 0:42

When I refer to Deis I'm referring to the platform version installed. All of the below is using deis client 1.10.0

In Deis 1.10.0 On the command line the following has the expected result of setting a multiline variable. Although it does complain does not match the pattern 'key=var', ex: MODE=test Creating config... ...

deis config:set HEALTHCHECK_INITIAL_DELAY=60 DERPY="HELLO                                                                               
dquote> world how
dquote> are you" -a app
'DERPY=HELLO
world how
are you' does not match the pattern 'key=var', ex: MODE=test
Creating config... done

=== app Config
HEALTHCHECK_INITIAL_DELAY      60
HEALTHCHECK_TIMEOUT            300
HEALTHCHECK_URL                /

After doing the above everything finishes correct, but when I do a deis config:pull or a deis config:list I don't see DERPY listed at all. This previously functioned with Deis 1.9.0.

On my Deis 1.9.0 system I have working multi line variables that show up when doing a deis config:list, but when I try to add new one's using the deis client 1.10.0 it no longer works and the added variables don't show up in deis config:list

A deis config:pull on the old platform produces

HEALTHCHECK_TIMEOUT=300
id_rsa=-----BEGIN RSA PRIVATE KEY-----
STUFF
THINGS
-----END RSA PRIVATE KEY-----
HEALTHCHECK_URL=/
HEALTHCHECK_INITIAL_DELAY=60

Which is not double quoted.

deis-admin commented 7 years ago

From @sstarcher on September 20, 2015 1:37

If I downgrade the deis client to 1.9.0 deis config:set with a multiline variable works and deis config:list shows the multiline variable.

If a multiline variable is set using deis client 1.9.0 and I do deis config:pull and deis config:push I get errors. If I go into the .env file that was created and quote the multline string it still does not function.

deis-admin commented 7 years ago

From @Joshua-Anderson on September 20, 2015 2:30

This is a bug with the new go client. I didn't consider multi line variables when writing and they're not properly handled. You can see the file here. Allowing multi line variables with config:set should be as simple as fixing the regex. Multi line config variables with config:pull will be more difficult as the client currently parses the config file by iterating over newlines.

deis-admin commented 7 years ago

From @Joshua-Anderson on September 20, 2015 3:2

I fixed the

deis config:set TEST="multi
line
var"

issue in #4513.

I'm not sure what the best approach for solving multi line config:push is, as newlines are used a separators for variables. How can you tell when a newline is part of a multi line config variable and not a config variable separator?

deis-admin commented 7 years ago

From @sstarcher on September 20, 2015 14:41

Could you take the naive approach and assume if you pass it through your regex and it does not match var=value than it goes with the previous variable?

deis-admin commented 7 years ago

From @bacongobbler on June 18, 2016 6:39

this is still relevant for v2. I propose we should move to a more formal library such as https://github.com/joho/godotenv for parsing .env files.

Cryptophobia commented 6 years ago

This issue was moved to teamhephy/workflow-cli#11