Skip to content

Commit

Permalink
Merge #11115
Browse files Browse the repository at this point in the history
11115: attempts to select the stack before creating r=justinvp a=jaxxstorm



Co-authored-by: Dennis Webb <dhwebb@gmail.com>
Co-authored-by: Lee Briggs <lee@leebriggs.co.uk>
  • Loading branch information
3 people committed Oct 21, 2022
2 parents 79c0af7 + 340c4c9 commit 5069e43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
@@ -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

0 comments on commit 5069e43

Please sign in to comment.