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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack selection behavior #11408

Merged
merged 1 commit into from Nov 18, 2022
Merged
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
4 changes: 4 additions & 0 deletions pkg/cmd/pulumi/util.go
Expand Up @@ -356,6 +356,8 @@ func chooseStack(ctx context.Context,
}

// If we are offering to create a new stack, add that to the end of the list.
// Otherwise, default to a stack if one exists – otherwise pressing enter will result in
// the empty string being passed (see https://github.com/go-survey/survey/issues/342).
const newOption = "<create a new stack>"
if offerNew {
options = append(options, newOption)
Expand All @@ -367,6 +369,8 @@ func chooseStack(ctx context.Context,
} else if len(options) == 0 {
// If no options are available, we can't offer a choice!
return nil, errors.New("this command requires a stack, but there are none")
} else if defaultOption == "" {
defaultOption = options[0]
}

// Customize the prompt a little bit (and disable color since it doesn't match our scheme).
Expand Down