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

Attempt to select stack then create as fallback #11402

Merged
merged 1 commit into from Nov 18, 2022
Merged

Attempt to select stack then create as fallback #11402

merged 1 commit into from Nov 18, 2022

Conversation

aq17
Copy link
Contributor

@aq17 aq17 commented Nov 17, 2022

Description

Fixes #11392

If a user does not have write permission (i.e. read-only), attempting to create the stack first will fail before the stack select fallback is triggered. Flip the logic to select first, then create.

7695311 changed it for python auto API already, this PR does the same for TS, Go, C#

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@aq17 aq17 requested review from ringods and Frassle November 17, 2022 23:30
@pulumi-bot
Copy link
Contributor

pulumi-bot commented Nov 17, 2022

Changelog

[uncommitted] (2022-11-18)

Bug Fixes

  • [sdk/{dotnet,go,nodejs}] Attempt to select stack then create as fallback on 'createOrSelect'
    #11402

@aq17 aq17 force-pushed the aqiu/11392 branch 2 times, most recently from a86dd9b to 44d6862 Compare November 17, 2022 23:43
@aq17 aq17 changed the title Attempt to select stack then create as fallback in ts Attempt to select stack then create as fallback Nov 17, 2022
Copy link
Member

@ringods ringods left a comment

Choose a reason for hiding this comment

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

@aq17 can you also reverse it for C# in this PR?

WorkspaceStackInitMode.CreateOrSelect => Task.Run(async () =>
{
try
{
await workspace.CreateStackAsync(name, cancellationToken).ConfigureAwait(false);
}
catch (StackAlreadyExistsException)
{
await workspace.SelectStackAsync(name, cancellationToken).ConfigureAwait(false);
}
}),

sdk/go/auto/stack.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dixler dixler left a comment

Choose a reason for hiding this comment

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

Nice. I have 1 suggestion around simplifying the retry logic in Go. (also you have a small lint error)

@aq17 aq17 force-pushed the aqiu/11392 branch 3 times, most recently from 88ce9a8 to 4465214 Compare November 18, 2022 18:49
sdk/go/auto/stack.go Outdated Show resolved Hide resolved
Copy link
Member

@ringods ringods left a comment

Choose a reason for hiding this comment

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

LGTM

@aq17
Copy link
Contributor Author

aq17 commented Nov 18, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 18, 2022

Build succeeded:

@bors bors bot merged commit 70192a5 into master Nov 18, 2022
@bors bors bot deleted the aqiu/11392 branch November 18, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack.createOrSelect: first select, then create to play well with RO permissions on Pulumi Service
4 participants