浏览代码

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

Signed-off-by: Svyatoslav Ilinskiy <[email protected]>
Svyatoslav Ilinskiy 7 年之前
父节点
当前提交
a1f0c3ed7c
共有 3 个文件被更改,包括 9 次插入9 次删除
  1. 5 5
      compose/cli/main.py
  2. 2 2
      contrib/completion/bash/docker-compose
  3. 2 2
      tests/acceptance/cli_test.py

+ 5 - 5
compose/cli/main.py

@@ -1349,13 +1349,13 @@ def filter_services(filt, services, project):
                 containers = project.containers([service.name], stopped=True)
                 containers = project.containers([service.name], stopped=True)
                 if not has_container_with_state(containers, state):
                 if not has_container_with_state(containers, state):
                     return False
                     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
                         return False
                 else:
                 else:
-                    raise UserError("Invalid value for key filter: %s" % key)
+                    raise UserError("Invalid value for source filter: %s" % source)
             else:
             else:
                 raise UserError("Invalid filter: %s" % f)
                 raise UserError("Invalid filter: %s" % f)
         return True
         return True

+ 2 - 2
contrib/completion/bash/docker-compose

@@ -66,12 +66,12 @@ __docker_compose_services_all() {
 
 
 # All services that are defined by a Dockerfile reference
 # All services that are defined by a Dockerfile reference
 __docker_compose_services_from_build() {
 __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
 # All services that are defined by an image
 __docker_compose_services_from_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
 # The services for which at least one paused container exists

+ 2 - 2
tests/acceptance/cli_test.py

@@ -469,8 +469,8 @@ class CLITestCase(DockerClientTestCase):
 
 
     def test_ps_services_filter_option(self):
     def test_ps_services_filter_option(self):
         self.base_dir = 'tests/fixtures/ps-services-filter'
         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'])
         all_services = self.dispatch(['ps', '--services'])
 
 
         assert 'with_build' in all_services.stdout
         assert 'with_build' in all_services.stdout