From 6eaf8ce721351420fa12ed4368b71bebabdf3ace Mon Sep 17 00:00:00 2001 From: Kristian Lewis Jones Date: Mon, 21 Mar 2016 15:24:43 +0000 Subject: [PATCH] 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 --- docker/utils/utils.py | 2 +- tests/unit/utils_test.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 70fcb1f0..d2507aa1 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 c744604d..ec787130 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')