Skip to content

Commit 3c02fc4

Browse files
committed
Merge pull request #1004 from klj613/allow-equals-character-in-env-file
makes it possible to have '=' in the env file
2 parents 237f531 + 6eaf8ce commit 3c02fc4

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
@@ -845,7 +845,7 @@ def parse_env_file(env_file):
845845
if line[0] == '#':
846846
continue
847847

848-
parse_line = line.strip().split('=')
848+
parse_line = line.strip().split('=', 1)
849849
if len(parse_line) == 2:
850850
k, v = parse_line
851851
environment[k] = v

tests/unit/utils_test.py

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

374+
def test_parse_env_file_with_equals_character(self):
375+
env_file = self.generate_tempfile(
376+
file_content='USER=jdoe\nPASS=sec==ret')
377+
get_parse_env_file = parse_env_file(env_file)
378+
self.assertEqual(get_parse_env_file,
379+
{'USER': 'jdoe', 'PASS': 'sec==ret'})
380+
os.unlink(env_file)
381+
374382
def test_parse_env_file_commented_line(self):
375383
env_file = self.generate_tempfile(
376384
file_content='USER=jdoe\n#PASS=secret')

0 commit comments

Comments
 (0)