Default ObjectNameFunc for all REST Stores
All Stores in Kubernetes follow the same logic for determining the name of an object. This change makes it so that CompleteWithOptions defaults the ObjectNameFunc if it is not specified. Thus a user does not need to remember to use ObjectMeta.Name. Using the wrong field as the name can lead to an object which has a name that bypasses normal object name validation. Signed-off-by: Monis Khan <mkhan@redhat.com>
This commit is contained in:
@@ -43,12 +43,9 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) *REST {
|
||||
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
|
||||
|
||||
store := &genericregistry.Store{
|
||||
Copier: api.Scheme,
|
||||
NewFunc: func() runtime.Object { return &api.Event{} },
|
||||
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*api.Event).Name, nil
|
||||
},
|
||||
Copier: api.Scheme,
|
||||
NewFunc: func() runtime.Object { return &api.Event{} },
|
||||
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
||||
PredicateFunc: event.MatchEvent,
|
||||
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
|
||||
return ttl, nil
|
||||
|
Reference in New Issue
Block a user