mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 18:31:25 -07:00
Backport of https://github.com/ansible-collections/community.docker/pull/87 to stable-1. (#1983)
This commit is contained in:
parent
3d3e47fc87
commit
1e1a843ff3
4 changed files with 25 additions and 5 deletions
|
@ -636,6 +636,9 @@ class AnsibleDockerClient(Client):
|
|||
if len(images) == 1:
|
||||
try:
|
||||
inspection = self.inspect_image(images[0]['Id'])
|
||||
except NotFound:
|
||||
self.log("Image %s:%s not found." % (name, tag))
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail("Error inspecting image %s:%s - %s" % (name, tag, str(exc)))
|
||||
return inspection
|
||||
|
@ -643,7 +646,7 @@ class AnsibleDockerClient(Client):
|
|||
self.log("Image %s:%s not found." % (name, tag))
|
||||
return None
|
||||
|
||||
def find_image_by_id(self, image_id):
|
||||
def find_image_by_id(self, image_id, accept_missing_image=False):
|
||||
'''
|
||||
Lookup an image (by ID) and return the inspection results.
|
||||
'''
|
||||
|
@ -653,6 +656,11 @@ class AnsibleDockerClient(Client):
|
|||
self.log("Find image %s (by ID)" % image_id)
|
||||
try:
|
||||
inspection = self.inspect_image(image_id)
|
||||
except NotFound as exc:
|
||||
if not accept_missing_image:
|
||||
self.fail("Error inspecting image ID %s - %s" % (image_id, str(exc)))
|
||||
self.log("Image %s not found." % image_id)
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail("Error inspecting image ID %s - %s" % (image_id, str(exc)))
|
||||
return inspection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue