mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #109733 from terloo/master
Unified v1/event NewREST function with other
This commit is contained in:
commit
69cabe778b
@ -35,12 +35,6 @@ type REST struct {
|
|||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against events.
|
// NewREST returns a RESTStorage object that will work against events.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) (*REST, error) {
|
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{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &api.Event{} },
|
NewFunc: func() runtime.Object { return &api.Event{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.EventList{} },
|
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) {
|
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
|
||||||
return ttl, nil
|
return ttl, nil
|
||||||
},
|
},
|
||||||
DefaultQualifiedResource: resource,
|
DefaultQualifiedResource: api.Resource("events"),
|
||||||
|
|
||||||
CreateStrategy: event.Strategy,
|
CreateStrategy: event.Strategy,
|
||||||
UpdateStrategy: 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)},
|
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 {
|
if err := store.CompleteWithOptions(options); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user