Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempts to select the stack before creating #11115

Merged
merged 2 commits into from Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: sdk/python
description: pulumi.automation.create_or_select_stack() attempts to select the stack before attempting to create
6 changes: 3 additions & 3 deletions sdk/python/lib/pulumi/automation/_stack.py
Expand Up @@ -25,7 +25,7 @@

from ._cmd import CommandResult, _run_pulumi_cmd, OnOutput
from ._config import ConfigValue, ConfigMap
from .errors import StackAlreadyExistsError
from .errors import StackAlreadyExistsError, StackNotFoundError
from .events import OpMap, EngineEvent, SummaryEvent
from ._output import OutputMap
from ._server import LanguageServer
Expand Down Expand Up @@ -186,9 +186,9 @@ def __init__(self, name: str, workspace: Workspace, mode: StackInitMode) -> None
workspace.select_stack(name)
elif mode is StackInitMode.CREATE_OR_SELECT:
try:
workspace.create_stack(name)
except StackAlreadyExistsError:
workspace.select_stack(name)
except StackNotFoundError:
workspace.create_stack(name)

def __repr__(self):
return f"Stack(stack_name={self.name!r}, workspace={self.workspace!r}, mode={self._mode!r})"
Expand Down