From 09479e605c2903a06b096ecfb88c59e06d58840c Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 8 Aug 2024 22:25:25 -0500 Subject: [PATCH] Copy config under a volume for Docker too (similar to a configmap). --- stack_orchestrator/deploy/deployment_create.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stack_orchestrator/deploy/deployment_create.py b/stack_orchestrator/deploy/deployment_create.py index 1534dcbb..9d45f226 100644 --- a/stack_orchestrator/deploy/deployment_create.py +++ b/stack_orchestrator/deploy/deployment_create.py @@ -520,6 +520,16 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw if os.path.exists(source_config_dir): destination_config_dir = deployment_dir_path.joinpath("configmaps", configmap) copytree(source_config_dir, destination_config_dir, dirs_exist_ok=True) + else: + # TODO: We should probably only do this if the volume is marked :ro. + for volume_name, volume_path in parsed_spec.get_volumes().items(): + source_config_dir = resolve_config_dir(stack_name, volume_name) + # Only copy if the source exists and is _not_ empty. + if os.path.exists(source_config_dir) and os.listdir(source_config_dir): + destination_config_dir = deployment_dir_path.joinpath(volume_path) + # Only copy if the destination exists and _is_ empty. + if os.path.exists(destination_config_dir) and not os.listdir(destination_config_dir): + copytree(source_config_dir, destination_config_dir, dirs_exist_ok=True) # Delegate to the stack's Python code # The deploy create command doesn't require a --stack argument so we need to insert the -- 2.45.2