mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 23:19:26 +00:00
Remove unimplemented methods
This commit is contained in:
@@ -20,9 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,21 +38,6 @@ func NewREST(bindingRegistry Registry) *REST {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns an error because bindings are write-only objects.
|
|
||||||
func (*REST) List(ctx api.Context, label, field labels.Selector) (runtime.Object, error) {
|
|
||||||
return nil, errors.NewNotFound("binding", "list")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns an error because bindings are write-only objects.
|
|
||||||
func (*REST) Get(ctx api.Context, id string) (runtime.Object, error) {
|
|
||||||
return nil, errors.NewNotFound("binding", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete returns an error because bindings are write-only objects.
|
|
||||||
func (*REST) Delete(ctx api.Context, id string) (<-chan apiserver.RESTResult, error) {
|
|
||||||
return nil, errors.NewNotFound("binding", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new binding object fit for having data unmarshalled into it.
|
// New returns a new binding object fit for having data unmarshalled into it.
|
||||||
func (*REST) New() runtime.Object {
|
func (*REST) New() runtime.Object {
|
||||||
return &api.Binding{}
|
return &api.Binding{}
|
||||||
@@ -73,8 +56,3 @@ func (b *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RES
|
|||||||
return &api.Status{Status: api.StatusSuccess}, nil
|
return &api.Status{Status: api.StatusSuccess}, nil
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update returns an error-- this object may not be updated.
|
|
||||||
func (b *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
|
|
||||||
return nil, fmt.Errorf("bindings may not be changed.")
|
|
||||||
}
|
|
||||||
|
@@ -24,7 +24,6 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewREST(t *testing.T) {
|
func TestNewREST(t *testing.T) {
|
||||||
@@ -51,30 +50,6 @@ func TestNewREST(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRESTUnsupported(t *testing.T) {
|
|
||||||
var ctx api.Context
|
|
||||||
mockRegistry := MockRegistry{
|
|
||||||
OnApplyBinding: func(b *api.Binding) error { return nil },
|
|
||||||
}
|
|
||||||
b := NewREST(mockRegistry)
|
|
||||||
if _, err := b.Delete(ctx, "binding id"); err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
if _, err := b.Update(ctx, &api.Binding{PodID: "foo", Host: "new machine"}); err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
if _, err := b.Get(ctx, "binding id"); err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
if _, err := b.List(ctx, labels.Set{"name": "foo"}.AsSelector(), labels.Everything()); err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
// Try sending wrong object just to get 100% coverage
|
|
||||||
if _, err := b.Create(ctx, &api.Pod{}); err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRESTPost(t *testing.T) {
|
func TestRESTPost(t *testing.T) {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
b *api.Binding
|
b *api.Binding
|
||||||
|
@@ -96,11 +96,6 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
|||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete satisfies the RESTStorage interface but is unimplemented.
|
|
||||||
func (rs *REST) Delete(ctx api.Context, id string) (<-chan apiserver.RESTResult, error) {
|
|
||||||
return nil, errors.NewBadRequest("Endpoints are read-only")
|
|
||||||
}
|
|
||||||
|
|
||||||
// New implements the RESTStorage interface.
|
// New implements the RESTStorage interface.
|
||||||
func (rs REST) New() runtime.Object {
|
func (rs REST) New() runtime.Object {
|
||||||
return &api.Endpoints{}
|
return &api.Endpoints{}
|
||||||
|
@@ -96,14 +96,3 @@ func TestEndpointsRegistryList(t *testing.T) {
|
|||||||
t.Errorf("Unexpected resource version: %#v", sl)
|
t.Errorf("Unexpected resource version: %#v", sl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpointsRegistryDelete(t *testing.T) {
|
|
||||||
registry := registrytest.NewServiceRegistry()
|
|
||||||
storage := NewREST(registry)
|
|
||||||
_, err := storage.Delete(api.NewContext(), "n/a")
|
|
||||||
if err == nil {
|
|
||||||
t.Error("unexpected non-error")
|
|
||||||
} else if !errors.IsBadRequest(err) {
|
|
||||||
t.Errorf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -131,8 +131,3 @@ func (*REST) New() runtime.Object {
|
|||||||
func (*REST) NewList() runtime.Object {
|
func (*REST) NewList() runtime.Object {
|
||||||
return &api.EventList{}
|
return &api.EventList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update returns an error: Events are not mutable.
|
|
||||||
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
|
|
||||||
return nil, fmt.Errorf("not allowed: 'Event' objects are not mutable")
|
|
||||||
}
|
|
||||||
|
@@ -172,20 +172,6 @@ func TestRESTgetAttrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRESTUpdate(t *testing.T) {
|
|
||||||
_, rest := NewTestREST()
|
|
||||||
eventA := testEvent("foo")
|
|
||||||
c, err := rest.Create(api.NewDefaultContext(), eventA)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Unexpected error %v", err)
|
|
||||||
}
|
|
||||||
<-c
|
|
||||||
_, err = rest.Update(api.NewDefaultContext(), eventA)
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("unexpected non-error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRESTList(t *testing.T) {
|
func TestRESTList(t *testing.T) {
|
||||||
reg, rest := NewTestREST()
|
reg, rest := NewTestREST()
|
||||||
eventA := &api.Event{
|
eventA := &api.Event{
|
||||||
|
Reference in New Issue
Block a user