-
Notifications
You must be signed in to change notification settings - Fork 165
[#TF-722] Allow safe and force delete through the tfe provider #675
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
Conversation
0c53b4f
to
321be76
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.
Not smoke tested yet but this is looking pretty good!
e658690
to
c137aa9
Compare
2cbd1cf
to
7dbdcc9
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.
I really appreciate the unit testing you added to delete because it can be difficult to set up the prerequisites for a conflict
I feel like the behavior of force_delete is unique enough to warrant mentioning in the error message because it's a meta argument. What do you think?
This is a great contribution, thanks!
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 only had one suggestion about ways of unnesting some if
statements, the actual logic in this PR is probably the only thing I feel confident in checking and it seems like you nailed it to me 💯 !
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.
Great! Thanks. I think the linter issue looks straightforward as well.
This is great, if we can cut a release soon, that would be super awesome! |
func errWorkspaceSafeDeleteWithPermission(workspaceID string, err error) error { | ||
if err != nil { | ||
if strings.HasPrefix(err.Error(), "conflict") { | ||
return fmt.Errorf("Error deleting workspace %s: %w\nTo delete this workspace without destroying the managed resources, add force_delete = true to the resource config.", workspaceID, err) | ||
} | ||
} | ||
return nil | ||
} |
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 logic here seems wrong; if there's an error, and it's not a conflict, this function should still return the err
value. i saw this behavior today when i destroyed a terraform cloud workspace, and the workspace wasn't actually deleted but the apply succeeded and the resource was removed from state.
Description
Adds the
force_delete
attribute to a workspace provider resource.External links
Output from acceptance tests
Please run applicable acceptance tests locally and include the output here. See TESTS.md to learn how to run acceptance tests.
If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.