diff options
author | Kristian Lewis Jones <klj613@kristianlewisjones.com> | 2016-03-21 15:24:43 +0000 |
---|---|---|
committer | Kristian Lewis Jones <klj613@kristianlewisjones.com> | 2016-03-22 10:00:47 +0000 |
commit | 6eaf8ce721351420fa12ed4368b71bebabdf3ace (patch) | |
tree | e48682a799a9d3251c1b87020a0583f3b49f5194 | |
parent | 5c1c42397cf0fdb74182df2d69822b82df8f2a6a (diff) | |
download | docker-py-6eaf8ce721351420fa12ed4368b71bebabdf3ace.tar.gz |
makes it possible to have '=' in the env file
note that the docker command line flag --env-file also allows '=' in the env file
Signed-off-by: Kristian Lewis Jones <klj613@kristianlewisjones.com>
-rw-r--r-- | docker/utils/utils.py | 2 | ||||
-rw-r--r-- | tests/unit/utils_test.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 70fcb1f..d2507aa 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -834,7 +834,7 @@ def parse_env_file(env_file): if line[0] == '#': continue - parse_line = line.strip().split('=') + parse_line = line.strip().split('=', 1) if len(parse_line) == 2: k, v = parse_line environment[k] = v diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index c744604..ec78713 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -355,6 +355,14 @@ class ParseEnvFileTest(base.BaseTestCase): {'USER': 'jdoe', 'PASS': 'secret'}) os.unlink(env_file) + def test_parse_env_file_with_equals_character(self): + env_file = self.generate_tempfile( + file_content='USER=jdoe\nPASS=sec==ret') + get_parse_env_file = parse_env_file(env_file) + self.assertEqual(get_parse_env_file, + {'USER': 'jdoe', 'PASS': 'sec==ret'}) + os.unlink(env_file) + def test_parse_env_file_commented_line(self): env_file = self.generate_tempfile( file_content='USER=jdoe\n#PASS=secret') |