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

json-output: Omit unchanged resource_drift entries #28975

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

alisdair
Copy link
Contributor

Previously, if any resources were found to have drifted, the JSON plan output would include a drift entry for every resource in state. This commit aligns the JSON plan output with the CLI UI, and only includes those resources where the old value does not equal the new value—i.e. drift has been detected.

Also fixes a bug where the "address" field was missing from the drift output, and adds some test coverage.

(I attempted to refactor the code which determines which resources have drifted into a single location, but got stuck with import cycles. We make the decision about drift very late, after decoding the state values using the provider schema, which means that the implementation needs to refer to the states, plans, and terraform packages, while being called from command/views and command/jsonplan.)

Previously, if any resources were found to have drifted, the JSON plan
output would include a drift entry for every resource in state. This
commit aligns the JSON plan output with the CLI UI, and only includes
those resources where the old value does not equal the new value---i.e.
drift has been detected.

Also fixes a bug where the "address" field was missing from the drift
output, and adds some test coverage.
@alisdair alisdair requested a review from a team June 17, 2021 19:10
@alisdair alisdair self-assigned this Jun 17, 2021
@alisdair alisdair added the 1.0-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Jun 17, 2021
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM!

FWIW the whole json* package structure is a trap specially (and accidentally) designed to capture import cycles, sorry 🙃

@alisdair alisdair merged commit 5611da8 into main Jun 18, 2021
@alisdair alisdair deleted the alisdair/jsonplan-drift branch June 18, 2021 15:39
@github-actions
Copy link

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 Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.0-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged json-output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants