From e04f0d44ee2b97705393cb58952e9f3e257a4a70 Mon Sep 17 00:00:00 2001 From: Jon Chen Date: Wed, 25 Oct 2023 23:17:58 +0900 Subject: [PATCH] updated project_id var in sb delete --- solutions_builder/cli/cli.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/solutions_builder/cli/cli.py b/solutions_builder/cli/cli.py index 9e37c5fd..ea96a382 100644 --- a/solutions_builder/cli/cli.py +++ b/solutions_builder/cli/cli.py @@ -198,7 +198,8 @@ def deploy( # Destory deployment. @app.command() def delete(profile: str = DEFAULT_DEPLOY_PROFILE, - component: str = None, + component: Annotated[str, typer.Option("--component", "-c", "-m")] = None, + namespace: Annotated[str, typer.Option("--namespace", "-n")] = None, solution_path: Annotated[Optional[str], typer.Argument()] = ".", yes: Optional[bool] = False): @@ -208,14 +209,21 @@ def delete(profile: str = DEFAULT_DEPLOY_PROFILE, validate_solution_folder(solution_path) sb_yaml = read_yaml(f"{solution_path}/sb.yaml") - project_id = sb_yaml["project_id"] + global_variables = sb_yaml.get("global_variables", {}) + + # Get project_id from sb.yaml. + project_id = global_variables.get("project_id", None) + assert project_id, "project_id is not set in 'global_variables' in sb.yaml." if component: component_flag = f" -m {component} " else: component_flag = "" - command = f"skaffold delete -p {profile} {component_flag} --default-repo=\"gcr.io/{project_id}\"" + # Set Skaffold namespace + namespace_flag = f"-n {namespace}" if namespace else "" + + command = f"skaffold delete -p {profile} {component_flag} {namespace_flag} --default-repo=\"gcr.io/{project_id}\"" print("This will DELETE deployed services using the command below:") print_highlight(command) confirm("\nThis may take a few minutes. Continue?", default=False, skip=yes)