Use enum to represent 3 possible states of the one_off filter
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
187ea4cd81
commit
5826a2147b
5 changed files with 53 additions and 34 deletions
|
|
@ -22,6 +22,7 @@ from ..const import DEFAULT_TIMEOUT
|
|||
from ..const import IS_WINDOWS_PLATFORM
|
||||
from ..progress_stream import StreamOutputError
|
||||
from ..project import NoSuchService
|
||||
from ..project import OneOffFilter
|
||||
from ..service import BuildAction
|
||||
from ..service import BuildError
|
||||
from ..service import ConvergenceStrategy
|
||||
|
|
@ -437,7 +438,7 @@ class TopLevelCommand(object):
|
|||
"""
|
||||
containers = sorted(
|
||||
self.project.containers(service_names=options['SERVICE'], stopped=True) +
|
||||
self.project.containers(service_names=options['SERVICE'], one_off=True),
|
||||
self.project.containers(service_names=options['SERVICE'], one_off=OneOffFilter.only),
|
||||
key=attrgetter('name'))
|
||||
|
||||
if options['-q']:
|
||||
|
|
@ -491,11 +492,13 @@ class TopLevelCommand(object):
|
|||
Options:
|
||||
-f, --force Don't ask to confirm removal
|
||||
-v Remove volumes associated with containers
|
||||
-a, --all Also remove one-off containers
|
||||
-a, --all Also remove one-off containers created by
|
||||
docker-compose run
|
||||
"""
|
||||
one_off = OneOffFilter.include if options.get('--all') else OneOffFilter.exclude
|
||||
|
||||
all_containers = self.project.containers(
|
||||
service_names=options['SERVICE'], stopped=True,
|
||||
one_off=(None if options.get('--all') else False)
|
||||
service_names=options['SERVICE'], stopped=True, one_off=one_off
|
||||
)
|
||||
stopped_containers = [c for c in all_containers if not c.is_running]
|
||||
|
||||
|
|
@ -506,7 +509,7 @@ class TopLevelCommand(object):
|
|||
self.project.remove_stopped(
|
||||
service_names=options['SERVICE'],
|
||||
v=options.get('-v', False),
|
||||
one_off=options.get('--all')
|
||||
one_off=one_off
|
||||
)
|
||||
else:
|
||||
print("No stopped containers")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue