Merge pull request #1521 from dano/validate-service-names
Validate that service names passed to Project.containers aren't bogus.
This commit is contained in:
commit
bc14c473c9
2 changed files with 17 additions and 0 deletions
|
|
@ -99,6 +99,16 @@ class Project(object):
|
|||
|
||||
raise NoSuchService(name)
|
||||
|
||||
def validate_service_names(self, service_names):
|
||||
"""
|
||||
Validate that the given list of service names only contains valid
|
||||
services. Raises NoSuchService if one of the names is invalid.
|
||||
"""
|
||||
valid_names = self.service_names
|
||||
for name in service_names:
|
||||
if name not in valid_names:
|
||||
raise NoSuchService(name)
|
||||
|
||||
def get_services(self, service_names=None, include_deps=False):
|
||||
"""
|
||||
Returns a list of this project's services filtered
|
||||
|
|
@ -276,6 +286,8 @@ class Project(object):
|
|||
service.remove_stopped(**options)
|
||||
|
||||
def containers(self, service_names=None, stopped=False, one_off=False):
|
||||
if service_names:
|
||||
self.validate_service_names(service_names)
|
||||
containers = [
|
||||
Container.from_ps(self.client, container)
|
||||
for container in self.client.containers(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue