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

Custom metadata DiffSuppressFunc - issue #5014 #6734

Merged
merged 4 commits into from May 4, 2020
Merged

Custom metadata DiffSuppressFunc - issue #5014 #6734

merged 4 commits into from May 4, 2020

Conversation

richeney
Copy link
Contributor

@richeney richeney commented May 1, 2020

Fixes #5014

@ghost ghost added the size/XS label May 1, 2020
@richeney
Copy link
Contributor Author

richeney commented May 1, 2020

The Go SDK for azurerm adds four metadata fields - "createdBy", "createdOn", "updatedBy", "updatedOn" - which causes spurious changes in terraform plan. (Users have been using lifecycle ignore blocks on metadata to suppress the "changes".)

I added a custom DiffSuppressFunc that strips those keys (if found) before using reflect.DeepEqual. With the change then valid changes to custom metadata will now be trapped. E.g.:

  metadata     = <<METADATA
    {
        "category": "Tags"
    }
METADATA

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @richeney, these changes look good but it'd be great to get a test to confirm it all works. I wrote one on #6736 that fails currently. Do you mind writing your own or doing a little copy paste magic to make sure that test passes with your changes?

@ghost ghost added size/L and removed size/XS labels May 2, 2020
@richeney
Copy link
Contributor Author

richeney commented May 2, 2020

I added essentially the same fix to policy definitions as I'd already created for policy set definitions. (As suggested by @keanesf's comment. )

Plus tests for both. (Thanks for the example, @mbfrahry!)

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @richeney

Thanks for pushing those changes - taking a look through this now LGTM 👍

Thanks!

@tombuildsstuff tombuildsstuff dismissed mbfrahry’s stale review May 4, 2020 04:38

dismissing since changes have been pushed

@tombuildsstuff tombuildsstuff added this to the v2.9.0 milestone May 4, 2020
@tombuildsstuff
Copy link
Member

Tests look good 👍

@tombuildsstuff tombuildsstuff merged commit 3a4f6ce into hashicorp:master May 4, 2020
tombuildsstuff added a commit that referenced this pull request May 4, 2020
@ghost
Copy link

ghost commented May 8, 2020

This has been released in version 2.9.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.9.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jun 3, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Jun 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Policies always update even when no change occurs
3 participants