Decouple apiserver from codec implementation

The apiserver on initialization must be provided with a codec
for encoding and decoding all handled objects including api.Status
and api.ServerOp.  In addition, the RESTStorage Extract() method
has been changed to New(), which returns a pointer object that the
codec must decode into (the internal object).  Switched registry
methods to use pointers for Create/Update instead of values.
This commit is contained in:
Clayton Coleman
2014-08-05 23:10:48 -04:00
parent 4123a44653
commit c9fc0bcf3d
16 changed files with 140 additions and 128 deletions

View File

@@ -24,6 +24,10 @@ import (
// RESTStorage is a generic interface for RESTful storage services
// Resources which are exported to the RESTful API of apiserver need to implement this interface.
type RESTStorage interface {
// New returns an empty object that can be used with Create and Update after request data has been put into it.
// This object must be a pointer type for use with Codec.DecodeInto([]byte, interface{})
New() interface{}
// List selects resources in the storage which match to the selector.
List(labels.Selector) (interface{}, error)
@@ -35,7 +39,6 @@ type RESTStorage interface {
// Although it can return an arbitrary error value, IsNotFound(err) is true for the returned error value err when the specified resource is not found.
Delete(id string) (<-chan interface{}, error)
Extract(body []byte) (interface{}, error)
Create(interface{}) (<-chan interface{}, error)
Update(interface{}) (<-chan interface{}, error)
}