mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Fix transports issues in podman_image (#619)
Fix #218 #205 #264 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
2ae2309cb8
commit
7ad3dc53d5
1 changed files with 11 additions and 17 deletions
|
|
@ -781,19 +781,12 @@ class PodmanImageManager(object):
|
|||
# Build the destination argument
|
||||
dest = self.push_args.get('dest')
|
||||
dest_format_string = '{dest}/{image_name}'
|
||||
regexp = re.compile(r'/{name}(:{tag})?'.format(name=self.name, tag=self.tag))
|
||||
if not dest:
|
||||
if '/' not in self.name:
|
||||
self.module.fail_json(msg="'push_args['dest']' is required when pushing images that do not have the remote registry in the image name")
|
||||
|
||||
# If the push destination contains the image name and/or the tag
|
||||
# remove it and warn since it's not needed.
|
||||
elif regexp.search(dest):
|
||||
dest = regexp.sub('', dest)
|
||||
self.module.warn("Image name and tag are automatically added to push_args['dest']. Destination changed to {dest}".format(dest=dest))
|
||||
|
||||
if dest and dest.endswith('/'):
|
||||
dest = dest[:-1]
|
||||
if dest:
|
||||
dest = dest.rstrip('/')
|
||||
|
||||
transport = self.push_args.get('transport')
|
||||
if transport:
|
||||
|
|
@ -806,19 +799,20 @@ class PodmanImageManager(object):
|
|||
else:
|
||||
dest_format_string = '{transport}:{dest}'
|
||||
|
||||
dest_string = dest_format_string.format(transport=transport, name=self.name, dest=dest, image_name=self.image_name,)
|
||||
dest_string = dest_format_string.format(transport=transport, name=self.name, dest=dest, image_name=self.image_name,)
|
||||
else:
|
||||
if len(dest.split('/')) < 3:
|
||||
dest_string = f'{dest}/{self.image_name}'
|
||||
else:
|
||||
dest_string = dest
|
||||
|
||||
# Only append the destination argument if the image name is not a URL
|
||||
if '/' not in self.name:
|
||||
args.append(dest_string)
|
||||
args.append(dest_string)
|
||||
self.module.log("PODMAN-IMAGE-DEBUG: Pushing image {image_name} to {dest_string}".format(image_name=self.image_name, dest_string=dest_string))
|
||||
|
||||
rc, out, err = self._run(args, ignore_errors=True)
|
||||
if rc != 0:
|
||||
self.module.fail_json(msg="Failed to push image {image_name}: {err}".format(image_name=self.image_name, err=err))
|
||||
last_id = self._get_id_from_output(
|
||||
out + err, contains=':', split_on=':')
|
||||
|
||||
return self.inspect_image(last_id), out + err
|
||||
return self.inspect_image(self.image_name), out + err
|
||||
|
||||
def remove_image(self, image_name=None):
|
||||
if image_name is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue