From 05c8765d6d1b2f2fec2fd06cee69647410ddf2b5 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Mon, 9 Sep 2024 17:35:34 +0800 Subject: [PATCH] Pass --cluster option to `deploy create` --- stack_orchestrator/deploy/deployment_create.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stack_orchestrator/deploy/deployment_create.py b/stack_orchestrator/deploy/deployment_create.py index 9d45f226..c389b5c2 100644 --- a/stack_orchestrator/deploy/deployment_create.py +++ b/stack_orchestrator/deploy/deployment_create.py @@ -422,9 +422,10 @@ def _copy_files_to_directory(file_paths: List[Path], directory: Path): copy(path, os.path.join(directory, os.path.basename(path))) -def _create_deployment_file(deployment_dir: Path): +def _create_deployment_file(deployment_dir: Path, cluster): deployment_file_path = deployment_dir.joinpath(constants.deployment_file_name) - cluster = f"{constants.cluster_name_prefix}{token_hex(8)}" + if cluster is None: + cluster = f"{constants.cluster_name_prefix}{token_hex(8)}" with open(deployment_file_path, "w") as output_file: output_file.write(f"{constants.cluster_id_key}: {cluster}\n") @@ -473,7 +474,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw # Copy spec file and the stack file into the deployment dir copyfile(spec_file, deployment_dir_path.joinpath(constants.spec_file_name)) copyfile(stack_file, deployment_dir_path.joinpath(constants.stack_file_name)) - _create_deployment_file(deployment_dir_path) + _create_deployment_file(deployment_dir_path, deployment_command_context.cluster_context.cluster) # Copy any config varibles from the spec file into an env file suitable for compose _write_config_file(spec_file, deployment_dir_path.joinpath(constants.config_file_name)) # Copy any k8s config file into the deployment dir -- 2.45.2