mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 04:18:42 +00:00
Avoid unnecessary string conversion.
This commit is contained in:
parent
82df0a745c
commit
8c5d9339ec
@ -255,7 +255,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||||||
try:
|
try:
|
||||||
inspect = client.get_json('/containers/{0}/json', id)
|
inspect = client.get_json('/containers/{0}/json', id)
|
||||||
except APIError as exc:
|
except APIError as exc:
|
||||||
raise AnsibleError(f"Error inspecting container {name} - {exc!s}")
|
raise AnsibleError(f"Error inspecting container {name} - {exc}")
|
||||||
|
|
||||||
state = inspect.get('State') or dict()
|
state = inspect.get('State') or dict()
|
||||||
config = inspect.get('Config') or dict()
|
config = inspect.get('Config') or dict()
|
||||||
|
|||||||
@ -468,7 +468,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
self.log(f"Image {name}:{tag} not found.")
|
self.log(f"Image {name}:{tag} not found.")
|
||||||
return None
|
return None
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error inspecting image {name}:{tag} - {exc!s}")
|
self.fail(f"Error inspecting image {name}:{tag} - {exc}")
|
||||||
return inspection
|
return inspection
|
||||||
|
|
||||||
self.log(f"Image {name}:{tag} not found.")
|
self.log(f"Image {name}:{tag} not found.")
|
||||||
@ -486,11 +486,11 @@ class AnsibleDockerClientBase(Client):
|
|||||||
inspection = self.inspect_image(image_id)
|
inspection = self.inspect_image(image_id)
|
||||||
except NotFound as exc:
|
except NotFound as exc:
|
||||||
if not accept_missing_image:
|
if not accept_missing_image:
|
||||||
self.fail(f"Error inspecting image ID {image_id} - {exc!s}")
|
self.fail(f"Error inspecting image ID {image_id} - {exc}")
|
||||||
self.log(f"Image {image_id} not found.")
|
self.log(f"Image {image_id} not found.")
|
||||||
return None
|
return None
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error inspecting image ID {image_id} - {exc!s}")
|
self.fail(f"Error inspecting image ID {image_id} - {exc}")
|
||||||
return inspection
|
return inspection
|
||||||
|
|
||||||
def _image_lookup(self, name, tag):
|
def _image_lookup(self, name, tag):
|
||||||
@ -502,7 +502,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
try:
|
try:
|
||||||
response = self.images(name=name)
|
response = self.images(name=name)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error searching for image {name} - {exc!s}")
|
self.fail(f"Error searching for image {name} - {exc}")
|
||||||
images = response
|
images = response
|
||||||
if tag:
|
if tag:
|
||||||
lookup = f"{name}:{tag}"
|
lookup = f"{name}:{tag}"
|
||||||
@ -539,7 +539,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
else:
|
else:
|
||||||
self.fail(f"Error pulling {name} - {line.get('error')}")
|
self.fail(f"Error pulling {name} - {line.get('error')}")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error pulling image {name}:{tag} - {exc!s}")
|
self.fail(f"Error pulling image {name}:{tag} - {exc}")
|
||||||
|
|
||||||
new_tag = self.find_image(name, tag)
|
new_tag = self.find_image(name, tag)
|
||||||
|
|
||||||
|
|||||||
@ -336,7 +336,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
params['filters'] = convert_filters({'reference': name})
|
params['filters'] = convert_filters({'reference': name})
|
||||||
images = self.get_json("/images/json", params=params)
|
images = self.get_json("/images/json", params=params)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error searching for image {name} - {exc!s}")
|
self.fail(f"Error searching for image {name} - {exc}")
|
||||||
if tag:
|
if tag:
|
||||||
lookup = f"{name}:{tag}"
|
lookup = f"{name}:{tag}"
|
||||||
lookup_digest = f"{name}@{tag}"
|
lookup_digest = f"{name}@{tag}"
|
||||||
@ -396,7 +396,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
self.log(f"Image {name}:{tag} not found.")
|
self.log(f"Image {name}:{tag} not found.")
|
||||||
return None
|
return None
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error inspecting image {name}:{tag} - {exc!s}")
|
self.fail(f"Error inspecting image {name}:{tag} - {exc}")
|
||||||
|
|
||||||
self.log(f"Image {name}:{tag} not found.")
|
self.log(f"Image {name}:{tag} not found.")
|
||||||
return None
|
return None
|
||||||
@ -413,11 +413,11 @@ class AnsibleDockerClientBase(Client):
|
|||||||
return self.get_json('/images/{0}/json', image_id)
|
return self.get_json('/images/{0}/json', image_id)
|
||||||
except NotFound as exc:
|
except NotFound as exc:
|
||||||
if not accept_missing_image:
|
if not accept_missing_image:
|
||||||
self.fail(f"Error inspecting image ID {image_id} - {exc!s}")
|
self.fail(f"Error inspecting image ID {image_id} - {exc}")
|
||||||
self.log(f"Image {image_id} not found.")
|
self.log(f"Image {image_id} not found.")
|
||||||
return None
|
return None
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error inspecting image ID {image_id} - {exc!s}")
|
self.fail(f"Error inspecting image ID {image_id} - {exc}")
|
||||||
|
|
||||||
def pull_image(self, name, tag="latest", platform=None):
|
def pull_image(self, name, tag="latest", platform=None):
|
||||||
'''
|
'''
|
||||||
@ -454,7 +454,7 @@ class AnsibleDockerClientBase(Client):
|
|||||||
else:
|
else:
|
||||||
self.fail(f"Error pulling {name} - {line.get('error')}")
|
self.fail(f"Error pulling {name} - {line.get('error')}")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.fail(f"Error pulling image {name}:{tag} - {exc!s}")
|
self.fail(f"Error pulling image {name}:{tag} - {exc}")
|
||||||
|
|
||||||
new_tag = self.find_image(name, tag)
|
new_tag = self.find_image(name, tag)
|
||||||
|
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class ImageManager(DockerBaseClass):
|
|||||||
self.client = client
|
self.client = client
|
||||||
self.results = results
|
self.results = results
|
||||||
self.name = self.client.module.params.get('name')
|
self.name = self.client.module.params.get('name')
|
||||||
self.log(f"Gathering facts for images: {self.name!s}")
|
self.log(f"Gathering facts for images: {self.name}")
|
||||||
|
|
||||||
if self.name:
|
if self.name:
|
||||||
self.results['images'] = self.get_facts()
|
self.results['images'] = self.get_facts()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user