Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add stack option for CLI start command #12675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions localstack-core/localstack/cli/localstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,13 @@ def _print_service_table(services: Dict[str, str]) -> None:
is_flag=True,
default=False,
)
@click.option(
"--stack",
"-s",
type=str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use click.Choice here to enforce only snowflake can be used here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice one! Today I learned. Added in 714e323.

Copy link
Member Author

@gtsiolis gtsiolis May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the choice in 931f2af to make it more flexible to add versions next to the image.

localstack start -s snowflake
localstack start -s snowflake:0.3

Happy to go back to restricting this only to image name as a first iteration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could subtype click.Choice as well and that logic in there instead of the start command. But no need to optimize without knowing what we'll do with the CLI in the future yet :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For passing specific versions next to the image, we can also introduce another cli option that would look like:

localstack start -s snowflake -v 0.3.0

This was also mentioned in #12529 briefly to get ideas around it. Wdyt?

Copy link
Member Author

@gtsiolis gtsiolis May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eruditmorina! I would still keep the {image}:{version} approach for simplicity, having a Docker-familiar syntax, not creating any confusion on what version (-v) is referring to (CLI, stack, or start command). Let me know if I'm missing something!

{image}:{version} {image} -v {version}
Frame 48097105 Frame 48097106

help="Use a specific stack with optional version. Examples: [localstack:4.5, snowflake]",
required=False,
)
@publish_invocation
def cmd_start(
docker: bool,
Expand All @@ -483,6 +490,7 @@ def cmd_start(
publish: Tuple = (),
volume: Tuple = (),
host_dns: bool = False,
stack: str = None,
) -> None:
"""
Start the LocalStack runtime.
Expand All @@ -496,6 +504,18 @@ def cmd_start(
if host and detached:
raise CLIError("Cannot start detached in host mode")

if stack:
# Validate allowed stacks
stack_name = stack.split(":")[0]
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:
stack = f"{stack}:latest"
os.environ["IMAGE_NAME"] = f"localstack/{stack}"

if not no_banner:
print_banner()
print_version()
Expand Down
Loading