-
Notifications
You must be signed in to change notification settings - Fork 895
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
fix deep equal check failure on objects with runtime.RawExtension. #5940
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5940 +/- ##
==========================================
+ Coverage 48.09% 48.15% +0.06%
==========================================
Files 663 665 +2
Lines 54769 54850 +81
==========================================
+ Hits 26340 26415 +75
+ Misses 26719 26717 -2
- Partials 1710 1718 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
d2e61d4
to
7e4e51f
Compare
7e4e51f
to
4a15b13
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: zach593 <[email protected]>
4a15b13
to
a59f918
Compare
var aObj, bObj unstructured.Unstructured | ||
err := aObj.UnmarshalJSON(a.Raw) | ||
if err != nil { | ||
return false | ||
} | ||
err = bObj.UnmarshalJSON(b.Raw) | ||
if err != 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.
Should we consider the case where a.Raw
is nil or an empty byte array?
obj1 := &workv1alpha1.Work{
Spec: workv1alpha1.WorkSpec{
Workload: workv1alpha1.WorkloadTemplate{Manifests: []workv1alpha1.Manifest{{RawExtension: runtime.RawExtension{Raw: []byte{}}}}},
},
}
obj2 := &workv1alpha1.Work{
Spec: workv1alpha1.WorkSpec{
Workload: workv1alpha1.WorkloadTemplate{Manifests: []workv1alpha1.Manifest{{RawExtension: runtime.RawExtension{Raw: nil}}}},
},
}
checker := equality.Semantic.Copy()
_ = RegisterEqualityCheckFunctions(&checker)
fmt.Println(equality.Semantic.DeepEqual(obj1, obj2)) #true
fmt.Println(checker.DeepEqual(obj1, obj2)) #false
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.
How about
var aObj, bObj unstructured.Unstructured | |
err := aObj.UnmarshalJSON(a.Raw) | |
if err != nil { | |
return false | |
} | |
err = bObj.UnmarshalJSON(b.Raw) | |
if err != nil { | |
if (a.Raw == nil || len(a.Raw) == 0) != (b.Raw == nil || len(b.Raw) == 0) { | |
return false | |
} | |
if a.Raw == nil || len(a.Raw) == 0 { | |
return true | |
} | |
var aObj, bObj unstructured.Unstructured | |
err := aObj.UnmarshalJSON(a.Raw) | |
if err != nil { | |
return false | |
} | |
err = bObj.UnmarshalJSON(b.Raw) | |
if err != nil { |
What type of PR is this?
/kind bug
What this PR does / why we need it:
see #5938
Which issue(s) this PR fixes:
Fixes #5938
Special notes for your reviewer:
Does this PR introduce a user-facing change?: