mirror of https://github.com/docker/compose.git
Handle missing (not built) service image in config --hash
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
861031b9b7
commit
ee878aee4c
|
@ -356,9 +356,9 @@ class TopLevelCommand(object):
|
|||
h = options['--hash']
|
||||
self.project = project_from_options('.', self.toplevel_options)
|
||||
services = [svc for svc in options['--hash'].split(',')] if h != '*' else None
|
||||
|
||||
for service in self.project.get_services(services):
|
||||
print('{} {}'.format(service.name, service.config_hash))
|
||||
with errors.handle_connection_errors(self.project.client):
|
||||
for service in self.project.get_services(services):
|
||||
print('{} {}'.format(service.name, service.config_hash))
|
||||
return
|
||||
|
||||
print(serialize_config(compose_config, image_digests))
|
||||
|
|
|
@ -656,9 +656,15 @@ class Service(object):
|
|||
return json_hash(self.config_dict())
|
||||
|
||||
def config_dict(self):
|
||||
def image_id():
|
||||
try:
|
||||
return self.image()['Id']
|
||||
except NoSuchImageError:
|
||||
return None
|
||||
|
||||
return {
|
||||
'options': self.options,
|
||||
'image_id': self.image()['Id'],
|
||||
'image_id': image_id(),
|
||||
'links': self.get_link_names(),
|
||||
'net': self.network_mode.id,
|
||||
'networks': self.networks,
|
||||
|
|
|
@ -224,7 +224,6 @@ class CLITestCase(DockerClientTestCase):
|
|||
|
||||
def test_config_with_hash_option(self):
|
||||
self.base_dir = 'tests/fixtures/v2-full'
|
||||
self.project.build()
|
||||
result = self.dispatch(['config', '--hash=*'])
|
||||
for service in self.project.get_services():
|
||||
assert '{} {}\n'.format(service.name, service.config_hash) in result.stdout
|
||||
|
|
Loading…
Reference in New Issue