Skip to content

Commit b19e51a

Browse files
committed
add HasSyncedChecker() required by client-go v0.36.0 for test fake informer implementations
Signed-off-by: jubittajohn <jujohn@redhat.com>
1 parent de2930b commit b19e51a

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

pkg/operator/staticpod/controller/guard/guard_controller_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ type FakeInfrastructureSharedInformer struct {
6262
HasSynced_ bool
6363
}
6464

65+
type fakeSharedIndexInformerDone struct {
66+
synced chan struct{}
67+
}
68+
69+
func (fd *fakeSharedIndexInformerDone) Name() string {
70+
return "FakeSharedIndexInformer"
71+
}
72+
73+
func (fd *fakeSharedIndexInformerDone) Done() <-chan struct{} {
74+
return fd.synced
75+
}
76+
6577
func (i FakeInfrastructureSharedInformer) RemoveEventHandler(handle cache.ResourceEventHandlerRegistration) error {
6678
//TODO implement me
6779
panic("implement me")
@@ -88,7 +100,14 @@ func (i FakeInfrastructureSharedInformer) GetController() cache.Controller {
88100
func (i FakeInfrastructureSharedInformer) Run(stopCh <-chan struct{}) {}
89101
func (i FakeInfrastructureSharedInformer) RunWithContext(ctx context.Context) {}
90102
func (i FakeInfrastructureSharedInformer) HasSynced() bool { return i.HasSynced_ }
91-
func (i FakeInfrastructureSharedInformer) LastSyncResourceVersion() string { return "" }
103+
func (i FakeInfrastructureSharedInformer) HasSyncedChecker() cache.DoneChecker {
104+
ch := make(chan struct{})
105+
if i.HasSynced_ {
106+
close(ch)
107+
}
108+
return &fakeSharedIndexInformerDone{synced: ch}
109+
}
110+
func (i FakeInfrastructureSharedInformer) LastSyncResourceVersion() string { return "" }
92111
func (i FakeInfrastructureSharedInformer) SetWatchErrorHandler(handler cache.WatchErrorHandler) error {
93112
return nil
94113
}

pkg/operator/v1helpers/test_helpers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ func (fakeSharedIndexInformer) HasSynced() bool {
6969
return true
7070
}
7171

72+
type fakeSharedIndexInformerDone struct {
73+
synced chan struct{}
74+
}
75+
76+
func (fd *fakeSharedIndexInformerDone) Name() string {
77+
return "FakeSharedIndexInformer"
78+
}
79+
80+
func (fd *fakeSharedIndexInformerDone) Done() <-chan struct{} {
81+
return fd.synced
82+
}
83+
84+
func (fakeSharedIndexInformer) HasSyncedChecker() cache.DoneChecker {
85+
ch := make(chan struct{})
86+
close(ch)
87+
return &fakeSharedIndexInformerDone{synced: ch}
88+
}
89+
7290
func (fakeSharedIndexInformer) LastSyncResourceVersion() string {
7391
panic("implement me")
7492
}

test/e2e-encryption/encryption_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/stretchr/testify/require"
1414
corev1 "k8s.io/api/core/v1"
1515
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
16-
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
16+
v1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
1717
"k8s.io/apimachinery/pkg/api/errors"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -756,6 +756,24 @@ func (d *lockStepDeployer) HasSynced() bool {
756756
return true
757757
}
758758

759+
type fakeSharedIndexInformerDone struct {
760+
synced chan struct{}
761+
}
762+
763+
func (fd *fakeSharedIndexInformerDone) Name() string {
764+
return "FakeSharedIndexInformer"
765+
}
766+
767+
func (fd *fakeSharedIndexInformerDone) Done() <-chan struct{} {
768+
return fd.synced
769+
}
770+
771+
func (d *lockStepDeployer) HasSyncedChecker() cache.DoneChecker {
772+
ch := make(chan struct{})
773+
close(ch)
774+
return &fakeSharedIndexInformerDone{synced: ch}
775+
}
776+
759777
func (d *lockStepDeployer) DeployedEncryptionConfigSecret(ctx context.Context) (secret *corev1.Secret, converged bool, err error) {
760778
d.lock.Lock()
761779
defer d.lock.Unlock()

0 commit comments

Comments
 (0)