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

How to exclude specific fields for comparison within the statefulset spec ? #40

Open
kaushiksrinivas opened this issue Apr 7, 2021 · 6 comments

Comments

@kaushiksrinivas
Copy link

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 ?

@pepov
Copy link
Collaborator

pepov commented Apr 7, 2021

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
	}

@kaushiksrinivas
Copy link
Author

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.

@pepov
Copy link
Collaborator

pepov commented Apr 7, 2021

those are examples, you have to craft the function you need for yourself right now

@kaushiksrinivas
Copy link
Author

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 ?

@pepov
Copy link
Collaborator

pepov commented Apr 7, 2021

It's absolutely possible! If you have something we can add it through a pull request of course!

@kaushiksrinivas
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants