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

Backport of Generalize the idea of a "plan mode", vs just destroy flag into v0.15 #28529

Closed
wants to merge 2 commits into from

Conversation

teamterraform
Copy link
Contributor

Backport

This PR is auto-generated from #28489 to be assessed for backporting due to the inclusion of the label 0.15-backport.

The below text is copied from the body of the original PR.


Previously there were only two planning modes: normal mode and destroy mode. In that context it made sense for these to be distinguished only by a boolean flag.

We're now getting ready to add our third mode, "refresh only". This establishes the idea that planning can be done in one of a number of mutually-exclusive "modes", which are related to but separate from the various other options that serve as modifiers for the plan operation.

This commit only introduces the new plans.Mode type and replaces the existing "destroy" flag fields with a field of that type. This doesn't cause any change in effective behavior because Terraform Core still supports only NormalMode and DestroyMode, with NewContext rejecting an attempt to create a RefreshMode context for now, and the CLI layer having no codepath that tries to set it.

It is in retrospect a little odd that the "destroy" flag was part of ContextOpts rather than just an argument to the Plan method, but refactoring that would be too invasive a change for right now so we'll leave this as a field of the context for now and save revisiting that for another day.


For this PR I've just peeled off the first two commits from #28297. These two just change internal implementation details of how we represent destroy mode without adding any new functionality. I want to land these first and early because they are cross-cutting and thus likely to come into conflict with other work if they were part of a long-lived feature branch.

With these in place the remaining work should involve more localized commits that we can land without necessarily colliding with other work in other subsystems.

I've marked this for backport primarily because otherwise it seems likely that other unrelated backports to v0.15 will end up failing due to this being a cross-cutting change. However, it also seems likely that at least parts of the planned functionality for refresh-only plans will also land in the v0.15 branch, and so this backport will support that.

@teamterraform teamterraform force-pushed the backport/f-plan-mode/virtually-pro-husky branch from 5a03072 to c9e3b5d Compare April 27, 2021 15:24
@apparentlymart
Copy link
Contributor

I've backported this manually with git cherry-pick because the backport assistant generates poor commit messages and this is a multi-commit set and so I can't repair them using the squash UI as I typically do.

@apparentlymart apparentlymart deleted the backport/f-plan-mode/virtually-pro-husky branch April 27, 2021 15:28
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants