pkg
pkg copied to clipboard
`patch.Helper` doesn't work with secrets and configmaps
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: https://github.com/fluxcd/pkg/blob/a04ccbfc5bc8348e31131978140640f0b1363d18/runtime/patch/patch.go#L239-L242
So it very deliberately checks spec field, which is something secrets and configmaps don't have.
Of course, there are more examples of resources that don't have spec.
I suggest you use ssa.apply to patch Kubernetes native resources, the patcher is for custom resources which subscribe to the spec/status standard.
@stefanprodan maybe that should be made more explicit in the docs?
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.