getpopper / popper

Container-native task automation engine.
https://getpopper.io
MIT License
302 stars 61 forks source link

CLI: bug with boolean docker options when substituting #968

Open bertbesser opened 3 years ago

bertbesser commented 3 years ago

This workflow uses a boolean docker option

steps:
- id: hello
  uses: "docker://alpine"
  runs: ['sh', '-c']
  args: ['echo hello ${WHO}']
  env:
    WHO: $_WHO
  options:
    auto_remove: true

When running it via ./popper run --substitution _WHO=bert -f wf.yml the following error arises:

[...]
  File "/usr/local/lib/python3.7/site-packages/popper/commands/cmd_run.py", line 179, in cli
    allow_loose=allow_loose,
  File "/usr/local/lib/python3.7/site-packages/popper/parser.py", line 113, in parse
    _wf_data, substitutions=substitutions, allow_loose=allow_loose
  File "/usr/local/lib/python3.7/site-packages/popper/parser.py", line 198, in __apply_substitutions
    step[attr], k, v, used
  File "/usr/local/lib/python3.7/site-packages/popper/parser.py", line 144, in __apply_substitution
    if k in wf_element[ek]:
TypeError: argument of type 'bool' is not iterable

Trying to solve the issue making the bool a string (auto_remove: "true") gives the following error:

[...]
ERROR: 500 Server Error: Internal Server Error ("json: cannot unmarshal string into Go struct field HostConfig.AutoRemove of type bool")

I.e., the docker daemon will not handle a string but demands a bool.

Side note: The problem does not arise when no substitutions are given.

Expected behavior: Bc the docker daemon demands a boolean value, the bug should be fixed by making the substitutions code handle boolean values gracefully.

bertbesser commented 3 years ago

Opened PR in #969 .