mirror of
https://github.com/docker/compose.git
synced 2025-07-02 03:14:26 +02:00
Rewrite images command method to decrease complexity
Also ensure we properly detect matching image names when tag is omitted Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
1b668973a2
commit
7d0fb7d3f3
@ -568,7 +568,13 @@ class TopLevelCommand(object):
|
|||||||
if options['--quiet']:
|
if options['--quiet']:
|
||||||
for image in set(c.image for c in containers):
|
for image in set(c.image for c in containers):
|
||||||
print(image.split(':')[1])
|
print(image.split(':')[1])
|
||||||
else:
|
return
|
||||||
|
|
||||||
|
def add_default_tag(img_name):
|
||||||
|
if ':' not in img_name.split('/')[-1]:
|
||||||
|
return '{}:latest'.format(img_name)
|
||||||
|
return img_name
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
'Container',
|
'Container',
|
||||||
'Repository',
|
'Repository',
|
||||||
@ -580,17 +586,15 @@ class TopLevelCommand(object):
|
|||||||
for container in containers:
|
for container in containers:
|
||||||
image_config = container.image_config
|
image_config = container.image_config
|
||||||
service = self.project.get_service(container.service)
|
service = self.project.get_service(container.service)
|
||||||
if service.image_name in image_config['RepoTags']:
|
index = 0
|
||||||
index = image_config['RepoTags'].index(service.image_name)
|
img_name = add_default_tag(service.image_name)
|
||||||
|
if img_name in image_config['RepoTags']:
|
||||||
|
index = image_config['RepoTags'].index(img_name)
|
||||||
repo_tags = (
|
repo_tags = (
|
||||||
image_config['RepoTags'][index].rsplit(':', 1) if image_config['RepoTags']
|
image_config['RepoTags'][index].rsplit(':', 1) if image_config['RepoTags']
|
||||||
else ('<none>', '<none>')
|
else ('<none>', '<none>')
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
repo_tags = (
|
|
||||||
image_config['RepoTags'][0].rsplit(':', 1) if image_config['RepoTags']
|
|
||||||
else ('<none>', '<none>')
|
|
||||||
)
|
|
||||||
image_id = image_config['Id'].split(':')[1][:12]
|
image_id = image_config['Id'].split(':')[1][:12]
|
||||||
size = human_readable_file_size(image_config['Size'])
|
size = human_readable_file_size(image_config['Size'])
|
||||||
rows.append([
|
rows.append([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user