-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fixed artifact_registry_repository permadiff in unordered array #9376
fixed artifact_registry_repository permadiff in unordered array #9376
Conversation
Hello! I am a robot. It looks like you are a: Community Contributor @trodge, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
How do I get magician to read my account as a Googler? |
The magician would have checked your membership using the GitHub api for the Sorry for the delay. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Breaking Change(s) DetectedThe following breaking change(s) were detected within your pull request.
If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a major release window. An Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 1 file changed, 29 insertions(+), 23 deletions(-)) |
Tests analyticsTotal tests:
|
@Subserial drive-by comment: see go/terraform-contribution-guide#before-you-begin for more details |
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.
Unfortunately, you will need to find a different way to fix this bug, since making a list into a set would be a breaking change for existing users. See this comment for details.
When such a way is found, please re-request review on this PR.
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 1 file changed, 44 insertions(+), 2 deletions(-)) |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 1 file changed, 44 insertions(+), 2 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccLoggingProjectSink_updatePreservesCustomWriter |
Rerun these tests in REPLAYING mode to catch issues
|
I'm not sure what the requested change feature in Github is, but otherwise I've updated the strategy for addressing the permadiff. |
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.
"Request changes" just means make changes to your PR and then re-request review when you want your reviewer to take another look.
Edit- also take a look at my third comment before addressing the other two, they didn't come out in the order I expected.
} | ||
hashFunc := func(val any) string { | ||
x := val.(map[string]any) | ||
return fmt.Sprintf("[id:%v priority:%v repository:%v]", x["id"], x["priority"], x["repository"]) |
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 believe this is equivalent to
return fmt.Sprintf("%v", x)
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'm not sure if golang is consistent with map key order within the same process. This was to prevent two maps from outputting different strings with the same information.
} | ||
|
||
func arrayDiffSuppress(old, new []any, hashFunc func(x any) string) bool { | ||
oldMap := map[string]bool{} |
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.
If we're just making a set here we can use map[string]struct{}
, if we need a boolean value that's distinct from omitting the key, use map[string]bool
.
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.
Replaced with schema.Set.
# limitations under the License. | ||
-%> | ||
func upstreamPoliciesDiffSuppress(k, old, new string, d *schema.ResourceData) bool { | ||
log.Printf("%v, %v, %v\n", k, old, new) |
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.
Unless we have a reason to do this by hand, it would probably be better to use the sdk provided set methods such as schema.NewSet and Set.Equal to ensure we don't miss anything with casting the types around.
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.
Agreed! Switched over to using schema.Set.
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 1 file changed, 24 insertions(+), 2 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDataprocClusterIamPolicy|TestAccDataprocJobIamPolicy|TestAccLoggingProjectSink_updatePreservesCustomWriter|TestAccDataSourceGoogleServiceAccountJwt |
Rerun these tests in REPLAYING mode to catch issues
|
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.
LGTM, but it looks like the test isn't running in VCR. Would it be possible to modify an existing test so that it will be re-recorded? Ideally we would just add another element to upstream_policies
to make sure the diff suppress works as expected.
} | ||
hashFunc := func(val any) int { | ||
x := val.(map[string]any) | ||
hashStr := fmt.Sprintf("[id:%v priority:%v repository:%v]", x["id"], x["priority"], x["repository"]) |
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.
Is there any chance we could see a panic if val isn't a map?
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.
It is possible if the returned field doesn't fit the expected schema, somehow. I updated it to avoid panicking on a bad cast.
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 3 files changed, 60 insertions(+), 14 deletions(-)) |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 3 files changed, 73 insertions(+), 14 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccArtifactRegistryRepository_artifactRegistryRepositoryVirtualExample|TestAccLoggingProjectSink_updatePreservesCustomWriter|TestAccDataSourceGoogleServiceAccountJwt|TestAccDataSourceGoogleServiceAccountIdToken_impersonation |
Rerun these tests in REPLAYING mode to catch issues
|
The failed test is not caused by this pull request. |
…leCloudPlatform#9376) * fixed permadiff in unordered array * changed permadiff fix strategy for upstream policies * removed no-op field * change diff semantics to use schema.Set * updated virtual example with intentional out-of-order priorities * update virtual policy comparison to not panic on bad cast (if possible)
Suppress diff of artifact_registry_repository.virtual_repository_config.upstream_policies order using set semantics.
Fixes hashicorp/terraform-provider-google#16381
Release Note Template for Downstream PRs (will be copied)