cluster-api icon indicating copy to clipboard operation
cluster-api copied to clipboard

Reduce number of excludes in golangci-lint

Open sbueringer opened this issue 7 months ago • 5 comments

This issue will track the open tasks to reduce the number of excludes in our golangci-lint config

Tasks:

  • [ ] https://github.com/kubernetes-sigs/cluster-api/issues/12272
  • [x] Migrate away from client.Apply: client.Apply is deprecated: Use client.Client.Apply
  • [ ] Let's audit all exclude rules and check which ones we can drop or match more precisely on the findings

sbueringer avatar Aug 27 '25 11:08 sbueringer

/triage accepted

sivchari avatar Aug 28 '25 04:08 sivchari

Regarding

Migrate away from client.Apply: client.Apply is deprecated: Use client.Client.Apply

I could see only in few tests files client.Client is implicitly declared to satisfy the Client interface, Like https://github.com/kubernetes-sigs/cluster-api/blob/b46a303451e9acd9bf59f634ad468631ba6b2d0c/cmd/clusterctl/client/cluster/crd_migration_test.go#L241.

Where else do I need to check to fix this? Is there any way I can reproduce this warning locally.

Karthik-K-N avatar Sep 03 '25 13:09 Karthik-K-N

@Karthik-K-N You can remove the exclude and run make lint

sbueringer avatar Sep 03 '25 16:09 sbueringer

@Karthik-K-N You can remove the exclude and run make lint

Thanks you, Still I could not able to rightly identify whats the right way of replace client.Apply is Patch commands.(May be to create patch object with RawPatch) may be will explore a bit or it would be handy if you have any other pointers or expectations. Thank you.

Karthik-K-N avatar Sep 05 '25 05:09 Karthik-K-N

Sure, no problem. Here is an example with Unstructured. I think for now we should/can probably only replace Patch calls with Unstructured

old

err = r.Client.Patch(ctx, u, client.Apply, client.FieldOwner("crdmigrator"))

new

err = r.Client.Apply(ctx, client.ApplyConfigurationFromUnstructured(u), client.FieldOwner("crdmigrator"))

sbueringer avatar Sep 05 '25 14:09 sbueringer

@sivchari I think "Migrate away from GetEventRecorder" once #13159 merges could be an interesting one for you

sbueringer avatar Dec 19 '25 07:12 sbueringer