From a46f6313bcd32c8479f58878107ee6b468590c22 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 29 Jul 2014 17:35:46 -0400 Subject: [PATCH] Split interfaces --- pkg/apiserver/apiserver.go | 26 -------------------- pkg/apiserver/interfaces.go | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 pkg/apiserver/interfaces.go diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index cfd926c81d0..197c904f0e3 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -61,32 +61,6 @@ func NewNotFoundErr(kind, name string) error { return errNotFound(fmt.Sprintf("%s %q not found", kind, name)) } -// 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 { - // List selects resources in the storage which match to the selector. - List(labels.Selector) (interface{}, error) - - // Get finds a resource in the storage by id and returns it. - // 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. - Get(id string) (interface{}, error) - - // Delete finds a resource in the storage and deletes it. - // 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) -} - -// ResourceWatcher should be implemented by all RESTStorage objects that -// want to offer the ability to watch for changes through the watch api. -type ResourceWatcher interface { - WatchAll() (watch.Interface, error) - WatchSingle(id string) (watch.Interface, error) -} - // APIServer is an HTTPHandler that delegates to RESTStorage objects. // It handles URLs of the form: // ${prefix}/${storage_key}[/${object_name}] diff --git a/pkg/apiserver/interfaces.go b/pkg/apiserver/interfaces.go new file mode 100644 index 00000000000..c268d532a69 --- /dev/null +++ b/pkg/apiserver/interfaces.go @@ -0,0 +1,48 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apiserver + +import ( + "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" + "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" +) + +// 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 { + // List selects resources in the storage which match to the selector. + List(labels.Selector) (interface{}, error) + + // Get finds a resource in the storage by id and returns it. + // 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. + Get(id string) (interface{}, error) + + // Delete finds a resource in the storage and deletes it. + // 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) +} + +// ResourceWatcher should be implemented by all RESTStorage objects that +// want to offer the ability to watch for changes through the watch api. +type ResourceWatcher interface { + WatchAll() (watch.Interface, error) + WatchSingle(id string) (watch.Interface, error) +}