Skip to content

Commit

Permalink
Fix config dir processing for external stacks (#810)
Browse files Browse the repository at this point in the history
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/810
Co-authored-by: David Boreham <[email protected]>
Co-committed-by: David Boreham <[email protected]>
  • Loading branch information
dboreham authored and David Boreham committed Apr 23, 2024
1 parent 6e4dae9 commit 13ce521
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions stack_orchestrator/deploy/deployment_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from stack_orchestrator.opts import opts
from stack_orchestrator.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config,
global_options, get_yaml, get_pod_list, get_pod_file_path, pod_has_scripts,
get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file)
get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file,
resolve_config_dir)
from stack_orchestrator.deploy.spec import Spec
from stack_orchestrator.deploy.deploy_types import LaconicStackSetupCommand
from stack_orchestrator.deploy.deployer_factory import getDeployerConfigGenerator
Expand Down Expand Up @@ -480,7 +481,6 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
os.mkdir(destination_compose_dir)
destination_pods_dir = deployment_dir_path.joinpath("pods")
os.mkdir(destination_pods_dir)
data_dir = Path(__file__).absolute().parent.parent.joinpath("data")
yaml = get_yaml()
for pod in pods:
pod_file_path = get_pod_file_path(stack_name, parsed_stack, pod)
Expand All @@ -497,7 +497,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
config_dirs = {pod}
config_dirs = config_dirs.union(extra_config_dirs)
for config_dir in config_dirs:
source_config_dir = data_dir.joinpath("config", config_dir)
source_config_dir = resolve_config_dir(stack_name, config_dir)
if os.path.exists(source_config_dir):
destination_config_dir = deployment_dir_path.joinpath("config", config_dir)
# If the same config dir appears in multiple pods, it may already have been copied
Expand Down
16 changes: 15 additions & 1 deletion stack_orchestrator/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ def get_plugin_code_paths(stack) -> List[Path]:
return list(result)


# # Find a config directory, looking first in any external stack
# and if not found there, internally
def resolve_config_dir(stack, config_dir_name: str):
if stack_is_external(stack):
# First try looking in the external stack for the compose file
config_base = Path(stack).parent.parent.joinpath("config")
proposed_dir = config_base.joinpath(config_dir_name)
if proposed_dir.exists():
return proposed_dir
# If we don't find it fall through to the internal case
config_base = get_internal_config_dir()
return config_base.joinpath(config_dir_name)


# Find a compose file, looking first in any external stack
# and if not found there, internally
def resolve_compose_file(stack, pod_name: str):
Expand Down Expand Up @@ -153,7 +167,7 @@ def get_internal_compose_file_dir():
return source_compose_dir


def get_config_file_dir():
def get_internal_config_dir():
# TODO: refactor to use common code with deploy command
data_dir = Path(__file__).absolute().parent.joinpath("data")
source_config_dir = data_dir.joinpath("config")
Expand Down

0 comments on commit 13ce521

Please sign in to comment.