Open kaushiksrinivas opened 3 years ago
The way this goes is to remove those fields before the comparison happens. You can see examples here on how to do that: https://github.com/banzaicloud/k8s-objectmatcher/blob/af0ea18f6ccf72e970a35f370ff0a392b3a1ffdc/patch/deletenull.go#L28-L58
And here is how to use it:
opts := []patch.CalculateOption{
patch.IgnoreStatusFields(),
patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus(),
}
patchResult, err := patch.DefaultPatchMaker.Calculate(existing.(runtime.Object), newObject.(runtime.Object), opts...)
if err != nil {
return err
}
Hi, The above code samples highlights only about status fields and volumeClainTemplateTypeMetaAndStatus fields. How to exclude for a field which is part of the spec. For example a field within the statefulset spec. Is that exclusion also possible ? I could not see any related functions to do the same.
those are examples, you have to craft the function you need for yourself right now
Got it... Would it be possible to implement such field exclusions as part of a common library within this repository ? Or we could take them as contribution pull requests ?
It's absolutely possible! If you have something we can add it through a pull request of course!
Ok sure.. am currently working on excluding fields in statefulset. i will try to create them in a generic way and come up with a PR. thanks for the info now.
Would like to exclude one specific field within the statefulset spec for the object matcher comparison. Is there a way to exclude specific fields in the statefulset spec for object matcher comparison ?