Fix Dockerfile validation for shell and command

This is a backport of a fix that was included in
I46c259ddad5a6aaf9c7301e6c44cd8a1d5c457d3.

Change-Id: I02b11e0633ec05f2c31409e32b1238ee717f3b32
This commit is contained in:
Michal Nasiadka 2019-11-19 09:34:23 +00:00 committed by Mark Goddard
parent 3570a8eedd
commit 19ddfeaae5
1 changed files with 13 additions and 7 deletions

View File

@ -172,13 +172,19 @@ def check_docker_become():
"task %s in %s",
module, task['name'], fullpath)
for module in cmd_modules:
if (module in task and
task[module].startswith('docker') and
not task.get('become')):
return_code = 1
LOG.error("Use of docker in %s module without "
"become in task %s in %s",
module, task['name'], fullpath)
docker_without_become = False
if (module in task and not task.get('become')):
if (isinstance(task[module], str) and
(task[module]).startswith('docker')):
docker_without_become = True
if (isinstance(task[module], dict) and
task[module]['cmd'].startswith('docker')):
docker_without_become = True
if docker_without_become:
return_code = 1
LOG.error("Use of docker in %s module without "
"become in task %s in %s",
module, task['name'], fullpath)
return return_code