From 8f4d56a6489ef0fa685e6b57e2b3eb286cd9050f Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 31 Oct 2018 14:24:35 -0700 Subject: [PATCH] Impose consistent behavior across command for --project-directory flag Signed-off-by: Joffrey F --- compose/cli/command.py | 10 ++++++---- compose/cli/main.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compose/cli/command.py b/compose/cli/command.py index 8a32a93a2..339a65c53 100644 --- a/compose/cli/command.py +++ b/compose/cli/command.py @@ -23,7 +23,8 @@ log = logging.getLogger(__name__) def project_from_options(project_dir, options): - environment = Environment.from_env_file(project_dir) + override_dir = options.get('--project-directory') + environment = Environment.from_env_file(override_dir or project_dir) set_parallel_limit(environment) host = options.get('--host') @@ -37,7 +38,7 @@ def project_from_options(project_dir, options): host=host, tls_config=tls_config_from_options(options, environment), environment=environment, - override_dir=options.get('--project-directory'), + override_dir=override_dir, compatibility=options.get('--compatibility'), ) @@ -59,12 +60,13 @@ def set_parallel_limit(environment): def get_config_from_options(base_dir, options): - environment = Environment.from_env_file(base_dir) + override_dir = options.get('--project-directory') + environment = Environment.from_env_file(override_dir or base_dir) config_path = get_config_path_from_options( base_dir, options, environment ) return config.load( - config.find(base_dir, config_path, environment), + config.find(base_dir, config_path, environment, override_dir), options.get('--compatibility') ) diff --git a/compose/cli/main.py b/compose/cli/main.py index 46b547b00..afe813ee5 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -306,7 +306,7 @@ class TopLevelCommand(object): -o, --output PATH Path to write the bundle file to. Defaults to ".dab". """ - compose_config = get_config_from_options(self.project_dir, self.toplevel_options) + compose_config = get_config_from_options('.', self.toplevel_options) output = options["--output"] if not output: @@ -336,7 +336,7 @@ class TopLevelCommand(object): or use the wildcard symbol to display all services """ - compose_config = get_config_from_options(self.project_dir, self.toplevel_options) + compose_config = get_config_from_options('.', self.toplevel_options) image_digests = None if options['--resolve-image-digests']: