mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Rename runtime.DefaultScheme to latest.Codec for ease of readability
This commit is contained in:
parent
fe614aeda2
commit
154a91cd33
@ -46,8 +46,8 @@ func convert(obj runtime.Object) (runtime.Object, error) {
|
|||||||
var codec = latest.Codec
|
var codec = latest.Codec
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.DefaultScheme.AddKnownTypes("", &Simple{}, &SimpleList{})
|
latest.Codec.AddKnownTypes("", &Simple{}, &SimpleList{})
|
||||||
runtime.DefaultScheme.AddKnownTypes("v1beta1", &Simple{}, &SimpleList{})
|
latest.Codec.AddKnownTypes("v1beta1", &Simple{}, &SimpleList{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Simple struct {
|
type Simple struct {
|
||||||
@ -95,7 +95,7 @@ func (storage *SimpleRESTStorage) List(labels.Selector) (runtime.Object, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Get(id string) (runtime.Object, error) {
|
func (storage *SimpleRESTStorage) Get(id string) (runtime.Object, error) {
|
||||||
return runtime.DefaultScheme.CopyOrDie(&storage.item), storage.errors["get"]
|
return latest.Codec.CopyOrDie(&storage.item), storage.errors["get"]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (storage *SimpleRESTStorage) Delete(id string) (<-chan runtime.Object, error) {
|
func (storage *SimpleRESTStorage) Delete(id string) (<-chan runtime.Object, error) {
|
||||||
|
@ -292,7 +292,7 @@ func TestSyncronize(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fakeControllerHandler := util.FakeHandler{
|
fakeControllerHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: runtime.DefaultScheme.EncodeOrDie(&api.ReplicationControllerList{
|
ResponseBody: latest.Codec.EncodeOrDie(&api.ReplicationControllerList{
|
||||||
Items: []api.ReplicationController{
|
Items: []api.ReplicationController{
|
||||||
controllerSpec1,
|
controllerSpec1,
|
||||||
controllerSpec2,
|
controllerSpec2,
|
||||||
|
@ -125,8 +125,8 @@ type TestParseType struct {
|
|||||||
func (*TestParseType) IsAnAPIObject() {}
|
func (*TestParseType) IsAnAPIObject() {}
|
||||||
|
|
||||||
func TestParseCustomType(t *testing.T) {
|
func TestParseCustomType(t *testing.T) {
|
||||||
runtime.DefaultScheme.AddKnownTypes("", &TestParseType{})
|
latest.Codec.AddKnownTypes("", &TestParseType{})
|
||||||
runtime.DefaultScheme.AddKnownTypes("v1beta1", &TestParseType{})
|
latest.Codec.AddKnownTypes("v1beta1", &TestParseType{})
|
||||||
parser := NewParser(map[string]runtime.Object{
|
parser := NewParser(map[string]runtime.Object{
|
||||||
"custom": &TestParseType{},
|
"custom": &TestParseType{},
|
||||||
})
|
})
|
||||||
|
@ -41,7 +41,7 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
|
|||||||
|
|
||||||
func TestEtcdGetPod(t *testing.T) {
|
func TestEtcdGetPod(t *testing.T) {
|
||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.Set("/registry/pods/foo", runtime.DefaultScheme.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/pods/foo", latest.Codec.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
pod, err := registry.GetPod("foo")
|
pod, err := registry.GetPod("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -77,7 +77,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||||||
},
|
},
|
||||||
E: tools.EtcdErrorNotFound,
|
E: tools.EtcdErrorNotFound,
|
||||||
}
|
}
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.DefaultScheme.EncodeOrDie(&api.ContainerManifestList{}), 0)
|
fakeClient.Set("/registry/hosts/machine/kubelet", latest.Codec.EncodeOrDie(&api.ContainerManifestList{}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
err := registry.CreatePod(&api.Pod{
|
err := registry.CreatePod(&api.Pod{
|
||||||
JSONBase: api.JSONBase{
|
JSONBase: api.JSONBase{
|
||||||
@ -133,7 +133,7 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
|
|||||||
fakeClient.Data["/registry/pods/foo"] = tools.EtcdResponseWithError{
|
fakeClient.Data["/registry/pods/foo"] = tools.EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: latest.Codec.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
E: nil,
|
E: nil,
|
||||||
@ -264,7 +264,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||||||
},
|
},
|
||||||
E: tools.EtcdErrorNotFound,
|
E: tools.EtcdErrorNotFound,
|
||||||
}
|
}
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.DefaultScheme.EncodeOrDie(&api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", latest.Codec.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "bar"},
|
{ID: "bar"},
|
||||||
},
|
},
|
||||||
@ -325,11 +325,11 @@ func TestEtcdDeletePod(t *testing.T) {
|
|||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
|
|
||||||
key := "/registry/pods/foo"
|
key := "/registry/pods/foo"
|
||||||
fakeClient.Set(key, runtime.DefaultScheme.EncodeOrDie(&api.Pod{
|
fakeClient.Set(key, latest.Codec.EncodeOrDie(&api.Pod{
|
||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
DesiredState: api.PodState{Host: "machine"},
|
DesiredState: api.PodState{Host: "machine"},
|
||||||
}), 0)
|
}), 0)
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.DefaultScheme.EncodeOrDie(&api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", latest.Codec.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "foo"},
|
{ID: "foo"},
|
||||||
},
|
},
|
||||||
@ -361,11 +361,11 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
|||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
|
|
||||||
key := "/registry/pods/foo"
|
key := "/registry/pods/foo"
|
||||||
fakeClient.Set(key, runtime.DefaultScheme.EncodeOrDie(&api.Pod{
|
fakeClient.Set(key, latest.Codec.EncodeOrDie(&api.Pod{
|
||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
DesiredState: api.PodState{Host: "machine"},
|
DesiredState: api.PodState{Host: "machine"},
|
||||||
}), 0)
|
}), 0)
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.DefaultScheme.EncodeOrDie(&api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", latest.Codec.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "foo"},
|
{ID: "foo"},
|
||||||
{ID: "bar"},
|
{ID: "bar"},
|
||||||
@ -445,13 +445,13 @@ func TestEtcdListPods(t *testing.T) {
|
|||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Pod{
|
Value: latest.Codec.EncodeOrDie(&api.Pod{
|
||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
DesiredState: api.PodState{Host: "machine"},
|
DesiredState: api.PodState{Host: "machine"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Pod{
|
Value: latest.Codec.EncodeOrDie(&api.Pod{
|
||||||
JSONBase: api.JSONBase{ID: "bar"},
|
JSONBase: api.JSONBase{ID: "bar"},
|
||||||
DesiredState: api.PodState{Host: "machine"},
|
DesiredState: api.PodState{Host: "machine"},
|
||||||
}),
|
}),
|
||||||
@ -520,10 +520,10 @@ func TestEtcdListControllers(t *testing.T) {
|
|||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: latest.Codec.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}),
|
Value: latest.Codec.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -543,7 +543,7 @@ func TestEtcdListControllers(t *testing.T) {
|
|||||||
|
|
||||||
func TestEtcdGetController(t *testing.T) {
|
func TestEtcdGetController(t *testing.T) {
|
||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.Set("/registry/controllers/foo", runtime.DefaultScheme.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/controllers/foo", latest.Codec.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
ctrl, err := registry.GetController("foo")
|
ctrl, err := registry.GetController("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -619,7 +619,7 @@ func TestEtcdCreateController(t *testing.T) {
|
|||||||
|
|
||||||
func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
|
func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
|
||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.Set("/registry/controllers/foo", runtime.DefaultScheme.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/controllers/foo", latest.Codec.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
|
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
err := registry.CreateController(&api.ReplicationController{
|
err := registry.CreateController(&api.ReplicationController{
|
||||||
@ -636,7 +636,7 @@ func TestEtcdUpdateController(t *testing.T) {
|
|||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
|
|
||||||
resp, _ := fakeClient.Set("/registry/controllers/foo", runtime.DefaultScheme.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, _ := fakeClient.Set("/registry/controllers/foo", latest.Codec.EncodeOrDie(&api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
err := registry.UpdateController(&api.ReplicationController{
|
err := registry.UpdateController(&api.ReplicationController{
|
||||||
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
|
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
|
||||||
@ -662,10 +662,10 @@ func TestEtcdListServices(t *testing.T) {
|
|||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: latest.Codec.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "bar"}}),
|
Value: latest.Codec.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -711,7 +711,7 @@ func TestEtcdCreateService(t *testing.T) {
|
|||||||
|
|
||||||
func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.Set("/registry/services/specs/foo", runtime.DefaultScheme.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/services/specs/foo", latest.Codec.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
err := registry.CreateService(&api.Service{
|
err := registry.CreateService(&api.Service{
|
||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
@ -723,7 +723,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
|||||||
|
|
||||||
func TestEtcdGetService(t *testing.T) {
|
func TestEtcdGetService(t *testing.T) {
|
||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.Set("/registry/services/specs/foo", runtime.DefaultScheme.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/services/specs/foo", latest.Codec.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
service, err := registry.GetService("foo")
|
service, err := registry.GetService("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -775,7 +775,7 @@ func TestEtcdUpdateService(t *testing.T) {
|
|||||||
fakeClient := tools.NewFakeEtcdClient(t)
|
fakeClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
|
|
||||||
resp, _ := fakeClient.Set("/registry/services/specs/foo", runtime.DefaultScheme.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, _ := fakeClient.Set("/registry/services/specs/foo", latest.Codec.EncodeOrDie(&api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
registry := NewTestEtcdRegistry(fakeClient)
|
registry := NewTestEtcdRegistry(fakeClient)
|
||||||
testService := api.Service{
|
testService := api.Service{
|
||||||
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
|
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
|
||||||
@ -812,10 +812,10 @@ func TestEtcdListEndpoints(t *testing.T) {
|
|||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
Value: latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "bar"}}),
|
Value: latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -841,7 +841,7 @@ func TestEtcdGetEndpoints(t *testing.T) {
|
|||||||
Endpoints: []string{"127.0.0.1:34855"},
|
Endpoints: []string{"127.0.0.1:34855"},
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeClient.Set("/registry/services/endpoints/foo", runtime.DefaultScheme.EncodeOrDie(endpoints), 0)
|
fakeClient.Set("/registry/services/endpoints/foo", latest.Codec.EncodeOrDie(endpoints), 0)
|
||||||
|
|
||||||
got, err := registry.GetEndpoints("foo")
|
got, err := registry.GetEndpoints("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -862,7 +862,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
|||||||
Endpoints: []string{"baz", "bar"},
|
Endpoints: []string{"baz", "bar"},
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeClient.Set("/registry/services/endpoints/foo", runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{}), 0)
|
fakeClient.Set("/registry/services/endpoints/foo", latest.Codec.EncodeOrDie(&api.Endpoints{}), 0)
|
||||||
|
|
||||||
err := registry.UpdateEndpoints(&endpoints)
|
err := registry.UpdateEndpoints(&endpoints)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -191,7 +191,7 @@ func TestSetObjWithVersion(t *testing.T) {
|
|||||||
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(obj),
|
Value: latest.Codec.EncodeOrDie(obj),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -48,62 +48,62 @@ func TestWatchInterpretations(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
"create": {
|
"create": {
|
||||||
actions: []string{"create", "get"},
|
actions: []string{"create", "get"},
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
nodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Added,
|
expectType: watch.Added,
|
||||||
expectObject: podBar,
|
expectObject: podBar,
|
||||||
},
|
},
|
||||||
"create but filter blocks": {
|
"create but filter blocks": {
|
||||||
actions: []string{"create", "get"},
|
actions: []string{"create", "get"},
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podFoo),
|
nodeValue: latest.Codec.EncodeOrDie(podFoo),
|
||||||
expectEmit: false,
|
expectEmit: false,
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
actions: []string{"delete"},
|
actions: []string{"delete"},
|
||||||
prevNodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
prevNodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Deleted,
|
expectType: watch.Deleted,
|
||||||
expectObject: podBar,
|
expectObject: podBar,
|
||||||
},
|
},
|
||||||
"delete but filter blocks": {
|
"delete but filter blocks": {
|
||||||
actions: []string{"delete"},
|
actions: []string{"delete"},
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podFoo),
|
nodeValue: latest.Codec.EncodeOrDie(podFoo),
|
||||||
expectEmit: false,
|
expectEmit: false,
|
||||||
},
|
},
|
||||||
"modify appears to create 1": {
|
"modify appears to create 1": {
|
||||||
actions: []string{"set", "compareAndSwap"},
|
actions: []string{"set", "compareAndSwap"},
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
nodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Added,
|
expectType: watch.Added,
|
||||||
expectObject: podBar,
|
expectObject: podBar,
|
||||||
},
|
},
|
||||||
"modify appears to create 2": {
|
"modify appears to create 2": {
|
||||||
actions: []string{"set", "compareAndSwap"},
|
actions: []string{"set", "compareAndSwap"},
|
||||||
prevNodeValue: runtime.DefaultScheme.EncodeOrDie(podFoo),
|
prevNodeValue: latest.Codec.EncodeOrDie(podFoo),
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
nodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Added,
|
expectType: watch.Added,
|
||||||
expectObject: podBar,
|
expectObject: podBar,
|
||||||
},
|
},
|
||||||
"modify appears to delete": {
|
"modify appears to delete": {
|
||||||
actions: []string{"set", "compareAndSwap"},
|
actions: []string{"set", "compareAndSwap"},
|
||||||
prevNodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
prevNodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podFoo),
|
nodeValue: latest.Codec.EncodeOrDie(podFoo),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Deleted,
|
expectType: watch.Deleted,
|
||||||
expectObject: podBar, // Should return last state that passed the filter!
|
expectObject: podBar, // Should return last state that passed the filter!
|
||||||
},
|
},
|
||||||
"modify modifies": {
|
"modify modifies": {
|
||||||
actions: []string{"set", "compareAndSwap"},
|
actions: []string{"set", "compareAndSwap"},
|
||||||
prevNodeValue: runtime.DefaultScheme.EncodeOrDie(podBar),
|
prevNodeValue: latest.Codec.EncodeOrDie(podBar),
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podBaz),
|
nodeValue: latest.Codec.EncodeOrDie(podBaz),
|
||||||
expectEmit: true,
|
expectEmit: true,
|
||||||
expectType: watch.Modified,
|
expectType: watch.Modified,
|
||||||
expectObject: podBaz,
|
expectObject: podBaz,
|
||||||
},
|
},
|
||||||
"modify ignores": {
|
"modify ignores": {
|
||||||
actions: []string{"set", "compareAndSwap"},
|
actions: []string{"set", "compareAndSwap"},
|
||||||
nodeValue: runtime.DefaultScheme.EncodeOrDie(podFoo),
|
nodeValue: latest.Codec.EncodeOrDie(podFoo),
|
||||||
expectEmit: false,
|
expectEmit: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ func TestWatchEtcdState(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Action: "create",
|
Action: "create",
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -273,12 +273,12 @@ func TestWatchEtcdState(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Action: "compareAndSwap",
|
Action: "compareAndSwap",
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
},
|
},
|
||||||
PrevNode: &etcd.Node{
|
PrevNode: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
@ -295,7 +295,7 @@ func TestWatchEtcdState(t *testing.T) {
|
|||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Action: "get",
|
Action: "get",
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Action: "compareAndSwap",
|
Action: "compareAndSwap",
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
},
|
},
|
||||||
PrevNode: &etcd.Node{
|
PrevNode: &etcd.Node{
|
||||||
Value: string(runtime.DefaultScheme.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(latest.Codec.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
@ -370,7 +370,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
|
|||||||
EtcdResponseWithError{
|
EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(pod),
|
Value: latest.Codec.EncodeOrDie(pod),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
@ -385,7 +385,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
|
|||||||
EtcdResponseWithError{
|
EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(pod),
|
Value: latest.Codec.EncodeOrDie(pod),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
},
|
},
|
||||||
@ -443,13 +443,13 @@ func TestWatchListFromZeroIndex(t *testing.T) {
|
|||||||
Dir: true,
|
Dir: true,
|
||||||
Nodes: etcd.Nodes{
|
Nodes: etcd.Nodes{
|
||||||
&etcd.Node{
|
&etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(pod),
|
Value: latest.Codec.EncodeOrDie(pod),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
Nodes: etcd.Nodes{},
|
Nodes: etcd.Nodes{},
|
||||||
},
|
},
|
||||||
&etcd.Node{
|
&etcd.Node{
|
||||||
Value: runtime.DefaultScheme.EncodeOrDie(pod),
|
Value: latest.Codec.EncodeOrDie(pod),
|
||||||
CreatedIndex: 2,
|
CreatedIndex: 2,
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
Nodes: etcd.Nodes{},
|
Nodes: etcd.Nodes{},
|
||||||
|
@ -113,7 +113,7 @@ func TestPollMinions(t *testing.T) {
|
|||||||
ml := &api.MinionList{Items: item.minions}
|
ml := &api.MinionList{Items: item.minions}
|
||||||
handler := util.FakeHandler{
|
handler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: runtime.DefaultScheme.EncodeOrDie(ml),
|
ResponseBody: latest.Codec.EncodeOrDie(ml),
|
||||||
T: t,
|
T: t,
|
||||||
}
|
}
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
@ -140,7 +140,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
|||||||
testPod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
testPod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||||
handler := util.FakeHandler{
|
handler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: runtime.DefaultScheme.EncodeOrDie(testPod),
|
ResponseBody: latest.Codec.EncodeOrDie(testPod),
|
||||||
T: t,
|
T: t,
|
||||||
}
|
}
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
@ -259,7 +259,7 @@ func TestBind(t *testing.T) {
|
|||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
expectedBody := runtime.DefaultScheme.EncodeOrDie(item.binding)
|
expectedBody := latest.Codec.EncodeOrDie(item.binding)
|
||||||
handler.ValidateRequest(t, "/api/v1beta1/bindings", "POST", &expectedBody)
|
handler.ValidateRequest(t, "/api/v1beta1/bindings", "POST", &expectedBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ func TestWatch(t *testing.T) {
|
|||||||
client := newEtcdClient()
|
client := newEtcdClient()
|
||||||
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: runtime.DefaultResourceVersioner}
|
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: runtime.DefaultResourceVersioner}
|
||||||
withEtcdKey(func(key string) {
|
withEtcdKey(func(key string) {
|
||||||
resp, err := client.Set(key, runtime.DefaultScheme.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, err := client.Set(key, latest.Codec.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user