diff --git a/pkg/client/fake.go b/pkg/client/fake.go index 306ac06f6f..5105b2f883 100644 --- a/pkg/client/fake.go +++ b/pkg/client/fake.go @@ -66,17 +66,17 @@ func NewFakeClient(objs ...client.Object) FakeClient { } } -func (fc *fakeClient) WithError(verb, resource string, err error) { - fc.fc.PrependReactor(verb, resource, func(action testing.Action) (bool, runtime.Object, error) { - return true, nil, err - }) -} - type fakeClient struct { Client fc *fakeUnderlayClient } +func (fc *fakeClient) WithError(verb, resource string, err error) { + fc.fc.PrependReactor(verb, resource, func(_ testing.Action) (bool, runtime.Object, error) { + return true, nil, err + }) +} + type fakeUnderlayClient struct { testing.Fake tracker testing.ObjectTracker @@ -586,11 +586,10 @@ func (c *fakeUnderlayClient) PatchReactionFunc(action *testing.PatchActionImpl) } case types.ApplyPatchType: patchObj := &unstructured.Unstructured{Object: map[string]any{}} - if err = yaml.Unmarshal(action.GetPatch(), &patchObj.Object); err != nil { + if err := yaml.Unmarshal(action.GetPatch(), &patchObj.Object); err != nil { return true, nil, fmt.Errorf("error decoding YAML: %w", err) } - obj, err = manager.Apply(obj, patchObj, "tidb-operator", true) - if err != nil { + if _, err := manager.Apply(obj, patchObj, "tidb-operator", true); err != nil { return true, nil, err } diff --git a/pkg/controllers/cluster/tasks/finalizer_test.go b/pkg/controllers/cluster/tasks/finalizer_test.go index 282a36cc7b..60923879a6 100644 --- a/pkg/controllers/cluster/tasks/finalizer_test.go +++ b/pkg/controllers/cluster/tasks/finalizer_test.go @@ -44,14 +44,14 @@ func TestFinalizer(t *testing.T) { }, { desc: "removed finalizer", - cluster: fake.FakeObj[v1alpha1.Cluster]("test", - fake.SetDeleteTimestamp[v1alpha1.Cluster](), fake.AddFinalizer[v1alpha1.Cluster]()), + cluster: fake.FakeObj("test", + fake.DeleteNow[v1alpha1.Cluster](), fake.AddFinalizer[v1alpha1.Cluster]()), expected: task.Complete().Break().With("removed finalizer"), }, { desc: "deleting components", - cluster: fake.FakeObj[v1alpha1.Cluster]("test", - fake.SetDeleteTimestamp[v1alpha1.Cluster](), fake.AddFinalizer[v1alpha1.Cluster]()), + cluster: fake.FakeObj("test", + fake.DeleteNow[v1alpha1.Cluster](), fake.AddFinalizer[v1alpha1.Cluster]()), pdGroup: fake.FakeObj[v1alpha1.PDGroup]("pd-group"), expected: task.Fail().With("deleting components"), hasFinalizer: true, diff --git a/pkg/controllers/pd/tasks/ctx.go b/pkg/controllers/pd/tasks/ctx.go index 3d5c0a616e..5a99c0004b 100644 --- a/pkg/controllers/pd/tasks/ctx.go +++ b/pkg/controllers/pd/tasks/ctx.go @@ -49,7 +49,7 @@ type ReconcileContext struct { } func TaskContextInfoFromPD(state *ReconcileContext, cm pdm.PDClientManager) task.Task { - return task.NameTaskFunc("ContextInfoFromPD", func(ctx context.Context) task.Result { + return task.NameTaskFunc("ContextInfoFromPD", func(_ context.Context) task.Result { ck := state.Cluster() pc, ok := cm.Get(pdm.PrimaryKey(ck.Namespace, ck.Name)) if !ok { diff --git a/pkg/controllers/pd/tasks/status.go b/pkg/controllers/pd/tasks/status.go index aa4fce8eac..324a882ba4 100644 --- a/pkg/controllers/pd/tasks/status.go +++ b/pkg/controllers/pd/tasks/status.go @@ -71,7 +71,7 @@ func TaskStatusSuspend(state *ReconcileContext, c client.Client) task.Task { } func TaskStatusUnknown() task.Task { - return task.NameTaskFunc("StatusUnknown", func(ctx context.Context) task.Result { + return task.NameTaskFunc("StatusUnknown", func(_ context.Context) task.Result { return task.Wait().With("status of the pd is unknown") }) }