Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_image_buid: fix composition of --output parameters #947

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading