@@ -28,6 +28,7 @@ import (
28
28
"github.com/sirupsen/logrus"
29
29
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
30
"k8s.io/apimachinery/pkg/runtime"
31
+ "k8s.io/apimachinery/pkg/runtime/schema"
31
32
"k8s.io/apimachinery/pkg/watch"
32
33
"k8s.io/client-go/tools/cache"
33
34
)
@@ -57,6 +58,9 @@ type Informer[T runtime.Object] struct {
57
58
58
59
resType reflect.Type
59
60
61
+ // groupResource is the group and resource of the watched objects.
62
+ groupResource schema.GroupResource
63
+
60
64
// logger is this informer's logger.
61
65
logger * logrus.Entry
62
66
@@ -109,6 +113,13 @@ func NewInformer[T runtime.Object](ctx context.Context, opts ...InformerOption[T
109
113
i := & Informer [T ]{}
110
114
var r T
111
115
i .resType = reflect .TypeOf (r )
116
+
117
+ // groupResource is the group and resource of the watched objects.
118
+ i .groupResource = schema.GroupResource {
119
+ Group : "argoproj.io" ,
120
+ Resource : "applications" ,
121
+ }
122
+
112
123
i .logger = logrus .NewEntry (logrus .StandardLogger ()).WithFields (logrus.Fields {
113
124
"type" : i .resType ,
114
125
"module" : "Informer" ,
@@ -287,3 +298,8 @@ func (i *Informer[T]) WaitForSync(ctx context.Context) error {
287
298
}
288
299
return nil
289
300
}
301
+
302
+ // Lister returns a GenericLister that can be used to list and get cached resources.
303
+ func (i * Informer [T ]) Lister () cache.GenericLister {
304
+ return cache .NewGenericLister (i .informer .GetIndexer (), i .groupResource )
305
+ }
0 commit comments