func NewGroupCache(groupRegistry groupregistry.Registry) *GroupCache { allNamespaceContext := kapi.WithNamespace(kapi.NewContext(), kapi.NamespaceAll) indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{byUserIndexName: ByUserIndexKeys}) reflector := cache.NewReflector( &cache.ListWatch{ ListFunc: func(options kapi.ListOptions) (runtime.Object, error) { opts := &unversioned.ListOptions{ LabelSelector: unversioned.LabelSelector{Selector: options.LabelSelector}, FieldSelector: unversioned.FieldSelector{Selector: options.FieldSelector}, ResourceVersion: options.ResourceVersion, } return groupRegistry.ListGroups(allNamespaceContext, opts) }, WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) { opts := &unversioned.ListOptions{ LabelSelector: unversioned.LabelSelector{Selector: options.LabelSelector}, FieldSelector: unversioned.FieldSelector{Selector: options.FieldSelector}, ResourceVersion: options.ResourceVersion, } return groupRegistry.WatchGroups(allNamespaceContext, opts) }, }, &userapi.Group{}, indexer, // TODO this was chosen via copy/paste. If or when we choose to standardize these in some way, be sure to update this. 2*time.Minute, ) return &GroupCache{ indexer: indexer, reflector: reflector, } }
func NewGroupCache(groupRegistry groupregistry.Registry) *GroupCache { allNamespaceContext := kapi.WithNamespace(kapi.NewContext(), kapi.NamespaceAll) indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{byUserIndexName: ByUserIndexKeys}) reflector := cache.NewReflector( &cache.ListWatch{ ListFunc: func() (runtime.Object, error) { return groupRegistry.ListGroups(allNamespaceContext, labels.Everything(), fields.Everything()) }, WatchFunc: func(resourceVersion string) (watch.Interface, error) { return groupRegistry.WatchGroups(allNamespaceContext, labels.Everything(), fields.Everything(), resourceVersion) }, }, &userapi.Group{}, indexer, // TODO this was chosen via copy/paste. If or when we choose to standardize these in some way, be sure to update this. 2*time.Minute, ) return &GroupCache{ indexer: indexer, reflector: reflector, } }