From 69c0683bfe8f4bbb90d07f0db6516e51942f97d6 Mon Sep 17 00:00:00 2001 From: Klaas Hoekema Date: Fri, 12 Jul 2019 12:59:31 -0400 Subject: [PATCH] Pass toplevel_environment to run_one_off_container Instead of passing `project_dir` from `TopLevelCommand.run` to `run_one_off_container` then using it there to load the toplevel environment (duplicating the logic that `TopLevelCommand.toplevel_environment` encapsulates), pass the Environment object. Signed-off-by: Klaas Hoekema --- compose/cli/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index eb6e7d820..477b57b52 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -887,7 +887,7 @@ class TopLevelCommand(object): container_options = build_one_off_container_options(options, detach, command) run_one_off_container( container_options, self.project, service, options, - self.toplevel_options, self.project_dir + self.toplevel_options, self.toplevel_environment ) def scale(self, options): @@ -1325,7 +1325,7 @@ def build_one_off_container_options(options, detach, command): def run_one_off_container(container_options, project, service, options, toplevel_options, - project_dir='.'): + toplevel_environment): if not options['--no-deps']: deps = service.get_dependency_names() if deps: @@ -1354,8 +1354,6 @@ def run_one_off_container(container_options, project, service, options, toplevel if options['--rm']: project.client.remove_container(container.id, force=True, v=True) - environment_file = toplevel_options.get('--env-file') - toplevel_environment = Environment.from_env_file(project_dir, environment_file) use_cli = not toplevel_environment.get_boolean('COMPOSE_INTERACTIVE_NO_CLI') signals.set_signal_handler_to_shutdown()