Skip to content

Commit 6eaf8ce

Browse files
committed
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 <[email protected]>
1 parent 5c1c423 commit 6eaf8ce

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docker/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ def parse_env_file(env_file):
834834
if line[0] == '#':
835835
continue
836836

837-
parse_line = line.strip().split('=')
837+
parse_line = line.strip().split('=', 1)
838838
if len(parse_line) == 2:
839839
k, v = parse_line
840840
environment[k] = v

tests/unit/utils_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ def test_parse_env_file_proper(self):
355355
{'USER': 'jdoe', 'PASS': 'secret'})
356356
os.unlink(env_file)
357357

358+
def test_parse_env_file_with_equals_character(self):
359+
env_file = self.generate_tempfile(
360+
file_content='USER=jdoe\nPASS=sec==ret')
361+
get_parse_env_file = parse_env_file(env_file)
362+
self.assertEqual(get_parse_env_file,
363+
{'USER': 'jdoe', 'PASS': 'sec==ret'})
364+
os.unlink(env_file)
365+
358366
def test_parse_env_file_commented_line(self):
359367
env_file = self.generate_tempfile(
360368
file_content='USER=jdoe\n#PASS=secret')

0 commit comments

Comments
 (0)