Rename `ps --filter` option from `key` to `source`.

Signed-off-by: Svyatoslav Ilinskiy <ilinskiy.sv@gmail.com>
This commit is contained in:
Svyatoslav Ilinskiy 2018-01-09 10:57:06 -06:00
parent 253bed497d
commit a1f0c3ed7c
3 changed files with 9 additions and 9 deletions

View File

@ -1349,13 +1349,13 @@ def filter_services(filt, services, project):
containers = project.containers([service.name], stopped=True)
if not has_container_with_state(containers, state):
return False
elif f == 'key':
key = filt[f]
if key == 'image' or key == 'build':
if key not in service.options:
elif f == 'source':
source = filt[f]
if source == 'image' or source == 'build':
if source not in service.options:
return False
else:
raise UserError("Invalid value for key filter: %s" % key)
raise UserError("Invalid value for source filter: %s" % source)
else:
raise UserError("Invalid filter: %s" % f)
return True

View File

@ -66,12 +66,12 @@ __docker_compose_services_all() {
# All services that are defined by a Dockerfile reference
__docker_compose_services_from_build() {
COMPREPLY=( $(compgen -W "$(__docker_compose_q ps --services --filter "key=build")" -- "$cur") )
COMPREPLY=( $(compgen -W "$(__docker_compose_q ps --services --filter "source=build")" -- "$cur") )
}
# All services that are defined by an image
__docker_compose_services_from_image() {
COMPREPLY=( $(compgen -W "$(__docker_compose_q ps --services --filter "key=image")" -- "$cur") )
COMPREPLY=( $(compgen -W "$(__docker_compose_q ps --services --filter "source=image")" -- "$cur") )
}
# The services for which at least one paused container exists

View File

@ -469,8 +469,8 @@ class CLITestCase(DockerClientTestCase):
def test_ps_services_filter_option(self):
self.base_dir = 'tests/fixtures/ps-services-filter'
image = self.dispatch(['ps', '--services', '--filter', 'key=image'])
build = self.dispatch(['ps', '--services', '--filter', 'key=build'])
image = self.dispatch(['ps', '--services', '--filter', 'source=image'])
build = self.dispatch(['ps', '--services', '--filter', 'source=build'])
all_services = self.dispatch(['ps', '--services'])
assert 'with_build' in all_services.stdout