mirror of https://github.com/docker/compose.git
Refactored mutable default values.
Signed-off-by: yukihira1992 <ykhr0130@gmail.com>
This commit is contained in:
parent
a2cdffeeee
commit
53d00f7677
|
@ -40,7 +40,8 @@ SILENT_COMMANDS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def project_from_options(project_dir, options, additional_options={}):
|
def project_from_options(project_dir, options, additional_options=None):
|
||||||
|
additional_options = additional_options or {}
|
||||||
override_dir = options.get('--project-directory')
|
override_dir = options.get('--project-directory')
|
||||||
environment_file = options.get('--env-file')
|
environment_file = options.get('--env-file')
|
||||||
environment = Environment.from_env_file(override_dir or project_dir, environment_file)
|
environment = Environment.from_env_file(override_dir or project_dir, environment_file)
|
||||||
|
@ -81,7 +82,8 @@ def set_parallel_limit(environment):
|
||||||
parallel.GlobalLimit.set_global_limit(parallel_limit)
|
parallel.GlobalLimit.set_global_limit(parallel_limit)
|
||||||
|
|
||||||
|
|
||||||
def get_config_from_options(base_dir, options, additional_options={}):
|
def get_config_from_options(base_dir, options, additional_options=None):
|
||||||
|
additional_options = additional_options or {}
|
||||||
override_dir = options.get('--project-directory')
|
override_dir = options.get('--project-directory')
|
||||||
environment_file = options.get('--env-file')
|
environment_file = options.get('--env-file')
|
||||||
environment = Environment.from_env_file(override_dir or base_dir, environment_file)
|
environment = Environment.from_env_file(override_dir or base_dir, environment_file)
|
||||||
|
|
|
@ -87,10 +87,11 @@ class Project(object):
|
||||||
return labels
|
return labels
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_config(cls, name, config_data, client, default_platform=None, extra_labels=[]):
|
def from_config(cls, name, config_data, client, default_platform=None, extra_labels=None):
|
||||||
"""
|
"""
|
||||||
Construct a Project from a config.Config object.
|
Construct a Project from a config.Config object.
|
||||||
"""
|
"""
|
||||||
|
extra_labels = extra_labels or []
|
||||||
use_networking = (config_data.version and config_data.version != V1)
|
use_networking = (config_data.version and config_data.version != V1)
|
||||||
networks = build_networks(name, config_data, client)
|
networks = build_networks(name, config_data, client)
|
||||||
project_networks = ProjectNetworks.from_services(
|
project_networks = ProjectNetworks.from_services(
|
||||||
|
|
|
@ -185,7 +185,7 @@ class Service(object):
|
||||||
scale=1,
|
scale=1,
|
||||||
pid_mode=None,
|
pid_mode=None,
|
||||||
default_platform=None,
|
default_platform=None,
|
||||||
extra_labels=[],
|
extra_labels=None,
|
||||||
**options
|
**options
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -201,7 +201,7 @@ class Service(object):
|
||||||
self.scale_num = scale
|
self.scale_num = scale
|
||||||
self.default_platform = default_platform
|
self.default_platform = default_platform
|
||||||
self.options = options
|
self.options = options
|
||||||
self.extra_labels = extra_labels
|
self.extra_labels = extra_labels or []
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Service: {}>'.format(self.name)
|
return '<Service: {}>'.format(self.name)
|
||||||
|
|
Loading…
Reference in New Issue