Skip to content

Commit 56ffb4e

Browse files
committed
Create TransformingIndexerInformer
1 parent efd3490 commit 56ffb4e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

staging/src/k8s.io/client-go/tools/cache/controller.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,27 @@ func NewTransformingInformer(
385385
return clientState, newInformer(lw, objType, resyncPeriod, h, clientState, transformer)
386386
}
387387

388+
// NewTransformingIndexerInformer returns an Indexer and a controller for
389+
// populating the index while also providing event notifications. You should
390+
// only used the returned Index for Get/List operations; Add/Modify/Deletes
391+
// will cause the event notifications to be faulty.
392+
// The given transform function will be called on all objects before they will
393+
// be put into the Index and corresponding Add/Modify/Delete handlers will
394+
// be invoked for them.
395+
func NewTransformingIndexerInformer(
396+
lw ListerWatcher,
397+
objType runtime.Object,
398+
resyncPeriod time.Duration,
399+
h ResourceEventHandler,
400+
indexers Indexers,
401+
transformer TransformFunc,
402+
) (Indexer, Controller) {
403+
// This will hold the client state, as we know it.
404+
clientState := NewIndexer(DeletionHandlingMetaNamespaceKeyFunc, indexers)
405+
406+
return clientState, newInformer(lw, objType, resyncPeriod, h, clientState, transformer)
407+
}
408+
388409
// newInformer returns a controller for populating the store while also
389410
// providing event notifications.
390411
//

0 commit comments

Comments
 (0)