-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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 taint and untaint commands when in a workspace #22467
Conversation
🚢 🚢 🚢 :D |
Is this going to be considered for one of the upcoming 0.12.x patch releases? |
It would be really great if this would be included in the next release. |
It would be great if this could be included in the next release. |
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 working on this, @kulinacs ! The changes look great, but I've requested changes to the tests.
The test changes are absolutely not something we'd expect a community contributor to know, and if you'd rather work on that part I'd be happy to re-write the tests using our more modern types for you. (states.State
instead of terraform.State
, and if you' think that's confusing WELCOME TO MY EVERY DAY 😉 )
Thanks again!
command/taint_test.go
Outdated
defer testFixCwd(t, tmp, cwd) | ||
|
||
// Write the temp state | ||
state := &terraform.State{ |
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.
This is absolutely something a developer would not know if they weren't writing this full-time, but we prefer to use states.State
when writing tests post-v0.12. This also removes the need for testStateFileWorkspaceDefault
:
state := states.BuildState(func(s *states.SyncState) {
s.SetResourceInstanceCurrent(
addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_instance",
Name: "bar",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
&states.ResourceInstanceObjectSrc{
AttrsJSON: []byte(`{"id":"bar"}`),
Status: states.ObjectReady,
},
addrs.AbsProviderConfig{
Provider: addrs.NewDefaultProvider("test"),
Module: addrs.RootModule,
},
)
})
path := testStateFile(t, state)
I'd greatly appreciate it if you'd re-write the tests for me. It's been a while since I've looked at the Terraform code and I don't want this PR blocked on me figuring out the type changes 😁 |
85cdfc1
to
15a4711
Compare
Fixes hashicorp#22157. Removes DefaultStateFilepath as the default for the -state flag, allowing workspaces to be used properly.
Apologies for the bad commit, I made a slight mess while rebasing against upstream :) hang tight, sorry for the extra noise! |
8f7f8c6
to
c6733f7
Compare
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.
Looks great, thanks!
I rebased your fork's taint-workspace branch against the upstream before modifying the tests, which wasn't strictly necessary. I apologize if I've messed up your fork at all (I'm having a bit of A Day in github).
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. |
Fixes #22157. Removes DefaultStateFilepath as the default for the
-state flag, allowing workspaces to be used properly.