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

patch.Helper doesn't work with secrets and configmaps #588

Open
errordeveloper opened this issue Jun 15, 2023 · 4 comments
Open

patch.Helper doesn't work with secrets and configmaps #588

errordeveloper opened this issue Jun 15, 2023 · 4 comments

Comments

@errordeveloper
Copy link
Contributor

errordeveloper commented Jun 15, 2023

I was using patcher in a project and discovered the hard way that it doesn't actually patch secrets.

The reason behind that is to do with this logic:

pkg/runtime/patch/patch.go

Lines 239 to 242 in a04ccbf

func (h *Helper) patch(ctx context.Context, obj client.Object, opts ...client.PatchOption) error {
if !h.shouldPatch("metadata") && !h.shouldPatch("spec") {
return nil
}

So it very deliberately checks spec field, which is something secrets and configmaps don't have.

@errordeveloper
Copy link
Contributor Author

Of course, there are more examples of resources that don't have spec.

@stefanprodan
Copy link
Member

stefanprodan commented Jun 15, 2023

I suggest you use ssa.apply to patch Kubernetes native resources, the patcher is for custom resources which subscribe to the spec/status standard.

@errordeveloper
Copy link
Contributor Author

@stefanprodan maybe that should be made more explicit in the docs?

@stefanprodan
Copy link
Member

Yes for sure, patcher is for controllers to set finalizers and status conditions, we use it as such in Flux, and we should clearly state it’s purpose in docs.

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