mirror of https://github.com/docker/compose.git
Add --hash opt for config command
Signed-off-by: Fender William <fender.william@gmail.com>
This commit is contained in:
parent
473703d0d9
commit
541fb65259
|
@ -13,3 +13,4 @@ compose/GITSHA
|
|||
*.swp
|
||||
.DS_Store
|
||||
.cache
|
||||
.idea
|
||||
|
|
|
@ -328,7 +328,8 @@ class TopLevelCommand(object):
|
|||
anything.
|
||||
--services Print the service names, one per line.
|
||||
--volumes Print the volume names, one per line.
|
||||
|
||||
--hash="all" Print the service config hash, one per line.
|
||||
Set "service1,service2" for a list of specified services.
|
||||
"""
|
||||
|
||||
compose_config = get_config_from_options(self.project_dir, self.toplevel_options)
|
||||
|
@ -350,6 +351,20 @@ class TopLevelCommand(object):
|
|||
print('\n'.join(volume for volume in compose_config.volumes))
|
||||
return
|
||||
|
||||
if options['--hash'] is not None:
|
||||
self.project = project_from_options('.', self.toplevel_options)
|
||||
if options['--hash'] == "all":
|
||||
for service in self.project.services:
|
||||
print('{} {}'.format(service.name, service.config_hash))
|
||||
else:
|
||||
for service_name in options['--hash'].split(','):
|
||||
try:
|
||||
print('{} {}'.format(service_name,
|
||||
self.project.get_service(service_name).config_hash))
|
||||
except NoSuchService as s:
|
||||
print('{}'.format(s))
|
||||
return
|
||||
|
||||
print(serialize_config(compose_config, image_digests))
|
||||
|
||||
def create(self, options):
|
||||
|
|
|
@ -136,7 +136,7 @@ _docker_compose_bundle() {
|
|||
|
||||
|
||||
_docker_compose_config() {
|
||||
COMPREPLY=( $( compgen -W "--help --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "--help --quiet -q --resolve-image-digests --services --volumes --hash" -- "$cur" ) )
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,7 +213,8 @@ __docker-compose_subcommand() {
|
|||
'(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
|
||||
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||
'--services[Print the service names, one per line.]' \
|
||||
'--volumes[Print the volume names, one per line.]' && ret=0
|
||||
'--volumes[Print the volume names, one per line.]' \
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
||||
;;
|
||||
(create)
|
||||
_arguments \
|
||||
|
|
Loading…
Reference in New Issue