Skip to content

Commit

Permalink
Fix composition of --output parameters. (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Aug 1, 2024
1 parent 41445de commit d91f854
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/947-docker_image_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "docker_image_build - fix ``--output`` parameter composition for ``type=docker`` and ``type=image`` (https://github.com/ansible-collections/community.docker/issues/946, https://github.com/ansible-collections/community.docker/pull/947)."
21 changes: 11 additions & 10 deletions plugins/modules/docker_image_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
image:
- This exporter writes the build result as an image or a manifest list.
When using this driver, the image will appear in C(docker images).
- The image name can be provided in O(outputs[].name). If it is not provided, the
- The image name can be provided in O(outputs[].name). If it is not provided,
O(name) and O(tag) will be used.
- Optionally, image can be automatically pushed to a registry by setting O(outputs[].push=true).
required: true
dest:
Expand Down Expand Up @@ -433,19 +434,19 @@ def add_args(self, args):
if output['type'] == 'oci':
args.extend(['--output', 'type=oci,dest={dest}'.format(dest=output['dest'])])
if output['type'] == 'docker':
more = []
subargs = ['type=docker']
if output['dest'] is not None:
more.append('dest={dest}'.format(dest=output['dest']))
if output['dest'] is not None:
more.append('context={context}'.format(context=output['context']))
args.extend(['--output', 'type=docker,{more}'.format(more=','.join(more))])
subargs.append('dest={dest}'.format(dest=output['dest']))
if output['context'] is not None:
subargs.append('context={context}'.format(context=output['context']))
args.extend(['--output', ','.join(subargs)])
if output['type'] == 'image':
more = []
subargs = ['type=image']
if output['name'] is not None:
more.append('name={name}'.format(name=output['name']))
subargs.append('name={name}'.format(name=output['name']))
if output['push']:
more.append('push=true')
args.extend(['--output', 'type=image,{more}'.format(more=','.join(more))])
subargs.append('push=true')
args.extend(['--output', ','.join(subargs)])
return environ_update

def build_image(self):
Expand Down

0 comments on commit d91f854

Please sign in to comment.