Fixes #17088 retcode now returns True or False based on return status

This commit is contained in:
Bernd May 2015-09-07 23:55:52 +02:00
parent 8b2e7cc4f5
commit d0c6128b8f
2 changed files with 7 additions and 8 deletions

View file

@ -2050,9 +2050,7 @@ def retcode(container, cmd):
command to execute
.. note::
The return is a bit different as we use the docker struct.
Output of the command is in 'out' and result is ``False`` if
command failed to execute.
The return is True or False depending on the commands success.
.. warning::
Be advised that this function allows for raw shell access to the named
@ -2067,7 +2065,7 @@ def retcode(container, cmd):
'''
status = base_status.copy()
return _run_wrapper(
status, container, 'cmd.retcode', cmd)
status, container, 'cmd.retcode', cmd)['status']
def get_container_root(container):

View file

@ -788,7 +788,7 @@ def run(name,
if not onlyif:
return valid(comment='onlyif execution failed')
elif isinstance(onlyif, string_types):
if retcode(cid, onlyif) != 0:
if not retcode(cid, onlyif):
return valid(comment='onlyif execution failed')
if unless is not None:
@ -796,7 +796,7 @@ def run(name,
if unless:
return valid(comment='unless execution succeeded')
elif isinstance(unless, string_types):
if retcode(cid, unless) == 0:
if retcode(cid, unless):
return valid(comment='unless execution succeeded')
if docked_onlyif is not None:
@ -804,7 +804,7 @@ def run(name,
if not docked_onlyif:
return valid(comment='docked_onlyif execution failed')
elif isinstance(docked_onlyif, string_types):
if retcode(cid, docked_onlyif) != 0:
if not retcode(cid, docked_onlyif):
return valid(comment='docked_onlyif execution failed')
if docked_unless is not None:
@ -812,8 +812,9 @@ def run(name,
if docked_unless:
return valid(comment='docked_unless execution succeeded')
elif isinstance(docked_unless, string_types):
if retcode(cid, docked_unless) == 0:
if retcode(cid, docked_unless):
return valid(comment='docked_unless execution succeeded')
# run only if the above did not bail
result = drun_all(cid, name)
if result['status']:
return valid(comment=result['comment'])