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

cli(state upgrade): Prompt for project names for detached stacks #13078

Merged
merged 1 commit into from Jun 23, 2023

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Jun 1, 2023

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600


Preview

Kapture 2023-05-31 at 19 25 57

Copy link
Contributor Author

abhinav commented Jun 1, 2023

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Jun 1, 2023

Changelog

[uncommitted] (2023-06-22)

Features

  • [cli/state] The upgrade command now prompts the user to supply project names for stacks for which the project name could not be automatically guessed.
    #13078

@abhinav abhinav requested a review from a team June 1, 2023 23:12
@abhinav abhinav force-pushed the filestate-upgrade-backfill-option branch from b07a824 to 85aba26 Compare June 12, 2023 16:29
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from 45191c1 to 32f182e Compare June 12, 2023 16:30
pkg/cmd/pulumi/state_upgrade.go Show resolved Hide resolved
pkg/cmd/pulumi/state_upgrade.go Outdated Show resolved Hide resolved
abhinav added a commit that referenced this pull request Jun 13, 2023
As pointed out in
#13078 (comment),
we repreatedly reimplement the project name validation logic.

This moves it to a central place: `tokens.ValidateProjectName`,
and re-uses it in existing places where copies were found.
@abhinav abhinav force-pushed the filestate-upgrade-backfill-option branch from 85aba26 to d237a3e Compare June 13, 2023 15:47
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch 2 times, most recently from 3183a92 to 0224384 Compare June 13, 2023 16:07
abhinav added a commit that referenced this pull request Jun 13, 2023
As pointed out in
#13078 (comment),
we repreatedly reimplement the project name validation logic.

This moves it to a central place: `tokens.ValidateProjectName`,
and re-uses it in existing places where copies were found.
@abhinav abhinav force-pushed the filestate-upgrade-backfill-option branch from d237a3e to 360ea62 Compare June 13, 2023 16:21
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from 0224384 to 3433903 Compare June 13, 2023 16:21
abhinav added a commit that referenced this pull request Jun 13, 2023
As pointed out in
#13078 (comment),
we repreatedly reimplement the project name validation logic.

This moves it to a central place: `tokens.ValidateProjectName`,
and re-uses it in existing places where copies were found.
@abhinav abhinav force-pushed the filestate-upgrade-backfill-option branch from 360ea62 to 3e6cc0d Compare June 13, 2023 16:44
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from 3433903 to 9841557 Compare June 13, 2023 16:45
abhinav added a commit that referenced this pull request Jun 13, 2023
As pointed out in
#13078 (comment),
we repreatedly reimplement the project name validation logic.

This moves it to a central place: `tokens.ValidateProjectName`,
and re-uses it in existing places where copies were found.
@abhinav abhinav force-pushed the filestate-upgrade-backfill-option branch from 3e6cc0d to 03ff557 Compare June 13, 2023 17:56
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from 9841557 to 23eed33 Compare June 13, 2023 17:56
bors bot added a commit that referenced this pull request Jun 13, 2023
13165: sdk/go: Add tokens.ValidateProjectName r=abhinav a=abhinav

As pointed out in
#13078 (comment),
we repreatedly reimplement the project name validation logic.

This moves it to a central place: `tokens.ValidateProjectName`,
and re-uses it in existing places where copies were found.


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
Base automatically changed from filestate-upgrade-backfill-option to master June 13, 2023 20:30
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch 2 times, most recently from 5c2a01f to c9304ab Compare June 14, 2023 15:39
@abhinav abhinav requested a review from a team June 15, 2023 17:08
@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch 3 times, most recently from c2c7d4d to aa93f5a Compare June 22, 2023 15:56
@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

bors merge

bors bot added a commit that referenced this pull request Jun 22, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

bors cancel

@bors
Copy link
Contributor

bors bot commented Jun 22, 2023

Canceled.

@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

slightly broken; vt10x library needs an update for Windows.

@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from aa93f5a to 5d39fc9 Compare June 22, 2023 18:12
@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

bors merge

bors bot added a commit that referenced this pull request Jun 22, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


13249: fix(codegen/go): Use raw string literals for multiline-strings r=abhinav a=abhinav

We already have logic in place to generate mutliline strings with
backticks if they meet certain conditions in genTemplateExpression.
However, the logic came into effect only if the string was complex
enough to warrant use of `Sprintf`
because the function short circuits to just printing a string literal
if the string doesn't need a `Sprintf`.

This changes genStringLiteral to be responsible for the decision
of whether the string warrants backticks or not,
retaining the prior conditions on whether the string would benefit
from being split across multiple lines.

Resolves #12358


13252: Freeze v3.73.0 r=Zaid-Ajaj a=Zaid-Ajaj



Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2023

Build failed (retrying...):

bors bot added a commit that referenced this pull request Jun 22, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600
@bors
Copy link
Contributor

bors bot commented Jun 22, 2023

Canceled.

@abhinav abhinav force-pushed the abhinav/filestate-upgrade-prompt branch from 5d39fc9 to d5fea17 Compare June 22, 2023 20:48
@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

🤦

I need to skip pty.Open on Windows on the second test too.

=== FAIL: cmd/pulumi TestStateUpgradeProjectNameWidget_noStacks (0.00s)
    state_upgrade_test.go:296: 
        	Error Trace:	C:/a/pulumi/pulumi/pkg/cmd/pulumi/state_upgrade_test.go:296
        	Error:      	Received unexpected error:
        	            	unsupported
        	Test:       	TestStateUpgradeProjectNameWidget_noStacks
        	Messages:   	creating pseudo-terminal

=== FAIL: cmd/pulumi TestStateUpgradeProjectNameWidget_noStacks (re-run 1) (0.00s)
    state_upgrade_test.go:296: 
        	Error Trace:	C:/a/pulumi/pulumi/pkg/cmd/pulumi/state_upgrade_test.go:296
        	Error:      	Received unexpected error:
        	            	unsupported
        	Test:       	TestStateUpgradeProjectNameWidget_noStacks
        	Messages:   	creating pseudo-terminal

@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

bors try

bors bot added a commit that referenced this pull request Jun 22, 2023
@bors
Copy link
Contributor

bors bot commented Jun 22, 2023

try

Build failed:

@abhinav
Copy link
Contributor Author

abhinav commented Jun 22, 2023

bors merge

bors bot added a commit that referenced this pull request Jun 22, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


13254: cli(state/rename): Validate new name before renaming r=abhinav a=abhinav

Check that resource names are valid
before renaming a resource and possibly corrupting the stack.

Resource names are `QName`s, so we rely on tokens.IsQName for this.

Resolves #11746


13256: Changelog and go.mod updates for v3.73.0 r=pulumi-bot a=pulumi-bot

bors merge

Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
Co-authored-by: github-actions <github-actions@github.com>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2023

Build failed (retrying...):

bors bot added a commit that referenced this pull request Jun 22, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
@bors
Copy link
Contributor

bors bot commented Jun 23, 2023

Build failed:

@abhinav
Copy link
Contributor Author

abhinav commented Jun 23, 2023

bors merge

bors bot added a commit that referenced this pull request Jun 23, 2023
13078: cli(state upgrade): Prompt for project names for detached stacks r=abhinav a=abhinav

When running 'pulumi state upgrade', supply the
ProjectsForDetachedStacks option to the file state backend so that we
get asked to fill in project names for stacks where we could not guess
them automatically.

The implementation of the prompt is straightforward:
For each stack, ask a question with the survey package
and feed the result back to the filestate backend.

Testing this is a bit complicated because terminals are involved.
The test for this uses the go-expect and vt10x libraries
recommended in the documentation for survey.
It uses them to simulate a terminal emulator and acts on the output.
The pty library is used to create a compatible pseduo-terminal.
Unfortunately, these test libraries rely on Unix APIs and are not
available on Windows, so the test will not run on Windows machines.

Resolves #12600

---

Preview

![Kapture 2023-05-31 at 19 25 57](https://github.com/pulumi/pulumi/assets/41730/69fcf37d-0267-40cc-9002-6514f1cf9ad5)


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
@bors
Copy link
Contributor

bors bot commented Jun 23, 2023

Build failed:

@abhinav
Copy link
Contributor Author

abhinav commented Jun 23, 2023

setup node timed out: image

bors retry

@bors
Copy link
Contributor

bors bot commented Jun 23, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

  • bors-ok

@bors bors bot merged commit e49c0fe into master Jun 23, 2023
43 checks passed
@bors bors bot deleted the abhinav/filestate-upgrade-prompt branch June 23, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants