From 1ae57d92d4081380759fc4f816975d1a3a4d459c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Thu, 14 Jan 2016 13:12:39 -0800 Subject: [PATCH] Remove duplicate functions Signed-off-by: Joffrey F --- compose/config/config.py | 44 +++++++++------------------------------- docs/compose-file.md | 12 ----------- 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/compose/config/config.py b/compose/config/config.py index 86f0aa3be..58b73dbe2 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -457,8 +457,7 @@ def resolve_environment(service_dict): def resolve_build_args(build): - args = {} - args.update(parse_build_arguments(build.get('args'))) + args = parse_build_arguments(build.get('args')) return dict(resolve_env_var(k, v) for k, v in six.iteritems(args)) @@ -699,6 +698,14 @@ parse_environment = functools.partial(parse_dict_or_list, split_env, 'environmen parse_labels = functools.partial(parse_dict_or_list, split_label, 'labels') +def parse_ulimits(ulimits): + if not ulimits: + return {} + + if isinstance(ulimits, dict): + return dict(ulimits) + + def resolve_env_var(key, val): if val is not None: return key, val @@ -743,13 +750,9 @@ def resolve_volume_path(working_dir, volume): def normalize_build(service_dict, working_dir): - build = {} - - # supported in V1 only - if 'dockerfile' in service_dict: - build['dockerfile'] = service_dict.pop('dockerfile') if 'build' in service_dict: + build = {} # Shortcut where specifying a string is treated as the build context if isinstance(service_dict['build'], six.string_types): build['context'] = service_dict.pop('build') @@ -758,7 +761,6 @@ def normalize_build(service_dict, working_dir): if 'args' in build: build['args'] = resolve_build_args(build) - if build: service_dict['build'] = build @@ -835,32 +837,6 @@ def join_path_mapping(pair): return ":".join((host, container)) -def parse_labels(labels): - if not labels: - return {} - - if isinstance(labels, list): - return dict(split_label(e) for e in labels) - - if isinstance(labels, dict): - return dict(labels) - - -def split_label(label): - if '=' in label: - return label.split('=', 1) - else: - return label, '' - - -def parse_ulimits(ulimits): - if not ulimits: - return {} - - if isinstance(ulimits, dict): - return dict(ulimits) - - def expand_path(working_dir, path): return os.path.abspath(os.path.join(working_dir, os.path.expanduser(path))) diff --git a/docs/compose-file.md b/docs/compose-file.md index a9e540148..ecd135f19 100644 --- a/docs/compose-file.md +++ b/docs/compose-file.md @@ -228,18 +228,6 @@ Custom DNS search domains. Can be a single value or a list. - dc1.example.com - dc2.example.com -### dockerfile - -Alternate Dockerfile. - -Compose will use an alternate file to build with. A build path must also be -specified using the `build` key. - - build: /path/to/build/dir - dockerfile: Dockerfile-alternate - -Using `dockerfile` together with `image` is not allowed. Attempting to do so results in an error. - ### entrypoint Override the default entrypoint.