mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Rename NewREST -> NewStorage to align on terminology
This commit is contained in:
@@ -38,8 +38,8 @@ type REST struct {
|
||||
etcdgeneric.Etcd
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against pods.
|
||||
func NewREST(h tools.EtcdHelper) (*REST, *BindingREST, *StatusREST) {
|
||||
// NewStorage returns a RESTStorage object that will work against pods.
|
||||
func NewStorage(h tools.EtcdHelper) (*REST, *BindingREST, *StatusREST) {
|
||||
prefix := "/registry/pods"
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &api.Pod{} },
|
||||
|
@@ -69,7 +69,7 @@ func newHelper(t *testing.T) (*tools.FakeEtcdClient, tools.EtcdHelper) {
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *tools.FakeEtcdClient, tools.EtcdHelper) {
|
||||
fakeEtcdClient, h := newHelper(t)
|
||||
storage, bindingStorage, statusStorage := NewREST(h)
|
||||
storage, bindingStorage, statusStorage := NewStorage(h)
|
||||
storage = storage.WithPodStatus(&fakeCache{statusToReturn: &api.PodStatus{}})
|
||||
return storage, bindingStorage, statusStorage, fakeEtcdClient, h
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func TestStorage(t *testing.T) {
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
test := resttest.New(t, storage, fakeEtcdClient.SetError)
|
||||
@@ -132,7 +132,7 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
test := resttest.New(t, storage, fakeEtcdClient.SetError)
|
||||
@@ -170,7 +170,7 @@ func expectPod(t *testing.T, out runtime.Object) (*api.Pod, bool) {
|
||||
func TestCreateRegistryError(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
fakeEtcdClient.Err = fmt.Errorf("test error")
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
|
||||
pod := validNewPod()
|
||||
_, err := storage.Create(api.NewDefaultContext(), pod)
|
||||
@@ -181,7 +181,7 @@ func TestCreateRegistryError(t *testing.T) {
|
||||
|
||||
func TestCreateSetsFields(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
pod := validNewPod()
|
||||
@@ -205,7 +205,7 @@ func TestCreateSetsFields(t *testing.T) {
|
||||
func TestListError(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
fakeEtcdClient.Err = fmt.Errorf("test error")
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
pods, err := storage.List(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
||||
@@ -233,7 +233,7 @@ func TestListCacheError(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{errorToReturn: client.ErrPodInfoNotAvailable}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -258,7 +258,7 @@ func TestListEmptyPodList(t *testing.T) {
|
||||
E: fakeEtcdClient.NewError(tools.EtcdErrorCodeNotFound),
|
||||
}
|
||||
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
pods, err := storage.List(api.NewContext(), labels.Everything(), fields.Everything())
|
||||
@@ -296,7 +296,7 @@ func TestListPodList(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -347,7 +347,7 @@ func TestListPodListSelection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -414,7 +414,7 @@ func TestListPodListSelection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPodDecode(t *testing.T) {
|
||||
storage, _, _ := NewREST(tools.EtcdHelper{})
|
||||
storage, _, _ := NewStorage(tools.EtcdHelper{})
|
||||
expected := validNewPod()
|
||||
body, err := latest.Codec.Encode(expected)
|
||||
if err != nil {
|
||||
@@ -443,7 +443,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -471,7 +471,7 @@ func TestGetCacheError(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{errorToReturn: client.ErrPodInfoNotAvailable}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -491,7 +491,7 @@ func TestGetCacheError(t *testing.T) {
|
||||
func TestPodStorageValidatesCreate(t *testing.T) {
|
||||
fakeEtcdClient, helper := newHelper(t)
|
||||
fakeEtcdClient.Err = fmt.Errorf("test error")
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -511,7 +511,7 @@ func TestPodStorageValidatesCreate(t *testing.T) {
|
||||
// TODO: remove, this is covered by RESTTest.TestCreate
|
||||
func TestCreatePod(t *testing.T) {
|
||||
_, helper := newHelper(t)
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -535,7 +535,7 @@ func TestCreatePod(t *testing.T) {
|
||||
// TODO: remove, this is covered by RESTTest.TestCreate
|
||||
func TestCreateWithConflictingNamespace(t *testing.T) {
|
||||
_, helper := newHelper(t)
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -566,7 +566,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -678,7 +678,7 @@ func TestResourceLocation(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{PodIP: expectedIP}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
@@ -712,7 +712,7 @@ func TestDeletePod(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
storage, _, _ := NewREST(helper)
|
||||
storage, _, _ := NewStorage(helper)
|
||||
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
|
||||
storage = storage.WithPodStatus(cache)
|
||||
|
||||
|
Reference in New Issue
Block a user