Merge "Change naming of key arguments in runner"

This commit is contained in:
Zuul 2018-11-08 14:18:06 +00:00 committed by Gerrit Code Review
commit 328e983d52
3 changed files with 10 additions and 8 deletions

View File

@ -212,7 +212,9 @@ class BaseBuilder(object):
for image in sorted(images):
# only pull if the image does not exist locally
if self.runner.inspect(image, format='exists', type='image'):
if self.runner.inspect(image,
output_format='exists',
o_type='image'):
continue
try:

View File

@ -73,17 +73,17 @@ class BaseRunner(object):
return [c for c in cmd_stdout.split()]
def inspect(self, name, format=None, type='container'):
cmd = [self.cont_cmd, 'inspect', '--type', type]
if format:
def inspect(self, name, output_format=None, o_type='container'):
cmd = [self.cont_cmd, 'inspect', '--type', o_type]
if output_format:
cmd.append('--format')
cmd.append(format)
cmd.append(output_format)
cmd.append(name)
(cmd_stdout, cmd_stderr, returncode) = self.execute(cmd, self.log)
if returncode != 0:
return
try:
if format:
if output_format:
return cmd_stdout
else:
return json.loads(cmd_stdout)[0]
@ -93,7 +93,7 @@ class BaseRunner(object):
def unique_container_name(self, container):
container_name = container
while self.inspect(container_name, format='exists'):
while self.inspect(container_name, output_format='exists'):
suffix = ''.join(random.choice(
string.ascii_lowercase + string.digits) for i in range(8))
container_name = '%s-%s' % (container, suffix)

View File

@ -90,7 +90,7 @@ class TestBaseRunner(base.TestCase):
self.assertEqual(
"bar",
self.runner.inspect('one', format='{{foo}}')
self.runner.inspect('one', output_format='{{foo}}')
)
self.assert_execute(
popen, ['docker', 'inspect', '--type', 'container',