🌱 use SDK basecontroller for better logging. (#1269)

* Use basecontroller in sdk-go instead for better logging

Signed-off-by: Jian Qiu <jqiu@redhat.com>

* Rename to fakeSyncContext

Signed-off-by: Jian Qiu <jqiu@redhat.com>

---------

Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
Jian Qiu
2025-12-01 11:07:02 +08:00
committed by GitHub
parent 26edb9423a
commit 33310619d9
199 changed files with 794 additions and 3268 deletions

View File

@@ -3,44 +3,24 @@ package testing
import (
"testing"
openshiftevents "github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/events/eventstesting"
"k8s.io/client-go/util/workqueue"
sdkevents "open-cluster-management.io/sdk-go/pkg/basecontroller/events"
)
type FakeSyncContext struct {
spokeName string
recorder openshiftevents.Recorder
queue workqueue.RateLimitingInterface
}
func (f FakeSyncContext) Queue() workqueue.RateLimitingInterface { return f.queue }
func (f FakeSyncContext) QueueKey() string { return f.spokeName }
func (f FakeSyncContext) Recorder() openshiftevents.Recorder { return f.recorder }
func NewFakeSyncContext(t *testing.T, clusterName string) *FakeSyncContext {
return &FakeSyncContext{
spokeName: clusterName,
recorder: eventstesting.NewTestingEventRecorder(t),
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
}
}
type FakeSDKSyncContext struct {
spokeName string
recorder sdkevents.Recorder
queue workqueue.TypedRateLimitingInterface[string]
}
func (f FakeSDKSyncContext) Queue() workqueue.TypedRateLimitingInterface[string] { return f.queue }
func (f FakeSDKSyncContext) Recorder() sdkevents.Recorder {
func (f FakeSyncContext) Queue() workqueue.TypedRateLimitingInterface[string] { return f.queue }
func (f FakeSyncContext) Recorder() sdkevents.Recorder {
return f.recorder
}
func NewFakeSDKSyncContext(t *testing.T, clusterName string) *FakeSDKSyncContext {
return &FakeSDKSyncContext{
func NewFakeSyncContext(t *testing.T, clusterName string) *FakeSyncContext {
return &FakeSyncContext{
spokeName: clusterName,
recorder: sdkevents.NewContextualLoggingEventRecorder(t.Name()),
queue: workqueue.NewTypedRateLimitingQueue[string](workqueue.DefaultTypedControllerRateLimiter[string]()),