fix: uppercase abbreviation for endpointSlices

This commit is contained in:
defaulterrr 2025-01-10 18:52:23 +03:00
parent bce5d7541c
commit 1bdb178cb0
3 changed files with 8 additions and 8 deletions

View file

@ -23,12 +23,12 @@ import (
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )
type getEpssForServiceFunc = func(key string) ([]*discoveryv1.EndpointSlice, error) type getEPSsForServiceFunc = func(key string) ([]*discoveryv1.EndpointSlice, error)
// EndpointSliceLister makes a Store that lists Endpoints. // EndpointSliceLister makes a Store that lists Endpoints.
type EndpointSliceLister struct { type EndpointSliceLister struct {
cache.Store cache.Store
endpointSliceIndex getEpssForServiceFunc endpointSliceIndex getEPSsForServiceFunc
} }
// MatchByKey returns the EndpointsSlices of the Service matching key in the local Endpoint Store. // MatchByKey returns the EndpointsSlices of the Service matching key in the local Endpoint Store.
@ -44,7 +44,7 @@ func (s *EndpointSliceLister) MatchByKey(key string) ([]*discoveryv1.EndpointSli
return epss, nil return epss, nil
} }
func epssIndexer() cache.Indexers { func newEPSsIndexer() cache.Indexers {
return cache.Indexers{ return cache.Indexers{
discoveryv1.LabelServiceName: func(obj interface{}) ([]string, error) { discoveryv1.LabelServiceName: func(obj interface{}) ([]string, error) {
eps, ok := obj.(*discoveryv1.EndpointSlice) eps, ok := obj.(*discoveryv1.EndpointSlice)
@ -67,7 +67,7 @@ func epssIndexer() cache.Indexers {
} }
} }
func epssForServiceFuncFromIndexer(indexer cache.Indexer) getEppsForServiceFunc { func getEPSsForServiceFuncFromIndexer(indexer cache.Indexer) getEPSsForServiceFunc {
return func(key string) ([]*discoveryv1.EndpointSlice, error) { return func(key string) ([]*discoveryv1.EndpointSlice, error) {
objs, err := indexer.ByIndex(discoveryv1.LabelServiceName, key) objs, err := indexer.ByIndex(discoveryv1.LabelServiceName, key)
if err != nil { if err != nil {

View file

@ -29,11 +29,11 @@ func newEndpointSliceLister(t *testing.T) (*EndpointSliceLister, cache.Indexer)
t.Helper() t.Helper()
store := cache.NewStore(cache.MetaNamespaceKeyFunc) store := cache.NewStore(cache.MetaNamespaceKeyFunc)
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, epssIndexer()) indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, newEPSsIndexer())
return &EndpointSliceLister{ return &EndpointSliceLister{
Store: store, Store: store,
endpointSliceIndex: eppsForServiceFuncFromIndexer(indexer), endpointSliceIndex: getEPSsForServiceFuncFromIndexer(indexer),
}, indexer }, indexer
} }

View file

@ -342,14 +342,14 @@ func New(
store.informers.EndpointSlice = infFactory.Discovery().V1().EndpointSlices().Informer() store.informers.EndpointSlice = infFactory.Discovery().V1().EndpointSlices().Informer()
// Add new endpointslices indexer to markup epps upfront for fast pinpoint retrieval // Add new endpointslices indexer to markup epps upfront for fast pinpoint retrieval
if err := store.informers.EndpointSlice.AddIndexers(epssIndexer()); err != nil { if err := store.informers.EndpointSlice.AddIndexers(newEPSsIndexer()); err != nil {
// This error only occurs due to errors in code, this panic is not possible in runtime // This error only occurs due to errors in code, this panic is not possible in runtime
// if the underlying code is correct. Typically, this error signals conflicts in indexer // if the underlying code is correct. Typically, this error signals conflicts in indexer
panic(fmt.Sprintf("failed to add new index for endpointslices: %v", err)) panic(fmt.Sprintf("failed to add new index for endpointslices: %v", err))
} }
store.listers.EndpointSlice.Store = store.informers.EndpointSlice.GetStore() store.listers.EndpointSlice.Store = store.informers.EndpointSlice.GetStore()
store.listers.EndpointSlice.endpointSliceIndex = eppsForServiceFuncFromIndexer(store.informers.EndpointSlice.GetIndexer()) store.listers.EndpointSlice.endpointSliceIndex = getEPSsForServiceFuncFromIndexer(store.informers.EndpointSlice.GetIndexer())
store.informers.Secret = infFactorySecrets.Core().V1().Secrets().Informer() store.informers.Secret = infFactorySecrets.Core().V1().Secrets().Informer()
store.listers.Secret.Store = store.informers.Secret.GetStore() store.listers.Secret.Store = store.informers.Secret.GetStore()