Merge pull request #109733 from terloo/master

Unified v1/event NewREST function with other
This commit is contained in:
Kubernetes Prow Robot 2022-05-15 06:06:16 -07:00 committed by GitHub
commit 69cabe778b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,12 +35,6 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against events.
func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) (*REST, error) {
resource := api.Resource("events")
opts, err := optsGetter.GetRESTOptions(resource)
if err != nil {
return nil, err
}
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &api.Event{} },
NewListFunc: func() runtime.Object { return &api.EventList{} },
@ -48,7 +42,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) (*REST, error) {
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
return ttl, nil
},
DefaultQualifiedResource: resource,
DefaultQualifiedResource: api.Resource("events"),
CreateStrategy: event.Strategy,
UpdateStrategy: event.Strategy,
@ -56,7 +50,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) (*REST, error) {
TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)},
}
options := &generic.StoreOptions{RESTOptions: opts, AttrFunc: event.GetAttrs} // Pass in opts to use UndecoratedStorage
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: event.GetAttrs}
if err := store.CompleteWithOptions(options); err != nil {
return nil, err
}