-
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 bug for force push for backends besides the remote backend #26190
Conversation
states/remote/state_test.go
Outdated
@@ -302,6 +302,168 @@ func TestWriteStateForMigration(t *testing.T) { | |||
}, | |||
} | |||
|
|||
testCases := []migrationTestCase{ |
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.
The diff implies this is the new section, however, it is the previous set of test cases with the EnableForcePush-specific code removed. The test TestWriteStateForMigrationWithForcePushClient
is the new test.
Codecov Report
|
2cbcafb
to
9d90bd6
Compare
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.
👏 Good catch in the force logic, that was subtle! Thanks for making the test changes easy to follow.
Edit: I agree with cherry-picking to 0.13, too.
In refactoring the force push code when implementing force push for the Terraform remote backend, a bug was introduced that meant that backends that don't implement the EnableForcePush method would still have their state validated. This commit fixes that, and adds test coverage such that there is a separate mockRemoteClient that has this method implemented.
9d90bd6
to
2c35869
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. |
In refactoring the
state push -force
code when implementing force push for the Terraform remote backend, a bug was introduced that meant that backends that don't implement theEnableForcePush
method would still have their state validated, despite having-force
set.This commit fixes that, and adds test coverage such that there is a separate mockRemoteClient that has this method implemented. I had trouble thinking of a way to simplify the tests that doesn't make it needlessly complicated. The tests fail without the change in state.go.
Closes #25761
I nominate this change to go to v0.13 as well, as it is a bug fix for existing versions worthy of cherry-picking.