From b66fe878e423fb571bc5cf8d942400d4dca6bd6b Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Wed, 28 May 2025 14:05:13 +0300 Subject: [PATCH 1/5] Add stack CLI option --- localstack-core/localstack/cli/localstack.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/localstack-core/localstack/cli/localstack.py b/localstack-core/localstack/cli/localstack.py index 9abbf4e53775a..55adf6cfba743 100644 --- a/localstack-core/localstack/cli/localstack.py +++ b/localstack-core/localstack/cli/localstack.py @@ -472,6 +472,13 @@ def _print_service_table(services: Dict[str, str]) -> None: is_flag=True, default=False, ) +@click.option( + "--stack", + "-s", + type=str, + help="Use a specific LocalStack stack", + required=False, +) @publish_invocation def cmd_start( docker: bool, @@ -483,6 +490,7 @@ def cmd_start( publish: Tuple = (), volume: Tuple = (), host_dns: bool = False, + stack: str = None, ) -> None: """ Start the LocalStack runtime. @@ -496,6 +504,9 @@ def cmd_start( if host and detached: raise CLIError("Cannot start detached in host mode") + if stack: + os.environ["IMAGE_NAME"] = f"localstack/{stack}:latest" + if not no_banner: print_banner() print_version() From 22fe21874e7d61f31d8597a24497822a05677ad8 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Wed, 28 May 2025 14:33:12 +0300 Subject: [PATCH 2/5] Add click choice for stack options --- localstack-core/localstack/cli/localstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localstack-core/localstack/cli/localstack.py b/localstack-core/localstack/cli/localstack.py index 55adf6cfba743..0595bba484295 100644 --- a/localstack-core/localstack/cli/localstack.py +++ b/localstack-core/localstack/cli/localstack.py @@ -475,7 +475,7 @@ def _print_service_table(services: Dict[str, str]) -> None: @click.option( "--stack", "-s", - type=str, + type=click.Choice(["snowflake"], case_sensitive=False), help="Use a specific LocalStack stack", required=False, ) From 9bd1816f844d6c2206be4e62c8a7c9a6e7ed49ce Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Wed, 28 May 2025 16:08:13 +0300 Subject: [PATCH 3/5] Allow adding image version in stack option --- localstack-core/localstack/cli/localstack.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/localstack-core/localstack/cli/localstack.py b/localstack-core/localstack/cli/localstack.py index 0595bba484295..9d54b6c3e10b0 100644 --- a/localstack-core/localstack/cli/localstack.py +++ b/localstack-core/localstack/cli/localstack.py @@ -475,8 +475,8 @@ def _print_service_table(services: Dict[str, str]) -> None: @click.option( "--stack", "-s", - type=click.Choice(["snowflake"], case_sensitive=False), - help="Use a specific LocalStack stack", + type=str, + help="Use a specific LocalStack stack with optional version.", required=False, ) @publish_invocation @@ -505,7 +505,17 @@ def cmd_start( raise CLIError("Cannot start detached in host mode") if stack: - os.environ["IMAGE_NAME"] = f"localstack/{stack}:latest" + # Validate allowed stacks + stack_name = stack.split(":")[0] + if stack_name.lower() not in ["localstack", "snowflake"]: + raise CLIError( + f"Invalid stack '{stack_name}'. Only 'localstack' and 'snowflake' are supported." + ) + + # Set IMAGE_NAME, defaulting to :latest if no version specified + if ":" not in stack: + stack = f"{stack}:latest" + os.environ["IMAGE_NAME"] = f"localstack/{stack}" if not no_banner: print_banner() From 186d3498456b853e914b5e23181104ba41b9d079 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Fri, 30 May 2025 14:23:40 +0300 Subject: [PATCH 4/5] Inlcude localstack-pro as option Co-authored-by: Silvio Vasiljevic --- localstack-core/localstack/cli/localstack.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/localstack-core/localstack/cli/localstack.py b/localstack-core/localstack/cli/localstack.py index 9d54b6c3e10b0..ce2036ca39121 100644 --- a/localstack-core/localstack/cli/localstack.py +++ b/localstack-core/localstack/cli/localstack.py @@ -507,10 +507,9 @@ def cmd_start( if stack: # Validate allowed stacks stack_name = stack.split(":")[0] - if stack_name.lower() not in ["localstack", "snowflake"]: - raise CLIError( - f"Invalid stack '{stack_name}'. Only 'localstack' and 'snowflake' are supported." - ) + allowed_stacks = ("localstack", "localstack-pro", "snowflake") + if stack_name.lower() not in allowed_stacks: + raise CLIError(f"Invalid stack '{stack_name}'. Allowed stacks: {allowed_stacks}.") # Set IMAGE_NAME, defaulting to :latest if no version specified if ":" not in stack: From dd2c462bc510f9550598722b1b1b31922bce852d Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Fri, 30 May 2025 14:28:48 +0300 Subject: [PATCH 5/5] Update help text with examples --- localstack-core/localstack/cli/localstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localstack-core/localstack/cli/localstack.py b/localstack-core/localstack/cli/localstack.py index ce2036ca39121..016834b3e21b3 100644 --- a/localstack-core/localstack/cli/localstack.py +++ b/localstack-core/localstack/cli/localstack.py @@ -476,7 +476,7 @@ def _print_service_table(services: Dict[str, str]) -> None: "--stack", "-s", type=str, - help="Use a specific LocalStack stack with optional version.", + help="Use a specific stack with optional version. Examples: [localstack:4.5, snowflake]", required=False, ) @publish_invocation