Closed BlaineEXE closed 3 years ago
We needed to do a similar thing in Rook and had to use an external library (github.com/google/go-cmp/cmp) to "diff" objects.
I would propose that if we want to check for equality to empty, this must look like
cmp.Diff(v1alpha1.ObjectBucket{}, *ob)
@travisn is there a reason we used cmp.Diff
in Rook and not apiequality.Semantic.DeepEqual?
https://stupefied-goodall-e282f7.netlify.app/contributors/devel/api_changes/#update-the-semantic-comparisons
https://github.com/kubernetes/apimachinery/blob/0ca7b349afd234e3376e550db2392f41236be77b/pkg/api/equality/semantic.go#L27-L49
update: was it just so that we could get the diff reported in a nice output?
@leseb IIRC you implemented the diff check? I don't recall the details.
I don't think I did. @leseb do you recall any details about cmp.Diff
vs apiequality.Semantic.DeepEqual
?
@travisn you actually did add it long ago I remember since I requested it. We use it to get the CR diff changes when the CR is updated. We don't actually use it for equality. We might as well use DeepEqual unless the type cannot be "deep equaled".
Oh did I do that? :) I was thinking there was another change after mine, oh well. We really just need to know if there is any difference so we know to update the pod spec, then print the diff to the log.
See discussion on comment: https://github.com/kube-object-storage/lib-bucket-provisioner/pull/201#discussion_r546008824