-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
command: Better in-house provider install errors #26066
command: Better in-house provider install errors #26066
Conversation
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it, love everything about it. Definitely the right idea 🎉
205f81f
to
6a8268e
Compare
Added tests, updated the format of the displayed |
command/init.go
Outdated
|
||
fmt.Fprintf(&detail, "Found unresolvable legacy provider references in state. It looks like these refer to in-house providers. You can update the resources in state with the following %s:\n", command) | ||
for legacy, replacement := range stateReplaceProviders { | ||
fmt.Fprintf(&detail, "\n terraform state replace-provider \\\n %s \\\n %s", legacy, replacement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling this backslash-escaping of newlines won't work in the Windows command interpreter 😖 . Although it'll be ugly to read, I think it'd be safer to put this all on one line so that everyone can just copy-paste it into whatever shell they are using. 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I just noticed in your last comment that you did this to avoid the automatic line wrapping. 🙄
I thought we had a rule in the line wrapping that it would not try to wrap a line that starts with leading whitespace, but I guess I imagined it. With that said, I think it could be reasonable to add such an exception, if that would make this easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the prompt! I hadn't considered trying to adjust how we format diagnostics to allow longer command lines. I made an attempt in 3547f9e and updated the other commits accordingly.
Diagnostic detail lines sometimes contain lines which include commands suggested for the user to execute. By convention, these start with leading whitespace to indicate that they are not prose. This commit changes the diagnostic formatter to wrap each line of the detail separately, and skips word wrapping for lines prefixed with space. This prevents ugly and confusing wrapping of long command lines.
When init attempts to install a legacy provider required by state and fails, but another provider with the same type is successfully installed, this almost definitely means that the user is migrating an in-house provider. The solution here is to use the `terraform state replace-provider` subcommand. This commit makes that next step clearer, by detecting this specific case, and displaying a list of commands to fix the existing state provider references.
The error diagnostic shown when legacy state contains resources from in-house providers has changed, so update references to it in the 0.13 upgrade guide.
6a8268e
to
f795083
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
When
init
attempts to install a legacy provider required by state and fails, but another provider with the same type is successfully installed, this almost definitely means that the user is migrating an in-house provider. The solution here is to use theterraform state replace-provider
subcommand.This commit makes that next step clearer, by detecting this specific case.
Screenshots
Before:
After: