mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix error when container has no names.
Rename loop variable from "i" to more informative "container" Fixes #1188
This commit is contained in:
parent
dd6b153700
commit
c2bf2c7c54
1 changed files with 7 additions and 4 deletions
|
@ -1131,17 +1131,20 @@ class DockerManager(object):
|
||||||
else:
|
else:
|
||||||
repo_tags = [normalize_image(self.module.params.get('image'))]
|
repo_tags = [normalize_image(self.module.params.get('image'))]
|
||||||
|
|
||||||
for i in self.client.containers(all=True):
|
for container in self.client.containers(all=True):
|
||||||
details = None
|
details = None
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
matches = name in i.get('Names', [])
|
name_list = container.get('Names')
|
||||||
|
if name_list is None:
|
||||||
|
name_list = []
|
||||||
|
matches = name in name_list
|
||||||
else:
|
else:
|
||||||
details = self.client.inspect_container(i['Id'])
|
details = self.client.inspect_container(i['Id'])
|
||||||
details = _docker_id_quirk(details)
|
details = _docker_id_quirk(details)
|
||||||
|
|
||||||
running_image = normalize_image(details['Config']['Image'])
|
running_image = normalize_image(details['Config']['Image'])
|
||||||
running_command = i['Command'].strip()
|
running_command = container['Command'].strip()
|
||||||
|
|
||||||
image_matches = running_image in repo_tags
|
image_matches = running_image in repo_tags
|
||||||
|
|
||||||
|
@ -1153,7 +1156,7 @@ class DockerManager(object):
|
||||||
|
|
||||||
if matches:
|
if matches:
|
||||||
if not details:
|
if not details:
|
||||||
details = self.client.inspect_container(i['Id'])
|
details = self.client.inspect_container(container['Id'])
|
||||||
details = _docker_id_quirk(details)
|
details = _docker_id_quirk(details)
|
||||||
|
|
||||||
deployed.append(details)
|
deployed.append(details)
|
||||||
|
|
Loading…
Reference in a new issue