Azure-App-Service / python

base image for Python on linux app service
Apache License 2.0
55 stars 49 forks source link

Problem having equals ("=") in environment variables values #23

Closed Aorimn closed 5 years ago

Aorimn commented 5 years ago

We tried to have equals in the values of environment variables (for a Redis-generated key that is base64-encoded, but that shouldn't matter), but failed to have the proper value in the running app.

We've managed to pinpoint (at least that's from an external, newbie point-of-view) the issue to the init_container script. The awk is performed with the equal sign ("=") as the field separator, breaking any environment value with this character.

A possible idea would be to do something like this instead:

printenv | awk -F= 'sub("^([^=]+)=", "export "$1"=")'

I'm not an awk expert so I cannot really explain how it works or if it doesn't have any side effect, I just tested it like so on an Ubuntu:

$ export FOO=BAR=

$ printenv |grep FOO
FOO=BAR=

$ printenv | awk -F= '{print "export " $1"="$2 }' | grep FOO
export FOO=BAR

$ printenv | awk -F= 'sub("^([^=]+)=", "export "$1"=")'  | grep FOO
export FOO=BAR=
patricklee2 commented 5 years ago

fixed with #36