Rename all XStorage types to REST for clarity

This commit is contained in:
Daniel Smith
2014-09-08 14:40:56 -07:00
parent 9954ce6ee7
commit 759c3f9033
13 changed files with 149 additions and 147 deletions

View File

@@ -26,42 +26,42 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
// BindingStorage implements the RESTStorage interface. When bindings are written, it
// REST implements the RESTStorage interface for bindings. When bindings are written, it
// changes the location of the affected pods. This information is eventually reflected
// in the pod's CurrentState.Host field.
type BindingStorage struct {
type REST struct {
registry Registry
}
// NewBindingStorage creates a new BindingStorage backed by the given bindingRegistry.
func NewBindingStorage(bindingRegistry Registry) *BindingStorage {
return &BindingStorage{
// NewREST creates a new REST backed by the given bindingRegistry.
func NewREST(bindingRegistry Registry) *REST {
return &REST{
registry: bindingRegistry,
}
}
// List returns an error because bindings are write-only objects.
func (*BindingStorage) List(selector labels.Selector) (runtime.Object, error) {
func (*REST) List(selector labels.Selector) (runtime.Object, error) {
return nil, errors.NewNotFound("binding", "list")
}
// Get returns an error because bindings are write-only objects.
func (*BindingStorage) Get(id string) (runtime.Object, error) {
func (*REST) Get(id string) (runtime.Object, error) {
return nil, errors.NewNotFound("binding", id)
}
// Delete returns an error because bindings are write-only objects.
func (*BindingStorage) Delete(id string) (<-chan runtime.Object, error) {
func (*REST) Delete(id string) (<-chan runtime.Object, error) {
return nil, errors.NewNotFound("binding", id)
}
// New returns a new binding object fit for having data unmarshalled into it.
func (*BindingStorage) New() runtime.Object {
func (*REST) New() runtime.Object {
return &api.Binding{}
}
// Create attempts to make the assignment indicated by the binding it recieves.
func (b *BindingStorage) Create(obj runtime.Object) (<-chan runtime.Object, error) {
func (b *REST) Create(obj runtime.Object) (<-chan runtime.Object, error) {
binding, ok := obj.(*api.Binding)
if !ok {
return nil, fmt.Errorf("incorrect type: %#v", obj)
@@ -75,6 +75,6 @@ func (b *BindingStorage) Create(obj runtime.Object) (<-chan runtime.Object, erro
}
// Update returns an error-- this object may not be updated.
func (b *BindingStorage) Update(obj runtime.Object) (<-chan runtime.Object, error) {
func (b *REST) Update(obj runtime.Object) (<-chan runtime.Object, error) {
return nil, fmt.Errorf("Bindings may not be changed.")
}

View File

@@ -28,11 +28,11 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
func TestNewBindingStorage(t *testing.T) {
func TestNewREST(t *testing.T) {
mockRegistry := MockRegistry{
OnApplyBinding: func(b *api.Binding) error { return nil },
}
b := NewBindingStorage(mockRegistry)
b := NewREST(mockRegistry)
binding := &api.Binding{
PodID: "foo",
@@ -52,11 +52,11 @@ func TestNewBindingStorage(t *testing.T) {
}
}
func TestBindingStorageUnsupported(t *testing.T) {
func TestRESTUnsupported(t *testing.T) {
mockRegistry := MockRegistry{
OnApplyBinding: func(b *api.Binding) error { return nil },
}
b := NewBindingStorage(mockRegistry)
b := NewREST(mockRegistry)
if _, err := b.Delete("binding id"); err == nil {
t.Errorf("unexpected non-error")
}
@@ -75,7 +75,7 @@ func TestBindingStorageUnsupported(t *testing.T) {
}
}
func TestBindingStoragePost(t *testing.T) {
func TestRESTPost(t *testing.T) {
table := []struct {
b *api.Binding
err error
@@ -94,7 +94,7 @@ func TestBindingStoragePost(t *testing.T) {
return item.err
},
}
b := NewBindingStorage(mockRegistry)
b := NewREST(mockRegistry)
resultChan, err := b.Create(item.b)
if err != nil {
t.Errorf("Unexpected error %v", err)