mirror of https://github.com/k3s-io/k3s
Simple refactor for ease of readability
runtime.DefaultCodec -> latest.Codecpull/6/head
parent
10f68902f6
commit
fe614aeda2
|
@ -129,7 +129,7 @@ func readConfig(storage string) []byte {
|
|||
glog.Fatal("Need config file (-c)")
|
||||
}
|
||||
|
||||
data, err := parser.ToWireFormat(readConfigData(), storage, runtime.DefaultCodec)
|
||||
data, err := parser.ToWireFormat(readConfigData(), storage, latest.Codec)
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Error parsing %v as an object for %v: %v\n", *config, storage, err)
|
||||
|
@ -296,7 +296,7 @@ func executeAPIRequest(method string, c *client.Client) bool {
|
|||
if setBody {
|
||||
if version != 0 {
|
||||
data := readConfig(storage)
|
||||
obj, err := runtime.DefaultCodec.Decode(data)
|
||||
obj, err := latest.Codec.Decode(data)
|
||||
if err != nil {
|
||||
glog.Fatalf("error setting resource version: %v", err)
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ func executeAPIRequest(method string, c *client.Client) bool {
|
|||
glog.Fatalf("error setting resource version: %v", err)
|
||||
}
|
||||
jsonBase.SetResourceVersion(version)
|
||||
data, err = runtime.DefaultCodec.Encode(obj)
|
||||
data, err = latest.Codec.Encode(obj)
|
||||
if err != nil {
|
||||
glog.Fatalf("error setting resource version: %v", err)
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ func TestApiExamples(t *testing.T) {
|
|||
return
|
||||
}
|
||||
tested += 1
|
||||
if err := runtime.DefaultCodec.DecodeInto(data, expectedType); err != nil {
|
||||
if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func TestExamples(t *testing.T) {
|
|||
return
|
||||
}
|
||||
tested += 1
|
||||
if err := runtime.DefaultCodec.DecodeInto(data, expectedType); err != nil {
|
||||
if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
|
@ -168,14 +168,14 @@ func TestReadme(t *testing.T) {
|
|||
}
|
||||
for _, json := range match[1:] {
|
||||
expectedType := &api.Pod{}
|
||||
if err := runtime.DefaultCodec.DecodeInto([]byte(json), expectedType); err != nil {
|
||||
if err := latest.Codec.DecodeInto([]byte(json), expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
}
|
||||
encoded, err := runtime.DefaultCodec.Encode(expectedType)
|
||||
encoded, err := latest.Codec.Encode(expectedType)
|
||||
if err != nil {
|
||||
t.Errorf("Could not encode object: %v", err)
|
||||
continue
|
||||
|
|
|
@ -135,13 +135,13 @@ func runTest(t *testing.T, source runtime.Object) {
|
|||
j.SetKind("")
|
||||
j.SetAPIVersion("")
|
||||
|
||||
data, err := runtime.DefaultCodec.Encode(source)
|
||||
data, err := latest.Codec.Encode(source)
|
||||
if err != nil {
|
||||
t.Errorf("%v: %v (%#v)", name, err, source)
|
||||
return
|
||||
}
|
||||
|
||||
obj2, err := runtime.DefaultCodec.Decode(data)
|
||||
obj2, err := latest.Codec.Decode(data)
|
||||
if err != nil {
|
||||
t.Errorf("%v: %v", name, err)
|
||||
return
|
||||
|
@ -152,7 +152,7 @@ func runTest(t *testing.T, source runtime.Object) {
|
|||
}
|
||||
}
|
||||
obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface().(runtime.Object)
|
||||
err = runtime.DefaultCodec.DecodeInto(data, obj3)
|
||||
err = latest.Codec.DecodeInto(data, obj3)
|
||||
if err != nil {
|
||||
t.Errorf("2: %v: %v", name, err)
|
||||
return
|
||||
|
@ -194,8 +194,8 @@ func TestEncode_Ptr(t *testing.T) {
|
|||
Labels: map[string]string{"name": "foo"},
|
||||
}
|
||||
obj := runtime.Object(pod)
|
||||
data, err := runtime.DefaultCodec.Encode(obj)
|
||||
obj2, err2 := runtime.DefaultCodec.Decode(data)
|
||||
data, err := latest.Codec.Encode(obj)
|
||||
obj2, err2 := latest.Codec.Decode(data)
|
||||
if err != nil || err2 != nil {
|
||||
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
||||
}
|
||||
|
@ -209,11 +209,11 @@ func TestEncode_Ptr(t *testing.T) {
|
|||
|
||||
func TestBadJSONRejection(t *testing.T) {
|
||||
badJSONMissingKind := []byte(`{ }`)
|
||||
if _, err := runtime.DefaultCodec.Decode(badJSONMissingKind); err == nil {
|
||||
if _, err := latest.Codec.Decode(badJSONMissingKind); err == nil {
|
||||
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
|
||||
}
|
||||
badJSONUnknownType := []byte(`{"kind": "bar"}`)
|
||||
if _, err1 := runtime.DefaultCodec.Decode(badJSONUnknownType); err1 == nil {
|
||||
if _, err1 := latest.Codec.Decode(badJSONUnknownType); err1 == nil {
|
||||
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
|
||||
}
|
||||
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)
|
||||
|
|
|
@ -43,7 +43,7 @@ func convert(obj runtime.Object) (runtime.Object, error) {
|
|||
return obj, nil
|
||||
}
|
||||
|
||||
var codec = runtime.DefaultCodec
|
||||
var codec = latest.Codec
|
||||
|
||||
func init() {
|
||||
runtime.DefaultScheme.AddKnownTypes("", &Simple{}, &SimpleList{})
|
||||
|
@ -676,7 +676,7 @@ func (*UnregisteredAPIObject) IsAnAPIObject() {}
|
|||
|
||||
func TestWriteJSONDecodeError(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
writeJSON(http.StatusOK, runtime.DefaultCodec, &UnregisteredAPIObject{"Undecodable"}, w)
|
||||
writeJSON(http.StatusOK, latest.Codec, &UnregisteredAPIObject{"Undecodable"}, w)
|
||||
}))
|
||||
status := expectApiStatus(t, "GET", server.URL, nil, http.StatusInternalServerError)
|
||||
if status.Reason != api.StatusReasonUnknown {
|
||||
|
|
|
@ -99,7 +99,7 @@ type Client struct {
|
|||
// to a URL will prepend the server path. Returns an error if host cannot be converted to a
|
||||
// valid URL.
|
||||
func New(host string, auth *AuthInfo) (*Client, error) {
|
||||
restClient, err := NewRESTClient(host, auth, "/api/v1beta1/", runtime.DefaultCodec)
|
||||
restClient, err := NewRESTClient(host, auth, "/api/v1beta1/", latest.Codec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ func (c *RESTClient) doRequest(request *http.Request) ([]byte, error) {
|
|||
// Did the server give us a status response?
|
||||
isStatusResponse := false
|
||||
var status api.Status
|
||||
if err := runtime.DefaultCodec.DecodeInto(body, &status); err == nil && status.Status != "" {
|
||||
if err := latest.Codec.DecodeInto(body, &status); err == nil && status.Status != "" {
|
||||
isStatusResponse = true
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestValidatesHostParameter(t *testing.T) {
|
|||
"host/server": {"", "", true},
|
||||
}
|
||||
for k, expected := range testCases {
|
||||
c, err := NewRESTClient(k, nil, "/api/v1beta1/", runtime.DefaultCodec)
|
||||
c, err := NewRESTClient(k, nil, "/api/v1beta1/", latest.Codec)
|
||||
switch {
|
||||
case err == nil && expected.Err:
|
||||
t.Errorf("expected error but was nil")
|
||||
|
@ -309,7 +309,7 @@ func TestCreateController(t *testing.T) {
|
|||
|
||||
func body(obj runtime.Object, raw *string) *string {
|
||||
if obj != nil {
|
||||
bs, _ := runtime.DefaultCodec.Encode(obj)
|
||||
bs, _ := latest.Codec.Encode(obj)
|
||||
body := string(bs)
|
||||
return &body
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ func TestDoRequest(t *testing.T) {
|
|||
|
||||
func TestDoRequestAccepted(t *testing.T) {
|
||||
status := &api.Status{Status: api.StatusWorking}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(status)
|
||||
expectedBody, _ := latest.Codec.Encode(status)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 202,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -570,7 +570,7 @@ func TestDoRequestAccepted(t *testing.T) {
|
|||
|
||||
func TestDoRequestAcceptedSuccess(t *testing.T) {
|
||||
status := &api.Status{Status: api.StatusSuccess}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(status)
|
||||
expectedBody, _ := latest.Codec.Encode(status)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 202,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -590,7 +590,7 @@ func TestDoRequestAcceptedSuccess(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("Unexpected error %#v", err)
|
||||
}
|
||||
statusOut, err := runtime.DefaultCodec.Decode(body)
|
||||
statusOut, err := latest.Codec.Decode(body)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error %#v", err)
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import (
|
|||
func TestDoRequestNewWay(t *testing.T) {
|
||||
reqBody := "request body"
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(expectedObj)
|
||||
expectedBody, _ := latest.Codec.Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -71,9 +71,9 @@ func TestDoRequestNewWay(t *testing.T) {
|
|||
|
||||
func TestDoRequestNewWayReader(t *testing.T) {
|
||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||
reqBodyExpected, _ := runtime.DefaultCodec.Encode(reqObj)
|
||||
reqBodyExpected, _ := latest.Codec.Encode(reqObj)
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(expectedObj)
|
||||
expectedBody, _ := latest.Codec.Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -108,9 +108,9 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
|||
|
||||
func TestDoRequestNewWayObj(t *testing.T) {
|
||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||
reqBodyExpected, _ := runtime.DefaultCodec.Encode(reqObj)
|
||||
reqBodyExpected, _ := latest.Codec.Encode(reqObj)
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(expectedObj)
|
||||
expectedBody, _ := latest.Codec.Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -144,7 +144,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
|||
|
||||
func TestDoRequestNewWayFile(t *testing.T) {
|
||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||
reqBodyExpected, err := runtime.DefaultCodec.Encode(reqObj)
|
||||
reqBodyExpected, err := latest.Codec.Encode(reqObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedObj := &api.Service{Port: 12345}
|
||||
expectedBody, _ := runtime.DefaultCodec.Encode(expectedObj)
|
||||
expectedBody, _ := latest.Codec.Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
|
@ -295,7 +295,7 @@ func TestPolling(t *testing.T) {
|
|||
|
||||
callNumber := 0
|
||||
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := runtime.DefaultCodec.Encode(objects[callNumber])
|
||||
data, err := latest.Codec.Encode(objects[callNumber])
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected encode error")
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func validateSyncReplication(t *testing.T, fakePodControl *FakePodControl, expec
|
|||
}
|
||||
|
||||
func TestSyncReplicationControllerDoesNothing(t *testing.T) {
|
||||
body, _ := runtime.DefaultCodec.Encode(newPodList(2))
|
||||
body, _ := latest.Codec.Encode(newPodList(2))
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(body),
|
||||
|
@ -129,7 +129,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSyncReplicationControllerDeletes(t *testing.T) {
|
||||
body, _ := runtime.DefaultCodec.Encode(newPodList(2))
|
||||
body, _ := latest.Codec.Encode(newPodList(2))
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(body),
|
||||
|
@ -149,7 +149,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSyncReplicationControllerCreates(t *testing.T) {
|
||||
body, _ := runtime.DefaultCodec.Encode(newPodList(0))
|
||||
body, _ := latest.Codec.Encode(newPodList(0))
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(body),
|
||||
|
@ -169,7 +169,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateReplica(t *testing.T) {
|
||||
body, _ := runtime.DefaultCodec.Encode(&api.Pod{})
|
||||
body, _ := latest.Codec.Encode(&api.Pod{})
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(body),
|
||||
|
|
|
@ -27,21 +27,21 @@ import (
|
|||
|
||||
func TestParseBadStorage(t *testing.T) {
|
||||
p := NewParser(map[string]runtime.Object{})
|
||||
_, err := p.ToWireFormat([]byte("{}"), "badstorage", runtime.DefaultCodec)
|
||||
_, err := p.ToWireFormat([]byte("{}"), "badstorage", latest.Codec)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error, received none")
|
||||
}
|
||||
}
|
||||
|
||||
func DoParseTest(t *testing.T, storage string, obj runtime.Object, p *Parser) {
|
||||
jsonData, _ := runtime.DefaultCodec.Encode(obj)
|
||||
jsonData, _ := latest.Codec.Encode(obj)
|
||||
var tmp map[string]interface{}
|
||||
json.Unmarshal(jsonData, &tmp)
|
||||
yamlData, _ := yaml.Marshal(tmp)
|
||||
t.Logf("Intermediate yaml:\n%v\n", string(yamlData))
|
||||
t.Logf("Intermediate json:\n%v\n", string(jsonData))
|
||||
jsonGot, jsonErr := p.ToWireFormat(jsonData, storage, runtime.DefaultCodec)
|
||||
yamlGot, yamlErr := p.ToWireFormat(yamlData, storage, runtime.DefaultCodec)
|
||||
jsonGot, jsonErr := p.ToWireFormat(jsonData, storage, latest.Codec)
|
||||
yamlGot, yamlErr := p.ToWireFormat(yamlData, storage, latest.Codec)
|
||||
|
||||
if jsonErr != nil {
|
||||
t.Errorf("json err: %#v", jsonErr)
|
||||
|
|
|
@ -53,7 +53,7 @@ func (s *ProxyServer) Serve() error {
|
|||
func (s *ProxyServer) doError(w http.ResponseWriter, err error) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Header().Add("Content-type", "application/json")
|
||||
data, _ := runtime.DefaultCodec.Encode(&api.Status{
|
||||
data, _ := latest.Codec.Encode(&api.Status{
|
||||
Status: api.StatusFailure,
|
||||
Message: fmt.Sprintf("internal error: %#v", err),
|
||||
})
|
||||
|
|
|
@ -50,7 +50,7 @@ func (i *IdentityPrinter) Print(data []byte, w io.Writer) error {
|
|||
|
||||
// PrintObj is an implementation of ResourcePrinter.PrintObj which simply writes the object to the Writer.
|
||||
func (i *IdentityPrinter) PrintObj(obj runtime.Object, output io.Writer) error {
|
||||
data, err := runtime.DefaultCodec.Encode(obj)
|
||||
data, err := latest.Codec.Encode(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (h *HumanReadablePrinter) Print(data []byte, output io.Writer) error {
|
|||
return fmt.Errorf("unexpected object with no 'kind' field: %s", data)
|
||||
}
|
||||
|
||||
obj, err := runtime.DefaultCodec.Decode(data)
|
||||
obj, err := latest.Codec.Decode(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ type TemplatePrinter struct {
|
|||
|
||||
// Print parses the data as JSON, and re-formats it with the Go Template.
|
||||
func (t *TemplatePrinter) Print(data []byte, w io.Writer) error {
|
||||
obj, err := runtime.DefaultCodec.Decode(data)
|
||||
obj, err := latest.Codec.Decode(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestIdentityPrinter(t *testing.T) {
|
|||
}
|
||||
buff.Reset()
|
||||
printer.PrintObj(obj, buff)
|
||||
objOut, err := runtime.DefaultCodec.Decode([]byte(buff.String()))
|
||||
objOut, err := latest.Codec.Decode([]byte(buff.String()))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpeted error: %#v", err)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ type SourceEtcd struct {
|
|||
func NewSourceEtcd(key string, client tools.EtcdClient, updates chan<- interface{}) *SourceEtcd {
|
||||
helper := tools.EtcdHelper{
|
||||
client,
|
||||
runtime.DefaultCodec,
|
||||
latest.Codec,
|
||||
runtime.DefaultResourceVersioner,
|
||||
}
|
||||
source := &SourceEtcd{
|
||||
|
|
|
@ -135,7 +135,7 @@ func (s ConfigSourceEtcd) GetServices() ([]api.Service, []api.Endpoints, error)
|
|||
// and create a Service entry for it.
|
||||
for i, node := range response.Node.Nodes {
|
||||
var svc api.Service
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(node.Value), &svc)
|
||||
err = latest.Codec.DecodeInto([]byte(node.Value), &svc)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to load Service: %s (%#v)", node.Value, err)
|
||||
continue
|
||||
|
@ -168,7 +168,7 @@ func (s ConfigSourceEtcd) GetEndpoints(service string) (api.Endpoints, error) {
|
|||
}
|
||||
// Parse all the endpoint specifications in this value.
|
||||
var e api.Endpoints
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &e)
|
||||
err = latest.Codec.DecodeInto([]byte(response.Node.Value), &e)
|
||||
return e, err
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ func etcdResponseToService(response *etcd.Response) (*api.Service, error) {
|
|||
return nil, fmt.Errorf("invalid response from etcd: %#v", response)
|
||||
}
|
||||
var svc api.Service
|
||||
err := runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &svc)
|
||||
err := latest.Codec.DecodeInto([]byte(response.Node.Value), &svc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
|
|||
func (s ConfigSourceEtcd) ProcessEndpointResponse(response *etcd.Response) {
|
||||
glog.Infof("Processing a change in endpoint configuration... %s", *response)
|
||||
var endpoints api.Endpoints
|
||||
err := runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &endpoints)
|
||||
err := latest.Codec.DecodeInto([]byte(response.Node.Value), &endpoints)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to parse service out of etcd key: %v : %+v", response.Node.Value, err)
|
||||
return
|
||||
|
|
|
@ -38,12 +38,12 @@ func TestNewREST(t *testing.T) {
|
|||
PodID: "foo",
|
||||
Host: "bar",
|
||||
}
|
||||
body, err := runtime.DefaultCodec.Encode(binding)
|
||||
body, err := latest.Codec.Encode(binding)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected encode error %v", err)
|
||||
}
|
||||
obj := b.New()
|
||||
err = runtime.DefaultCodec.DecodeInto(body, obj)
|
||||
err = latest.Codec.DecodeInto(body, obj)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
|
|
|
@ -113,13 +113,13 @@ func TestControllerDecode(t *testing.T) {
|
|||
ID: "foo",
|
||||
},
|
||||
}
|
||||
body, err := runtime.DefaultCodec.Encode(controller)
|
||||
body, err := latest.Codec.Encode(controller)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
controllerOut := storage.New()
|
||||
if err := runtime.DefaultCodec.DecodeInto(body, controllerOut); err != nil {
|
||||
if err := latest.Codec.DecodeInto(body, controllerOut); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func NewRegistry(client tools.EtcdClient) *Registry {
|
|||
registry := &Registry{
|
||||
EtcdHelper: tools.EtcdHelper{
|
||||
client,
|
||||
runtime.DefaultCodec,
|
||||
latest.Codec,
|
||||
runtime.DefaultResourceVersioner,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var pod api.Pod
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var pod api.Pod
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var pod api.Pod
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
|||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||
if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" {
|
||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ func TestEtcdDeletePod(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var manifests api.ContainerManifestList
|
||||
runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||
latest.Codec.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||
if len(manifests.Items) != 0 {
|
||||
t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value)
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var manifests api.ContainerManifestList
|
||||
runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||
latest.Codec.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||
if len(manifests.Items) != 1 {
|
||||
t.Fatalf("Unexpected manifest set: %#v, expected empty", manifests)
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ func TestEtcdCreateController(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var ctrl api.ReplicationController
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &ctrl)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &ctrl)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -699,7 +699,7 @@ func TestEtcdCreateService(t *testing.T) {
|
|||
}
|
||||
|
||||
var service api.Service
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(resp.Node.Value), &service)
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &service)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
|||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
var endpointsOut api.Endpoints
|
||||
err = runtime.DefaultCodec.DecodeInto([]byte(response.Node.Value), &endpointsOut)
|
||||
err = latest.Codec.DecodeInto([]byte(response.Node.Value), &endpointsOut)
|
||||
if !reflect.DeepEqual(endpoints, endpointsOut) {
|
||||
t.Errorf("Unexpected endpoints: %#v, expected %#v", endpointsOut, endpoints)
|
||||
}
|
||||
|
|
|
@ -201,13 +201,13 @@ func TestPodDecode(t *testing.T) {
|
|||
ID: "foo",
|
||||
},
|
||||
}
|
||||
body, err := runtime.DefaultCodec.Encode(expected)
|
||||
body, err := latest.Codec.Encode(expected)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
actual := storage.New()
|
||||
if err := runtime.DefaultCodec.DecodeInto(body, actual); err != nil {
|
||||
if err := latest.Codec.DecodeInto(body, actual); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ type TestResource struct {
|
|||
func (*TestResource) IsAnAPIObject() {}
|
||||
|
||||
var scheme *runtime.Scheme
|
||||
var codec = runtime.DefaultCodec
|
||||
var codec = latest.Codec
|
||||
var versioner = runtime.DefaultResourceVersioner
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -90,7 +90,7 @@ func TestExtractObj(t *testing.T) {
|
|||
|
||||
func TestWatch(t *testing.T) {
|
||||
client := newEtcdClient()
|
||||
helper := tools.EtcdHelper{Client: client, Codec: runtime.DefaultCodec, ResourceVersioner: runtime.DefaultResourceVersioner}
|
||||
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: runtime.DefaultResourceVersioner}
|
||||
withEtcdKey(func(key string) {
|
||||
resp, err := client.Set(key, runtime.DefaultScheme.EncodeOrDie(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue