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']
|
h = options['--hash']
|
||||||
self.project = project_from_options('.', self.toplevel_options)
|
self.project = project_from_options('.', self.toplevel_options)
|
||||||
services = [svc for svc in options['--hash'].split(',')] if h != '*' else None
|
services = [svc for svc in options['--hash'].split(',')] if h != '*' else None
|
||||||
|
with errors.handle_connection_errors(self.project.client):
|
||||||
for service in self.project.get_services(services):
|
for service in self.project.get_services(services):
|
||||||
print('{} {}'.format(service.name, service.config_hash))
|
print('{} {}'.format(service.name, service.config_hash))
|
||||||
return
|
return
|
||||||
|
|
||||||
print(serialize_config(compose_config, image_digests))
|
print(serialize_config(compose_config, image_digests))
|
||||||
|
|
|
@ -656,9 +656,15 @@ class Service(object):
|
||||||
return json_hash(self.config_dict())
|
return json_hash(self.config_dict())
|
||||||
|
|
||||||
def config_dict(self):
|
def config_dict(self):
|
||||||
|
def image_id():
|
||||||
|
try:
|
||||||
|
return self.image()['Id']
|
||||||
|
except NoSuchImageError:
|
||||||
|
return None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'options': self.options,
|
'options': self.options,
|
||||||
'image_id': self.image()['Id'],
|
'image_id': image_id(),
|
||||||
'links': self.get_link_names(),
|
'links': self.get_link_names(),
|
||||||
'net': self.network_mode.id,
|
'net': self.network_mode.id,
|
||||||
'networks': self.networks,
|
'networks': self.networks,
|
||||||
|
|
|
@ -224,7 +224,6 @@ class CLITestCase(DockerClientTestCase):
|
||||||
|
|
||||||
def test_config_with_hash_option(self):
|
def test_config_with_hash_option(self):
|
||||||
self.base_dir = 'tests/fixtures/v2-full'
|
self.base_dir = 'tests/fixtures/v2-full'
|
||||||
self.project.build()
|
|
||||||
result = self.dispatch(['config', '--hash=*'])
|
result = self.dispatch(['config', '--hash=*'])
|
||||||
for service in self.project.get_services():
|
for service in self.project.get_services():
|
||||||
assert '{} {}\n'.format(service.name, service.config_hash) in result.stdout
|
assert '{} {}\n'.format(service.name, service.config_hash) in result.stdout
|
||||||
|
|
Loading…
Reference in New Issue