diff --git a/pkg/registry/core/node/storage/storage.go b/pkg/registry/core/node/storage/storage.go index a073832c35a..fa15b058013 100644 --- a/pkg/registry/core/node/storage/storage.go +++ b/pkg/registry/core/node/storage/storage.go @@ -93,7 +93,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, kubeletClientConfig client options := &generic.StoreOptions{ RESTOptions: optsGetter, AttrFunc: node.GetAttrs, - TriggerFunc: map[string]storage.TriggerPublisherFunc{"metadata.name": node.NodeNameTriggerFunc}, + TriggerFunc: map[string]storage.IndexerFunc{"metadata.name": node.NodeNameTriggerFunc}, } if err := store.CompleteWithOptions(options); err != nil { return nil, err diff --git a/pkg/registry/core/pod/storage/storage.go b/pkg/registry/core/pod/storage/storage.go index e268c46268b..ee04706f0b4 100644 --- a/pkg/registry/core/pod/storage/storage.go +++ b/pkg/registry/core/pod/storage/storage.go @@ -81,7 +81,7 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet options := &generic.StoreOptions{ RESTOptions: optsGetter, AttrFunc: pod.GetAttrs, - TriggerFunc: map[string]storage.TriggerPublisherFunc{"spec.nodeName": pod.NodeNameTriggerFunc}, + TriggerFunc: map[string]storage.IndexerFunc{"spec.nodeName": pod.NodeNameTriggerFunc}, } if err := store.CompleteWithOptions(options); err != nil { panic(err) // TODO: Propagate error up diff --git a/pkg/registry/core/secret/storage/storage.go b/pkg/registry/core/secret/storage/storage.go index b27b5c012bb..6cb2d5eb8d7 100644 --- a/pkg/registry/core/secret/storage/storage.go +++ b/pkg/registry/core/secret/storage/storage.go @@ -50,7 +50,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST { options := &generic.StoreOptions{ RESTOptions: optsGetter, AttrFunc: secret.GetAttrs, - TriggerFunc: map[string]storage.TriggerPublisherFunc{"metadata.name": secret.SecretNameTriggerFunc}, + TriggerFunc: map[string]storage.IndexerFunc{"metadata.name": secret.SecretNameTriggerFunc}, } if err := store.CompleteWithOptions(options); err != nil { panic(err) // TODO: Propagate error up diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/options.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/options.go index fb9adba1ab0..907928a356e 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/options.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/options.go @@ -47,6 +47,6 @@ type RESTOptionsGetter interface { // StoreOptions is set of configuration options used to complete generic registries. type StoreOptions struct { RESTOptions RESTOptionsGetter - TriggerFunc storage.TriggerPublisherFuncs + TriggerFunc storage.IndexerFuncs AttrFunc storage.AttrFunc } diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/storage_factory.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/storage_factory.go index acefc238689..7fb785a5b75 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/storage_factory.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/storage_factory.go @@ -39,7 +39,7 @@ func StorageWithCacher(capacity int) generic.StorageDecorator { newFunc func() runtime.Object, newListFunc func() runtime.Object, getAttrsFunc storage.AttrFunc, - triggerFuncs storage.TriggerPublisherFuncs) (storage.Interface, factory.DestroyFunc, error) { + triggerFuncs storage.IndexerFuncs) (storage.Interface, factory.DestroyFunc, error) { s, d, err := generic.NewRawStorage(storageConfig) if err != nil { @@ -56,16 +56,16 @@ func StorageWithCacher(capacity int) generic.StorageDecorator { // TODO: we would change this later to make storage always have cacher and hide low level KV layer inside. // Currently it has two layers of same storage interface -- cacher and low level kv. cacherConfig := cacherstorage.Config{ - CacheCapacity: capacity, - Storage: s, - Versioner: etcd3.APIObjectVersioner{}, - ResourcePrefix: resourcePrefix, - KeyFunc: keyFunc, - NewFunc: newFunc, - NewListFunc: newListFunc, - GetAttrsFunc: getAttrsFunc, - TriggerPublisherFuncs: triggerFuncs, - Codec: storageConfig.Codec, + CacheCapacity: capacity, + Storage: s, + Versioner: etcd3.APIObjectVersioner{}, + ResourcePrefix: resourcePrefix, + KeyFunc: keyFunc, + NewFunc: newFunc, + NewListFunc: newListFunc, + GetAttrsFunc: getAttrsFunc, + IndexerFuncs: triggerFuncs, + Codec: storageConfig.Codec, } cacher, err := cacherstorage.NewCacherFromConfig(cacherConfig) if err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/registry/generic/storage_decorator.go b/staging/src/k8s.io/apiserver/pkg/registry/generic/storage_decorator.go index 1c553413efa..993f21200f0 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/generic/storage_decorator.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/generic/storage_decorator.go @@ -32,7 +32,7 @@ type StorageDecorator func( newFunc func() runtime.Object, newListFunc func() runtime.Object, getAttrsFunc storage.AttrFunc, - trigger storage.TriggerPublisherFuncs) (storage.Interface, factory.DestroyFunc, error) + trigger storage.IndexerFuncs) (storage.Interface, factory.DestroyFunc, error) // UndecoratedStorage returns the given a new storage from the given config // without any decoration. @@ -43,7 +43,7 @@ func UndecoratedStorage( newFunc func() runtime.Object, newListFunc func() runtime.Object, getAttrsFunc storage.AttrFunc, - trigger storage.TriggerPublisherFuncs) (storage.Interface, factory.DestroyFunc, error) { + trigger storage.IndexerFuncs) (storage.Interface, factory.DestroyFunc, error) { return NewRawStorage(config) } diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index 2b701084db4..2fa49efafff 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -88,9 +88,9 @@ type Config struct { // GetAttrsFunc is used to get object labels, fields GetAttrsFunc func(runtime.Object) (label labels.Set, field fields.Set, err error) - // TriggerPublisherFuncs is used for optimizing amount of watchers that + // IndexerFuncs is used for optimizing amount of watchers that // needs to process an incoming event. - TriggerPublisherFuncs storage.TriggerPublisherFuncs + IndexerFuncs storage.IndexerFuncs // NewFunc is a function that creates new empty object storing a object of type Type. NewFunc func() runtime.Object @@ -211,7 +211,7 @@ type filterWithAttrsFunc func(key string, l labels.Set, f fields.Set) bool type indexedTriggerFunc struct { indexName string - triggerFunc storage.TriggerPublisherFunc + indexerFunc storage.IndexerFunc } // Cacher is responsible for serving WATCH and LIST requests for a given @@ -306,17 +306,17 @@ func NewCacherFromConfig(config Config) (*Cacher, error) { } var indexedTrigger *indexedTriggerFunc - if config.TriggerPublisherFuncs != nil { + if config.IndexerFuncs != nil { // For now, we don't support multiple trigger functions defined // for a given resource. - if len(config.TriggerPublisherFuncs) > 1 { - return nil, fmt.Errorf("cacher %s doesn't support more than one TriggerPublisherFunc: ", reflect.TypeOf(obj).String()) + if len(config.IndexerFuncs) > 1 { + return nil, fmt.Errorf("cacher %s doesn't support more than one IndexerFunc: ", reflect.TypeOf(obj).String()) } - for key, value := range config.TriggerPublisherFuncs { + for key, value := range config.IndexerFuncs { if value != nil { indexedTrigger = &indexedTriggerFunc{ indexName: key, - triggerFunc: value, + indexerFunc: value, } } } @@ -742,11 +742,11 @@ func (c *Cacher) triggerValues(event *watchCacheEvent) ([]string, bool) { } result := make([]string, 0, 2) - result = append(result, c.indexedTrigger.triggerFunc(event.Object)) + result = append(result, c.indexedTrigger.indexerFunc(event.Object)) if event.PrevObject == nil { return result, true } - prevTriggerValue := c.indexedTrigger.triggerFunc(event.PrevObject) + prevTriggerValue := c.indexedTrigger.indexerFunc(event.PrevObject) if result[0] != prevTriggerValue { result = append(result, prevTriggerValue) } diff --git a/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go b/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go index c850b248439..f5d3b3ea789 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go @@ -73,15 +73,13 @@ type ResponseMeta struct { ResourceVersion uint64 } -// TriggerPublisherFunc is a function that for a given object computes +// IndexerFunc is a function that for a given object computes // for a particular . -// TODO(wojtek-t): Rename to IndexerFunc? -type TriggerPublisherFunc func(obj runtime.Object) string +type IndexerFunc func(obj runtime.Object) string -// TriggerPublisherFuncs is a mapping from to function that +// IndexerFuncs is a mapping from to function that // for a given object computes . -// TODO(wojtek-t): Rename to IndexerFuncs? -type TriggerPublisherFuncs map[string]TriggerPublisherFunc +type IndexerFuncs map[string]IndexerFunc // Everything accepts all objects. var Everything = SelectionPredicate{