Skip to content

Commit

Permalink
use single informer
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanHoladay committed Oct 11, 2024
1 parent b4634b9 commit 4b3c860
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pkg/api/resources/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ func NewCache(ctx context.Context, clients *client.Clients) (*Cache, error) {
}
c.dynamicFactory = dynamicInformer.NewFilteredDynamicSharedInformerFactory(dynamicClient, time.Minute*10, metaV1.NamespaceAll, nil)

c.setupUDSCRDInformer()

c.bindCoreResources()
c.bindWorkloadResources()
c.bindUDSResources()
Expand Down Expand Up @@ -146,7 +144,9 @@ func (c *Cache) bindCoreResources() {
Version: "v1",
Resource: "customresourcedefinitions",
}
c.CRDs = NewResourceList(c.dynamicFactory.ForResource(crdGVR).Informer(), crdGVK)
crdInformer := c.dynamicFactory.ForResource(crdGVR).Informer()
c.CRDs = NewResourceList(crdInformer, crdGVK)
c.addExistsListeners(crdInformer)
}

func (c *Cache) bindWorkloadResources() {
Expand Down
10 changes: 2 additions & 8 deletions pkg/api/resources/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ func NewCRDs() *CRDs {
}
}

func (c *Cache) setupUDSCRDInformer() {
crdGVR := schema.GroupVersionResource{
Group: "apiextensions.k8s.io",
Version: "v1",
Resource: "customresourcedefinitions",
}
crdInformer := c.dynamicFactory.ForResource(crdGVR).Informer()
_, err := crdInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
func (c *Cache) addExistsListeners(informer cache.SharedIndexInformer) {
_, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
c.UDSCRDs.addCRD(obj)
notifyDynamicResources(c)
Expand Down

0 comments on commit 4b3c860

Please sign in to comment.