Skip to content

Commit

Permalink
fix: do not fail on bool docker opts when substituting
Browse files Browse the repository at this point in the history
  • Loading branch information
bertbesser committed Feb 21, 2021
1 parent d7f79f1 commit a530453
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/popper/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ def __apply_substitution(wf_element, k, v, used_registry):
used_registry[k] = 1

elif isinstance(wf_element, dict):
# we assume map of strings
for ek in wf_element:
if k in ek:
log.fail("Substitutions not allowed on dictionary keys")
if k in wf_element[ek]:
if type(wf_element[ek]) == str and k in wf_element[ek]:
log.debug(f"Applying substitution to value associated to key {k}")
wf_element[ek] = wf_element[ek].replace(k, v)
used_registry[k] = 1
Expand Down
25 changes: 25 additions & 0 deletions src/test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ def test_substitutions(self):
**{"wf_data": wf_data, "substitutions": ["SUB1=WRONG"]}
)

# allow non-str values
wf_data = {
"steps": [
{
"uses": "some_image",
"id": "some_$_DUMMY",
"env": {"FOO": "BAR"},
"secrets": ["a-secret"],
"options": {"auto_remove": True},
}
]
}
substitutions = [
"_DUMMY=dummy",
]
wf = WorkflowParser.parse(
wf_data=wf_data, substitutions=substitutions, allow_loose=True
)
step = wf.steps[0]
self.assertEqual("some_image", step.uses)
self.assertEqual("some_dummy", step.id)
self.assertEqual("BAR", step.env["FOO"])
self.assertEqual(("a-secret",), step.secrets)
self.assertEqual({"auto_remove": True}, step.options)

# expect error when not all given subs are used
wf_data = {
"steps": [
Expand Down

0 comments on commit a530453

Please sign in to comment.