From 099c8fd36f6028dab2c2571496b80c9688b04e2d Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Sun, 31 Aug 2014 22:10:49 -0700 Subject: [PATCH] Propagate rename; tests pass again. --- cmd/kubecfg/kubecfg.go | 9 +-- examples/examples_test.go | 16 +++-- pkg/apiserver/apiserver_test.go | 9 +-- pkg/apiserver/watch.go | 5 +- pkg/client/cache/reflector.go | 4 +- pkg/client/client.go | 3 +- pkg/client/client_test.go | 9 +-- pkg/client/request.go | 7 +- pkg/client/request_test.go | 20 +++--- pkg/controller/replication_controller_test.go | 11 +-- pkg/kubecfg/parse.go | 6 +- pkg/kubecfg/parse_test.go | 7 +- pkg/kubecfg/proxy_server.go | 3 +- pkg/kubecfg/resource_printer.go | 7 +- pkg/kubecfg/resource_printer_test.go | 3 +- pkg/kubelet/config/etcd_test.go | 7 +- pkg/kubelet/config/http.go | 5 +- pkg/kubelet/kubelet.go | 3 +- pkg/kubelet/validation.go | 4 +- pkg/master/master.go | 4 +- pkg/proxy/config/etcd.go | 9 +-- pkg/registry/binding/storage_test.go | 5 +- pkg/registry/controller/storage.go | 5 +- pkg/registry/controller/storage_test.go | 5 +- pkg/registry/etcd/etcd.go | 9 +-- pkg/registry/etcd/etcd_test.go | 67 ++++++++++--------- pkg/registry/minion/cloud_registry_test.go | 2 +- pkg/registry/pod/storage.go | 5 +- pkg/registry/pod/storage_test.go | 5 +- pkg/registry/service/storage.go | 5 +- pkg/tools/decoder_test.go | 3 +- pkg/tools/etcd_tools_test.go | 15 +++-- pkg/tools/etcd_tools_watch_test.go | 45 +++++++------ plugin/pkg/scheduler/factory/factory_test.go | 7 +- test/integration/etcd_tools_test.go | 5 +- 35 files changed, 183 insertions(+), 151 deletions(-) diff --git a/cmd/kubecfg/kubecfg.go b/cmd/kubecfg/kubecfg.go index ae03a1a2649..181904ab164 100644 --- a/cmd/kubecfg/kubecfg.go +++ b/cmd/kubecfg/kubecfg.go @@ -29,6 +29,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubecfg" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -237,7 +238,7 @@ func executeAPIRequest(method string, c *client.Client) bool { if err != nil { glog.Fatalf("error obtaining resource version for update: %v", err) } - jsonBase, err := api.FindJSONBase(obj) + jsonBase, err := apitools.FindJSONBase(obj) if err != nil { glog.Fatalf("error finding json base for update: %v", err) } @@ -257,16 +258,16 @@ func executeAPIRequest(method string, c *client.Client) bool { if setBody { if version != 0 { data := readConfig(storage) - obj, err := api.Decode(data) + obj, err := apitools.Decode(data) if err != nil { glog.Fatalf("error setting resource version: %v", err) } - jsonBase, err := api.FindJSONBase(obj) + jsonBase, err := apitools.FindJSONBase(obj) if err != nil { glog.Fatalf("error setting resource version: %v", err) } jsonBase.SetResourceVersion(version) - data, err = api.Encode(obj) + data, err = apitools.Encode(obj) if err != nil { glog.Fatalf("error setting resource version: %v", err) } diff --git a/examples/examples_test.go b/examples/examples_test.go index b7d8cfda0f7..beb1027ff75 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -26,25 +26,27 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/golang/glog" ) func validateObject(obj interface{}) (errors []error) { switch t := obj.(type) { case *api.ReplicationController: - errors = api.ValidateManifest(&t.DesiredState.PodTemplate.DesiredState.Manifest) + errors = validation.ValidateManifest(&t.DesiredState.PodTemplate.DesiredState.Manifest) case *api.ReplicationControllerList: for i := range t.Items { errors = append(errors, validateObject(&t.Items[i])...) } case *api.Service: - errors = api.ValidateService(t) + errors = validation.ValidateService(t) case *api.ServiceList: for i := range t.Items { errors = append(errors, validateObject(&t.Items[i])...) } case *api.Pod: - errors = api.ValidateManifest(&t.DesiredState.Manifest) + errors = validation.ValidateManifest(&t.DesiredState.Manifest) case *api.PodList: for i := range t.Items { errors = append(errors, validateObject(&t.Items[i])...) @@ -101,7 +103,7 @@ func TestApiExamples(t *testing.T) { return } tested += 1 - if err := api.DecodeInto(data, expectedType); err != nil { + if err := apitools.DecodeInto(data, expectedType); err != nil { t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) return } @@ -135,7 +137,7 @@ func TestExamples(t *testing.T) { return } tested += 1 - if err := api.DecodeInto(data, expectedType); err != nil { + if err := apitools.DecodeInto(data, expectedType); err != nil { t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) return } @@ -166,14 +168,14 @@ func TestReadme(t *testing.T) { } for _, json := range match[1:] { expectedType := &api.Pod{} - if err := api.DecodeInto([]byte(json), expectedType); err != nil { + if err := apitools.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 := api.Encode(expectedType) + encoded, err := apitools.Encode(expectedType) if err != nil { t.Errorf("Could not encode object: %v", err) continue diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index f51b7dafe41..35ef4a1d0ce 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -31,6 +31,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/version" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -40,11 +41,11 @@ func convert(obj interface{}) (interface{}, error) { return obj, nil } -var codec = api.Codec +var codec = apitools.Codec func init() { - api.AddKnownTypes("", Simple{}, SimpleList{}) - api.AddKnownTypes("v1beta1", Simple{}, SimpleList{}) + apitools.AddKnownTypes("", Simple{}, SimpleList{}) + apitools.AddKnownTypes("v1beta1", Simple{}, SimpleList{}) } type Simple struct { @@ -696,7 +697,7 @@ func TestWriteJSONDecodeError(t *testing.T) { type T struct { Value string } - writeJSON(http.StatusOK, api.Codec, &T{"Undecodable"}, w) + writeJSON(http.StatusOK, apitools.Codec, &T{"Undecodable"}, w) })) status := expectApiStatus(t, "GET", server.URL, nil, http.StatusInternalServerError) if status.Reason != api.StatusReasonUnknown { diff --git a/pkg/apiserver/watch.go b/pkg/apiserver/watch.go index d0e0ed1785a..4e5422cc480 100644 --- a/pkg/apiserver/watch.go +++ b/pkg/apiserver/watch.go @@ -24,6 +24,7 @@ import ( "code.google.com/p/go.net/websocket" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/common" "github.com/GoogleCloudPlatform/kubernetes/pkg/httplog" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -112,7 +113,7 @@ func (w *WatchServer) HandleWS(ws *websocket.Conn) { } err := websocket.JSON.Send(ws, &api.WatchEvent{ Type: event.Type, - Object: api.APIObject{event.Object}, + Object: common.Object{event.Object}, }) if err != nil { // Client disconnect. @@ -159,7 +160,7 @@ func (self *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { } err := encoder.Encode(&api.WatchEvent{ Type: event.Type, - Object: api.APIObject{event.Object}, + Object: common.Object{event.Object}, }) if err != nil { // Client disconnect. diff --git a/pkg/client/cache/reflector.go b/pkg/client/cache/reflector.go index 204b44f5ab9..81ab014c066 100644 --- a/pkg/client/cache/reflector.go +++ b/pkg/client/cache/reflector.go @@ -20,7 +20,7 @@ import ( "reflect" "time" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/golang/glog" @@ -81,7 +81,7 @@ func (gc *Reflector) watchHandler(w watch.Interface, resourceVersion *uint64) { glog.Errorf("expected type %v, but watch event object had type %v", e, a) continue } - jsonBase, err := api.FindJSONBase(event.Object) + jsonBase, err := apitools.FindJSONBase(event.Object) if err != nil { glog.Errorf("unable to understand watch event %#v", event) continue diff --git a/pkg/client/client.go b/pkg/client/client.go index bacd5705bb2..d848cafa4e9 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -27,6 +27,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/version" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -216,7 +217,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 := api.DecodeInto(body, &status); err == nil && status.Status != "" { + if err := apitools.DecodeInto(body, &status); err == nil && status.Status != "" { isStatusResponse = true } diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 0b9f92c7655..c4934e519ed 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -26,6 +26,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/version" @@ -308,7 +309,7 @@ func TestCreateController(t *testing.T) { func body(obj interface{}, raw *string) *string { if obj != nil { - bs, _ := api.Encode(obj) + bs, _ := apitools.Encode(obj) body := string(bs) return &body } @@ -470,7 +471,7 @@ func TestDoRequest(t *testing.T) { func TestDoRequestAccepted(t *testing.T) { status := api.Status{Status: api.StatusWorking} - expectedBody, _ := api.Encode(status) + expectedBody, _ := apitools.Encode(status) fakeHandler := util.FakeHandler{ StatusCode: 202, ResponseBody: string(expectedBody), @@ -507,7 +508,7 @@ func TestDoRequestAccepted(t *testing.T) { func TestDoRequestAcceptedSuccess(t *testing.T) { status := api.Status{Status: api.StatusSuccess} - expectedBody, _ := api.Encode(status) + expectedBody, _ := apitools.Encode(status) fakeHandler := util.FakeHandler{ StatusCode: 202, ResponseBody: string(expectedBody), @@ -527,7 +528,7 @@ func TestDoRequestAcceptedSuccess(t *testing.T) { if err != nil { t.Errorf("Unexpected error %#v", err) } - statusOut, err := api.Decode(body) + statusOut, err := apitools.Decode(body) if err != nil { t.Errorf("Unexpected error %#v", err) } diff --git a/pkg/client/request.go b/pkg/client/request.go index 1400ec27bfe..a692a59ea31 100644 --- a/pkg/client/request.go +++ b/pkg/client/request.go @@ -28,6 +28,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -204,7 +205,7 @@ func (r *Request) Body(obj interface{}) *Request { case io.Reader: r.body = t default: - data, err := api.Encode(obj) + data, err := apitools.Encode(obj) if err != nil { r.err = err return r @@ -317,7 +318,7 @@ func (r Result) Get() (interface{}, error) { if r.err != nil { return nil, r.err } - return api.Decode(r.body) + return apitools.Decode(r.body) } // Into stores the result into obj, if possible. @@ -325,7 +326,7 @@ func (r Result) Into(obj interface{}) error { if r.err != nil { return r.err } - return api.DecodeInto(r.body, obj) + return apitools.DecodeInto(r.body, obj) } // Error returns the error executing the request, nil if no error occurred. diff --git a/pkg/client/request_test.go b/pkg/client/request_test.go index 360e3962ed2..0d3d8e256ee 100644 --- a/pkg/client/request_test.go +++ b/pkg/client/request_test.go @@ -29,6 +29,8 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/common" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -37,7 +39,7 @@ import ( func TestDoRequestNewWay(t *testing.T) { reqBody := "request body" expectedObj := &api.Service{Port: 12345} - expectedBody, _ := api.Encode(expectedObj) + expectedBody, _ := apitools.Encode(expectedObj) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(expectedBody), @@ -70,9 +72,9 @@ func TestDoRequestNewWay(t *testing.T) { func TestDoRequestNewWayReader(t *testing.T) { reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}} - reqBodyExpected, _ := api.Encode(reqObj) + reqBodyExpected, _ := apitools.Encode(reqObj) expectedObj := &api.Service{Port: 12345} - expectedBody, _ := api.Encode(expectedObj) + expectedBody, _ := apitools.Encode(expectedObj) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(expectedBody), @@ -107,9 +109,9 @@ func TestDoRequestNewWayReader(t *testing.T) { func TestDoRequestNewWayObj(t *testing.T) { reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}} - reqBodyExpected, _ := api.Encode(reqObj) + reqBodyExpected, _ := apitools.Encode(reqObj) expectedObj := &api.Service{Port: 12345} - expectedBody, _ := api.Encode(expectedObj) + expectedBody, _ := apitools.Encode(expectedObj) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(expectedBody), @@ -143,7 +145,7 @@ func TestDoRequestNewWayObj(t *testing.T) { func TestDoRequestNewWayFile(t *testing.T) { reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}} - reqBodyExpected, err := api.Encode(reqObj) + reqBodyExpected, err := apitools.Encode(reqObj) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -159,7 +161,7 @@ func TestDoRequestNewWayFile(t *testing.T) { } expectedObj := &api.Service{Port: 12345} - expectedBody, _ := api.Encode(expectedObj) + expectedBody, _ := apitools.Encode(expectedObj) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(expectedBody), @@ -294,7 +296,7 @@ func TestPolling(t *testing.T) { callNumber := 0 testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - data, err := api.Encode(objects[callNumber]) + data, err := apitools.Encode(objects[callNumber]) if err != nil { t.Errorf("Unexpected encode error") } @@ -400,7 +402,7 @@ func TestWatch(t *testing.T) { encoder := json.NewEncoder(w) for _, item := range table { - encoder.Encode(&api.WatchEvent{item.t, api.APIObject{item.obj}}) + encoder.Encode(&api.WatchEvent{item.t, common.Object{item.obj}}) flusher.Flush() } })) diff --git a/pkg/controller/replication_controller_test.go b/pkg/controller/replication_controller_test.go index c5e3a8480eb..96143c6e9fe 100644 --- a/pkg/controller/replication_controller_test.go +++ b/pkg/controller/replication_controller_test.go @@ -27,6 +27,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" @@ -108,7 +109,7 @@ func validateSyncReplication(t *testing.T, fakePodControl *FakePodControl, expec } func TestSyncReplicationControllerDoesNothing(t *testing.T) { - body, _ := api.Encode(newPodList(2)) + body, _ := apitools.Encode(newPodList(2)) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(body), @@ -128,7 +129,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) { } func TestSyncReplicationControllerDeletes(t *testing.T) { - body, _ := api.Encode(newPodList(2)) + body, _ := apitools.Encode(newPodList(2)) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(body), @@ -148,7 +149,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) { } func TestSyncReplicationControllerCreates(t *testing.T) { - body, _ := api.Encode(newPodList(0)) + body, _ := apitools.Encode(newPodList(0)) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(body), @@ -168,7 +169,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) { } func TestCreateReplica(t *testing.T) { - body, _ := api.Encode(api.Pod{}) + body, _ := apitools.Encode(api.Pod{}) fakeHandler := util.FakeHandler{ StatusCode: 200, ResponseBody: string(body), @@ -291,7 +292,7 @@ func TestSyncronize(t *testing.T) { } fakeControllerHandler := util.FakeHandler{ StatusCode: 200, - ResponseBody: api.EncodeOrDie(&api.ReplicationControllerList{ + ResponseBody: apitools.EncodeOrDie(&api.ReplicationControllerList{ Items: []api.ReplicationController{ controllerSpec1, controllerSpec2, diff --git a/pkg/kubecfg/parse.go b/pkg/kubecfg/parse.go index 984747c47ef..f363fe5c263 100644 --- a/pkg/kubecfg/parse.go +++ b/pkg/kubecfg/parse.go @@ -20,7 +20,7 @@ import ( "fmt" "reflect" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" ) type Parser struct { @@ -44,11 +44,11 @@ func (p *Parser) ToWireFormat(data []byte, storage string) ([]byte, error) { } obj := reflect.New(prototypeType).Interface() - err := api.DecodeInto(data, obj) + err := apitools.DecodeInto(data, obj) if err != nil { return nil, err } - return api.Encode(obj) + return apitools.Encode(obj) } func (p *Parser) SupportedWireStorage() []string { diff --git a/pkg/kubecfg/parse_test.go b/pkg/kubecfg/parse_test.go index baada2514ec..790493a45a6 100644 --- a/pkg/kubecfg/parse_test.go +++ b/pkg/kubecfg/parse_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "gopkg.in/v1/yaml" ) @@ -32,7 +33,7 @@ func TestParseBadStorage(t *testing.T) { } func DoParseTest(t *testing.T, storage string, obj interface{}, p *Parser) { - jsonData, _ := api.Encode(obj) + jsonData, _ := apitools.Encode(obj) yamlData, _ := yaml.Marshal(obj) t.Logf("Intermediate yaml:\n%v\n", string(yamlData)) t.Logf("Intermediate json:\n%v\n", string(jsonData)) @@ -119,8 +120,8 @@ type TestParseType struct { } func TestParseCustomType(t *testing.T) { - api.AddKnownTypes("", TestParseType{}) - api.AddKnownTypes("v1beta1", TestParseType{}) + apitools.AddKnownTypes("", TestParseType{}) + apitools.AddKnownTypes("v1beta1", TestParseType{}) parser := NewParser(map[string]interface{}{ "custom": TestParseType{}, }) diff --git a/pkg/kubecfg/proxy_server.go b/pkg/kubecfg/proxy_server.go index 799f5f36f16..a9e03a2f5b8 100644 --- a/pkg/kubecfg/proxy_server.go +++ b/pkg/kubecfg/proxy_server.go @@ -21,6 +21,7 @@ import ( "net/http" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" ) @@ -52,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, _ := api.Encode(api.Status{ + data, _ := apitools.Encode(api.Status{ Status: api.StatusFailure, Message: fmt.Sprintf("internal error: %#v", err), }) diff --git a/pkg/kubecfg/resource_printer.go b/pkg/kubecfg/resource_printer.go index d5159e3ce9d..3f4e06e9191 100644 --- a/pkg/kubecfg/resource_printer.go +++ b/pkg/kubecfg/resource_printer.go @@ -26,6 +26,7 @@ import ( "text/template" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/golang/glog" "gopkg.in/v1/yaml" @@ -49,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 interface{}, output io.Writer) error { - data, err := api.Encode(obj) + data, err := apitools.Encode(obj) if err != nil { return err } @@ -258,7 +259,7 @@ func (h *HumanReadablePrinter) Print(data []byte, output io.Writer) error { return fmt.Errorf("unexpected object with no 'kind' field: %s", data) } - obj, err := api.Decode(data) + obj, err := apitools.Decode(data) if err != nil { return err } @@ -290,7 +291,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 := api.Decode(data) + obj, err := apitools.Decode(data) if err != nil { return err } diff --git a/pkg/kubecfg/resource_printer_test.go b/pkg/kubecfg/resource_printer_test.go index 1b864d0ad36..4a9b3942b3d 100644 --- a/pkg/kubecfg/resource_printer_test.go +++ b/pkg/kubecfg/resource_printer_test.go @@ -25,6 +25,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "gopkg.in/v1/yaml" ) @@ -95,7 +96,7 @@ func TestIdentityPrinter(t *testing.T) { } buff.Reset() printer.PrintObj(obj, buff) - objOut, err := api.Decode([]byte(buff.String())) + objOut, err := apitools.Decode([]byte(buff.String())) if err != nil { t.Errorf("Unexpeted error: %#v", err) } diff --git a/pkg/kubelet/config/etcd_test.go b/pkg/kubelet/config/etcd_test.go index 5f77711c87f..482527941e6 100644 --- a/pkg/kubelet/config/etcd_test.go +++ b/pkg/kubelet/config/etcd_test.go @@ -22,6 +22,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/coreos/go-etcd/etcd" @@ -35,7 +36,7 @@ func TestGetEtcdData(t *testing.T) { fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(&api.ContainerManifestList{ + Value: apitools.EncodeOrDie(&api.ContainerManifestList{ Items: []api.ContainerManifest{{ID: "foo"}}, }), ModifiedIndex: 1, @@ -78,7 +79,7 @@ func TestGetEtcd(t *testing.T) { fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(&api.ContainerManifestList{ + Value: apitools.EncodeOrDie(&api.ContainerManifestList{ Items: []api.ContainerManifest{manifest}, }), ModifiedIndex: 1, @@ -112,7 +113,7 @@ func TestWatchEtcd(t *testing.T) { fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(&api.ContainerManifestList{}), + Value: apitools.EncodeOrDie(&api.ContainerManifestList{}), ModifiedIndex: 2, }, }, diff --git a/pkg/kubelet/config/http.go b/pkg/kubelet/config/http.go index f168d3100e9..80f508c40f2 100644 --- a/pkg/kubelet/config/http.go +++ b/pkg/kubelet/config/http.go @@ -24,6 +24,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" @@ -69,7 +70,7 @@ func (s *SourceURL) extractFromURL() error { var manifest api.ContainerManifest singleErr := yaml.Unmarshal(data, &manifest) if singleErr == nil { - if errs := api.ValidateManifest(&manifest); len(errs) > 0 { + if errs := validation.ValidateManifest(&manifest); len(errs) > 0 { singleErr = fmt.Errorf("invalid manifest: %v", errs) } } @@ -90,7 +91,7 @@ func (s *SourceURL) extractFromURL() error { // done at the end. Hence not returning early here. if multiErr == nil { for _, manifest := range manifests { - if errs := api.ValidateManifest(&manifest); len(errs) > 0 { + if errs := validation.ValidateManifest(&manifest); len(errs) > 0 { multiErr = fmt.Errorf("invalid manifest: %v", errs) break } diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index f6bc2734fcb..ec59b2a229b 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -28,6 +28,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/health" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -600,7 +601,7 @@ func filterHostPortConflicts(pods []Pod) []Pod { extract := func(p *api.Port) int { return p.HostPort } for i := range pods { pod := &pods[i] - if errs := api.AccumulateUniquePorts(pod.Manifest.Containers, ports, extract); len(errs) != 0 { + if errs := validation.AccumulateUniquePorts(pod.Manifest.Containers, ports, extract); len(errs) != 0 { glog.Warningf("Pod %s has conflicting ports, ignoring: %v", GetPodFullName(pod), errs) continue } diff --git a/pkg/kubelet/validation.go b/pkg/kubelet/validation.go index 68d643b9607..74b0b90a9d4 100644 --- a/pkg/kubelet/validation.go +++ b/pkg/kubelet/validation.go @@ -17,8 +17,8 @@ limitations under the License. package kubelet import ( - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" apierrs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) @@ -26,7 +26,7 @@ func ValidatePod(pod *Pod) (errors []error) { if !util.IsDNSSubdomain(pod.Name) { errors = append(errors, apierrs.NewInvalid("Pod.Name", pod.Name)) } - if errs := api.ValidateManifest(&pod.Manifest); len(errs) != 0 { + if errs := validation.ValidateManifest(&pod.Manifest); len(errs) != 0 { errors = append(errors, errs...) } return errors diff --git a/pkg/master/master.go b/pkg/master/master.go index e0c998f330c..394b726238f 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -20,9 +20,9 @@ import ( "net/http" "time" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/binding" @@ -136,5 +136,5 @@ func (m *Master) API_v1beta1() (map[string]apiserver.RESTStorage, apiserver.Code for k, v := range m.storage { storage[k] = v } - return storage, api.Codec + return storage, apitools.Codec } diff --git a/pkg/proxy/config/etcd.go b/pkg/proxy/config/etcd.go index 15c66320851..2c239842a4e 100644 --- a/pkg/proxy/config/etcd.go +++ b/pkg/proxy/config/etcd.go @@ -39,6 +39,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/coreos/go-etcd/etcd" @@ -132,7 +133,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 = api.DecodeInto([]byte(node.Value), &svc) + err = apitools.DecodeInto([]byte(node.Value), &svc) if err != nil { glog.Errorf("Failed to load Service: %s (%#v)", node.Value, err) continue @@ -165,7 +166,7 @@ func (s ConfigSourceEtcd) GetEndpoints(service string) (api.Endpoints, error) { } // Parse all the endpoint specifications in this value. var e api.Endpoints - err = api.DecodeInto([]byte(response.Node.Value), &e) + err = apitools.DecodeInto([]byte(response.Node.Value), &e) return e, err } @@ -175,7 +176,7 @@ func etcdResponseToService(response *etcd.Response) (*api.Service, error) { return nil, fmt.Errorf("invalid response from etcd: %#v", response) } var svc api.Service - err := api.DecodeInto([]byte(response.Node.Value), &svc) + err := apitools.DecodeInto([]byte(response.Node.Value), &svc) if err != nil { return nil, err } @@ -229,7 +230,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 := api.DecodeInto([]byte(response.Node.Value), &endpoints) + err := apitools.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 diff --git a/pkg/registry/binding/storage_test.go b/pkg/registry/binding/storage_test.go index be62dcdd9a9..78f374cb54a 100644 --- a/pkg/registry/binding/storage_test.go +++ b/pkg/registry/binding/storage_test.go @@ -24,6 +24,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" ) @@ -37,12 +38,12 @@ func TestNewBindingStorage(t *testing.T) { PodID: "foo", Host: "bar", } - body, err := api.Encode(binding) + body, err := apitools.Encode(binding) if err != nil { t.Fatalf("Unexpected encode error %v", err) } obj := b.New() - err = api.DecodeInto(body, obj) + err = apitools.DecodeInto(body, obj) if err != nil { t.Fatalf("Unexpected error %v", err) } diff --git a/pkg/registry/controller/storage.go b/pkg/registry/controller/storage.go index 0a21a0fbbf5..4eafbbef61c 100644 --- a/pkg/registry/controller/storage.go +++ b/pkg/registry/controller/storage.go @@ -21,6 +21,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod" @@ -59,7 +60,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { } // Pod Manifest ID should be assigned by the pod API controller.DesiredState.PodTemplate.DesiredState.Manifest.ID = "" - if errs := api.ValidateReplicationController(controller); len(errs) > 0 { + if errs := validation.ValidateReplicationController(controller); len(errs) > 0 { return nil, apiserver.NewInvalidErr("replicationController", controller.ID, errs) } @@ -118,7 +119,7 @@ func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) } - if errs := api.ValidateReplicationController(controller); len(errs) > 0 { + if errs := validation.ValidateReplicationController(controller); len(errs) > 0 { return nil, apiserver.NewInvalidErr("replicationController", controller.ID, errs) } return apiserver.MakeAsync(func() (interface{}, error) { diff --git a/pkg/registry/controller/storage_test.go b/pkg/registry/controller/storage_test.go index be4b3c54547..4cdd146a4f9 100644 --- a/pkg/registry/controller/storage_test.go +++ b/pkg/registry/controller/storage_test.go @@ -26,6 +26,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest" ) @@ -111,13 +112,13 @@ func TestControllerDecode(t *testing.T) { ID: "foo", }, } - body, err := api.Encode(controller) + body, err := apitools.Encode(controller) if err != nil { t.Errorf("unexpected error: %v", err) } controllerOut := storage.New() - if err := api.DecodeInto(body, controllerOut); err != nil { + if err := apitools.DecodeInto(body, controllerOut); err != nil { t.Errorf("unexpected error: %v", err) } diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index 64b1e90160f..be808b14b6f 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -21,6 +21,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/constraint" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" @@ -44,8 +45,8 @@ func NewRegistry(client tools.EtcdClient) *Registry { registry := &Registry{ EtcdHelper: tools.EtcdHelper{ client, - api.Codec, - api.ResourceVersioner, + apitools.Codec, + apitools.ResourceVersioner, }, } registry.manifestFactory = &BasicManifestFactory{ @@ -267,7 +268,7 @@ func (r *Registry) CreateController(controller api.ReplicationController) error // UpdateController replaces an existing ReplicationController. func (r *Registry) UpdateController(controller api.ReplicationController) error { - return r.SetObj(makeControllerKey(controller.ID), controller) + return r.SetObj(makeControllerKey(controller.ID), &controller) } // DeleteController deletes a ReplicationController specified by its ID. @@ -352,7 +353,7 @@ func (r *Registry) DeleteService(name string) error { // UpdateService replaces an existing Service. func (r *Registry) UpdateService(svc api.Service) error { - return r.SetObj(makeServiceKey(svc.ID), svc) + return r.SetObj(makeServiceKey(svc.ID), &svc) } // WatchServices begins watching for new, changed, or deleted service configurations. diff --git a/pkg/registry/etcd/etcd_test.go b/pkg/registry/etcd/etcd_test.go index adf0fdc2905..f62c07830cb 100644 --- a/pkg/registry/etcd/etcd_test.go +++ b/pkg/registry/etcd/etcd_test.go @@ -23,6 +23,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" @@ -40,7 +41,7 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *Registry { func TestEtcdGetPod(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/pods/foo", api.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) + fakeClient.Set("/registry/pods/foo", apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) pod, err := registry.GetPod("foo") if err != nil { @@ -76,7 +77,7 @@ func TestEtcdCreatePod(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Set("/registry/hosts/machine/kubelet", api.EncodeOrDie(&api.ContainerManifestList{}), 0) + fakeClient.Set("/registry/hosts/machine/kubelet", apitools.EncodeOrDie(&api.ContainerManifestList{}), 0) registry := NewTestEtcdRegistry(fakeClient) err := registry.CreatePod(api.Pod{ JSONBase: api.JSONBase{ @@ -107,7 +108,7 @@ func TestEtcdCreatePod(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var pod api.Pod - err = api.DecodeInto([]byte(resp.Node.Value), &pod) + err = apitools.DecodeInto([]byte(resp.Node.Value), &pod) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -121,7 +122,7 @@ func TestEtcdCreatePod(t *testing.T) { t.Errorf("unexpected error: %v", err) } - err = api.DecodeInto([]byte(resp.Node.Value), &manifests) + err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests) if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } @@ -132,7 +133,7 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) { fakeClient.Data["/registry/pods/foo"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), + Value: apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), }, }, E: nil, @@ -234,7 +235,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var pod api.Pod - err = api.DecodeInto([]byte(resp.Node.Value), &pod) + err = apitools.DecodeInto([]byte(resp.Node.Value), &pod) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -248,7 +249,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { t.Errorf("unexpected error: %v", err) } - err = api.DecodeInto([]byte(resp.Node.Value), &manifests) + err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests) if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } @@ -263,7 +264,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Set("/registry/hosts/machine/kubelet", api.EncodeOrDie(api.ContainerManifestList{ + fakeClient.Set("/registry/hosts/machine/kubelet", apitools.EncodeOrDie(api.ContainerManifestList{ Items: []api.ContainerManifest{ {ID: "bar"}, }, @@ -299,7 +300,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var pod api.Pod - err = api.DecodeInto([]byte(resp.Node.Value), &pod) + err = apitools.DecodeInto([]byte(resp.Node.Value), &pod) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -313,7 +314,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { t.Errorf("unexpected error: %v", err) } - err = api.DecodeInto([]byte(resp.Node.Value), &manifests) + err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests) if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } @@ -324,11 +325,11 @@ func TestEtcdDeletePod(t *testing.T) { fakeClient.TestIndex = true key := "/registry/pods/foo" - fakeClient.Set(key, api.EncodeOrDie(api.Pod{ + fakeClient.Set(key, apitools.EncodeOrDie(api.Pod{ JSONBase: api.JSONBase{ID: "foo"}, DesiredState: api.PodState{Host: "machine"}, }), 0) - fakeClient.Set("/registry/hosts/machine/kubelet", api.EncodeOrDie(&api.ContainerManifestList{ + fakeClient.Set("/registry/hosts/machine/kubelet", apitools.EncodeOrDie(&api.ContainerManifestList{ Items: []api.ContainerManifest{ {ID: "foo"}, }, @@ -349,7 +350,7 @@ func TestEtcdDeletePod(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var manifests api.ContainerManifestList - api.DecodeInto([]byte(response.Node.Value), &manifests) + apitools.DecodeInto([]byte(response.Node.Value), &manifests) if len(manifests.Items) != 0 { t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value) } @@ -360,11 +361,11 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { fakeClient.TestIndex = true key := "/registry/pods/foo" - fakeClient.Set(key, api.EncodeOrDie(api.Pod{ + fakeClient.Set(key, apitools.EncodeOrDie(api.Pod{ JSONBase: api.JSONBase{ID: "foo"}, DesiredState: api.PodState{Host: "machine"}, }), 0) - fakeClient.Set("/registry/hosts/machine/kubelet", api.EncodeOrDie(&api.ContainerManifestList{ + fakeClient.Set("/registry/hosts/machine/kubelet", apitools.EncodeOrDie(&api.ContainerManifestList{ Items: []api.ContainerManifest{ {ID: "foo"}, {ID: "bar"}, @@ -387,7 +388,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var manifests api.ContainerManifestList - api.DecodeInto([]byte(response.Node.Value), &manifests) + apitools.DecodeInto([]byte(response.Node.Value), &manifests) if len(manifests.Items) != 1 { t.Fatalf("Unexpected manifest set: %#v, expected empty", manifests) } @@ -444,13 +445,13 @@ func TestEtcdListPods(t *testing.T) { Node: &etcd.Node{ Nodes: []*etcd.Node{ { - Value: api.EncodeOrDie(api.Pod{ + Value: apitools.EncodeOrDie(api.Pod{ JSONBase: api.JSONBase{ID: "foo"}, DesiredState: api.PodState{Host: "machine"}, }), }, { - Value: api.EncodeOrDie(api.Pod{ + Value: apitools.EncodeOrDie(api.Pod{ JSONBase: api.JSONBase{ID: "bar"}, DesiredState: api.PodState{Host: "machine"}, }), @@ -519,10 +520,10 @@ func TestEtcdListControllers(t *testing.T) { Node: &etcd.Node{ Nodes: []*etcd.Node{ { - Value: api.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), + Value: apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), }, { - Value: api.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}), + Value: apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}), }, }, }, @@ -542,7 +543,7 @@ func TestEtcdListControllers(t *testing.T) { func TestEtcdGetController(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/controllers/foo", api.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) + fakeClient.Set("/registry/controllers/foo", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) ctrl, err := registry.GetController("foo") if err != nil { @@ -606,7 +607,7 @@ func TestEtcdCreateController(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var ctrl api.ReplicationController - err = api.DecodeInto([]byte(resp.Node.Value), &ctrl) + err = apitools.DecodeInto([]byte(resp.Node.Value), &ctrl) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -618,7 +619,7 @@ func TestEtcdCreateController(t *testing.T) { func TestEtcdCreateControllerAlreadyExisting(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/controllers/foo", api.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) + fakeClient.Set("/registry/controllers/foo", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) err := registry.CreateController(api.ReplicationController{ @@ -635,7 +636,7 @@ func TestEtcdUpdateController(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) fakeClient.TestIndex = true - resp, _ := fakeClient.Set("/registry/controllers/foo", api.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) + resp, _ := fakeClient.Set("/registry/controllers/foo", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) err := registry.UpdateController(api.ReplicationController{ JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex}, @@ -661,10 +662,10 @@ func TestEtcdListServices(t *testing.T) { Node: &etcd.Node{ Nodes: []*etcd.Node{ { - Value: api.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), + Value: apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), }, { - Value: api.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "bar"}}), + Value: apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "bar"}}), }, }, }, @@ -698,7 +699,7 @@ func TestEtcdCreateService(t *testing.T) { } var service api.Service - err = api.DecodeInto([]byte(resp.Node.Value), &service) + err = apitools.DecodeInto([]byte(resp.Node.Value), &service) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -710,7 +711,7 @@ func TestEtcdCreateService(t *testing.T) { func TestEtcdCreateServiceAlreadyExisting(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/services/specs/foo", api.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) + fakeClient.Set("/registry/services/specs/foo", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) err := registry.CreateService(api.Service{ JSONBase: api.JSONBase{ID: "foo"}, @@ -722,7 +723,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) { func TestEtcdGetService(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) - fakeClient.Set("/registry/services/specs/foo", api.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) + fakeClient.Set("/registry/services/specs/foo", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) service, err := registry.GetService("foo") if err != nil { @@ -774,7 +775,7 @@ func TestEtcdUpdateService(t *testing.T) { fakeClient := tools.NewFakeEtcdClient(t) fakeClient.TestIndex = true - resp, _ := fakeClient.Set("/registry/services/specs/foo", api.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) + resp, _ := fakeClient.Set("/registry/services/specs/foo", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) registry := NewTestEtcdRegistry(fakeClient) testService := api.Service{ JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex}, @@ -811,7 +812,7 @@ func TestEtcdGetEndpoints(t *testing.T) { Endpoints: []string{"127.0.0.1:34855"}, } - fakeClient.Set("/registry/services/endpoints/foo", api.EncodeOrDie(endpoints), 0) + fakeClient.Set("/registry/services/endpoints/foo", apitools.EncodeOrDie(endpoints), 0) got, err := registry.GetEndpoints("foo") if err != nil { @@ -832,7 +833,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) { Endpoints: []string{"baz", "bar"}, } - fakeClient.Set("/registry/services/endpoints/foo", api.EncodeOrDie(api.Endpoints{}), 0) + fakeClient.Set("/registry/services/endpoints/foo", apitools.EncodeOrDie(api.Endpoints{}), 0) err := registry.UpdateEndpoints(endpoints) if err != nil { @@ -844,7 +845,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) { t.Fatalf("Unexpected error %v", err) } var endpointsOut api.Endpoints - err = api.DecodeInto([]byte(response.Node.Value), &endpointsOut) + err = apitools.DecodeInto([]byte(response.Node.Value), &endpointsOut) if !reflect.DeepEqual(endpoints, endpointsOut) { t.Errorf("Unexpected endpoints: %#v, expected %#v", endpointsOut, endpoints) } diff --git a/pkg/registry/minion/cloud_registry_test.go b/pkg/registry/minion/cloud_registry_test.go index d325b91b259..8f5a8894fee 100644 --- a/pkg/registry/minion/cloud_registry_test.go +++ b/pkg/registry/minion/cloud_registry_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" + fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" ) func TestCloudList(t *testing.T) { diff --git a/pkg/registry/pod/storage.go b/pkg/registry/pod/storage.go index 41da556ba36..a3ee524ee44 100644 --- a/pkg/registry/pod/storage.go +++ b/pkg/registry/pod/storage.go @@ -23,6 +23,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" @@ -68,7 +69,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { pod.ID = uuid.NewUUID().String() } pod.DesiredState.Manifest.ID = pod.ID - if errs := api.ValidatePod(pod); len(errs) > 0 { + if errs := validation.ValidatePod(pod); len(errs) > 0 { return nil, apiserver.NewInvalidErr("pod", pod.ID, errs) } @@ -135,7 +136,7 @@ func (rs RegistryStorage) New() interface{} { func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { pod := obj.(*api.Pod) - if errs := api.ValidatePod(pod); len(errs) > 0 { + if errs := validation.ValidatePod(pod); len(errs) > 0 { return nil, apiserver.NewInvalidErr("pod", pod.ID, errs) } return apiserver.MakeAsync(func() (interface{}, error) { diff --git a/pkg/registry/pod/storage_test.go b/pkg/registry/pod/storage_test.go index 46da24c3c61..2a6f922bb56 100644 --- a/pkg/registry/pod/storage_test.go +++ b/pkg/registry/pod/storage_test.go @@ -24,6 +24,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest" @@ -177,13 +178,13 @@ func TestPodDecode(t *testing.T) { ID: "foo", }, } - body, err := api.Encode(expected) + body, err := apitools.Encode(expected) if err != nil { t.Errorf("unexpected error: %v", err) } actual := storage.New() - if err := api.DecodeInto(body, actual); err != nil { + if err := apitools.DecodeInto(body, actual); err != nil { t.Errorf("unexpected error: %v", err) } diff --git a/pkg/registry/service/storage.go b/pkg/registry/service/storage.go index 8ad2623137c..742847c4b4b 100644 --- a/pkg/registry/service/storage.go +++ b/pkg/registry/service/storage.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -49,7 +50,7 @@ func NewRegistryStorage(registry Registry, cloud cloudprovider.Interface, machin func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { srv := obj.(*api.Service) - if errs := api.ValidateService(srv); len(errs) > 0 { + if errs := validation.ValidateService(srv); len(errs) > 0 { return nil, apiserver.NewInvalidErr("service", srv.ID, errs) } @@ -155,7 +156,7 @@ func GetServiceEnvironmentVariables(registry Registry, machine string) ([]api.En func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { srv := obj.(*api.Service) - if errs := api.ValidateService(srv); len(errs) > 0 { + if errs := validation.ValidateService(srv); len(errs) > 0 { return nil, apiserver.NewInvalidErr("service", srv.ID, errs) } return apiserver.MakeAsync(func() (interface{}, error) { diff --git a/pkg/tools/decoder_test.go b/pkg/tools/decoder_test.go index dc7fd636249..eeb14d9a677 100644 --- a/pkg/tools/decoder_test.go +++ b/pkg/tools/decoder_test.go @@ -24,6 +24,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/common" _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" ) @@ -35,7 +36,7 @@ func TestDecoder(t *testing.T) { expect := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}} go func() { - err := encoder.Encode(api.WatchEvent{watch.Added, api.APIObject{expect}}) + err := encoder.Encode(api.WatchEvent{watch.Added, common.Object{expect}}) if err != nil { t.Errorf("Unexpected error %v", err) } diff --git a/pkg/tools/etcd_tools_test.go b/pkg/tools/etcd_tools_test.go index 216e1bfd898..132de4b2f7a 100644 --- a/pkg/tools/etcd_tools_test.go +++ b/pkg/tools/etcd_tools_test.go @@ -24,6 +24,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/conversion" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/coreos/go-etcd/etcd" @@ -40,8 +41,8 @@ type TestResource struct { } var scheme *conversion.Scheme -var codec = api.Codec -var versioner = api.ResourceVersioner +var codec = apitools.Codec +var versioner = apitools.ResourceVersioner func init() { scheme = conversion.NewScheme() @@ -184,13 +185,13 @@ func TestSetObj(t *testing.T) { } func TestSetObjWithVersion(t *testing.T) { - obj := api.Pod{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}} + obj := &api.Pod{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}} fakeClient := NewFakeEtcdClient(t) fakeClient.TestIndex = true fakeClient.Data["/some/key"] = EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(obj), + Value: apitools.EncodeOrDie(obj), ModifiedIndex: 1, }, }, @@ -235,7 +236,7 @@ func TestAtomicUpdate(t *testing.T) { fakeClient := NewFakeEtcdClient(t) fakeClient.TestIndex = true codec := scheme - helper := EtcdHelper{fakeClient, codec, api.NewJSONBaseResourceVersioner()} + helper := EtcdHelper{fakeClient, codec, apitools.NewJSONBaseResourceVersioner()} // Create a new node. fakeClient.ExpectNotFoundGet("/some/key") @@ -289,7 +290,7 @@ func TestAtomicUpdate(t *testing.T) { func TestAtomicUpdateNoChange(t *testing.T) { fakeClient := NewFakeEtcdClient(t) fakeClient.TestIndex = true - helper := EtcdHelper{fakeClient, scheme, api.NewJSONBaseResourceVersioner()} + helper := EtcdHelper{fakeClient, scheme, apitools.NewJSONBaseResourceVersioner()} // Create a new node. fakeClient.ExpectNotFoundGet("/some/key") @@ -321,7 +322,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) { fakeClient := NewFakeEtcdClient(t) fakeClient.TestIndex = true codec := scheme - helper := EtcdHelper{fakeClient, codec, api.NewJSONBaseResourceVersioner()} + helper := EtcdHelper{fakeClient, codec, apitools.NewJSONBaseResourceVersioner()} fakeClient.ExpectNotFoundGet("/some/key") diff --git a/pkg/tools/etcd_tools_watch_test.go b/pkg/tools/etcd_tools_watch_test.go index 0d0378cae4d..59d59493af0 100644 --- a/pkg/tools/etcd_tools_watch_test.go +++ b/pkg/tools/etcd_tools_watch_test.go @@ -23,6 +23,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" "github.com/coreos/go-etcd/etcd" ) @@ -47,62 +48,62 @@ func TestWatchInterpretations(t *testing.T) { }{ "create": { actions: []string{"create", "get"}, - nodeValue: api.EncodeOrDie(podBar), + nodeValue: apitools.EncodeOrDie(podBar), expectEmit: true, expectType: watch.Added, expectObject: podBar, }, "create but filter blocks": { actions: []string{"create", "get"}, - nodeValue: api.EncodeOrDie(podFoo), + nodeValue: apitools.EncodeOrDie(podFoo), expectEmit: false, }, "delete": { actions: []string{"delete"}, - prevNodeValue: api.EncodeOrDie(podBar), + prevNodeValue: apitools.EncodeOrDie(podBar), expectEmit: true, expectType: watch.Deleted, expectObject: podBar, }, "delete but filter blocks": { actions: []string{"delete"}, - nodeValue: api.EncodeOrDie(podFoo), + nodeValue: apitools.EncodeOrDie(podFoo), expectEmit: false, }, "modify appears to create 1": { actions: []string{"set", "compareAndSwap"}, - nodeValue: api.EncodeOrDie(podBar), + nodeValue: apitools.EncodeOrDie(podBar), expectEmit: true, expectType: watch.Added, expectObject: podBar, }, "modify appears to create 2": { actions: []string{"set", "compareAndSwap"}, - prevNodeValue: api.EncodeOrDie(podFoo), - nodeValue: api.EncodeOrDie(podBar), + prevNodeValue: apitools.EncodeOrDie(podFoo), + nodeValue: apitools.EncodeOrDie(podBar), expectEmit: true, expectType: watch.Added, expectObject: podBar, }, "modify appears to delete": { actions: []string{"set", "compareAndSwap"}, - prevNodeValue: api.EncodeOrDie(podBar), - nodeValue: api.EncodeOrDie(podFoo), + prevNodeValue: apitools.EncodeOrDie(podBar), + nodeValue: apitools.EncodeOrDie(podFoo), expectEmit: true, expectType: watch.Deleted, expectObject: podBar, // Should return last state that passed the filter! }, "modify modifies": { actions: []string{"set", "compareAndSwap"}, - prevNodeValue: api.EncodeOrDie(podBar), - nodeValue: api.EncodeOrDie(podBaz), + prevNodeValue: apitools.EncodeOrDie(podBar), + nodeValue: apitools.EncodeOrDie(podBaz), expectEmit: true, expectType: watch.Modified, expectObject: podBaz, }, "modify ignores": { actions: []string{"set", "compareAndSwap"}, - nodeValue: api.EncodeOrDie(podFoo), + nodeValue: apitools.EncodeOrDie(podFoo), expectEmit: false, }, } @@ -258,7 +259,7 @@ func TestWatchEtcdState(t *testing.T) { { Action: "create", Node: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), }, }, }, @@ -272,12 +273,12 @@ func TestWatchEtcdState(t *testing.T) { { Action: "compareAndSwap", Node: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), CreatedIndex: 1, ModifiedIndex: 2, }, PrevNode: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), CreatedIndex: 1, ModifiedIndex: 1, }, @@ -294,7 +295,7 @@ func TestWatchEtcdState(t *testing.T) { R: &etcd.Response{ Action: "get", Node: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), CreatedIndex: 1, ModifiedIndex: 1, }, @@ -307,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) { { Action: "compareAndSwap", Node: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})), CreatedIndex: 1, ModifiedIndex: 2, }, PrevNode: &etcd.Node{ - Value: string(api.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), + Value: string(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})), CreatedIndex: 1, ModifiedIndex: 1, }, @@ -369,7 +370,7 @@ func TestWatchFromZeroIndex(t *testing.T) { EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(pod), + Value: apitools.EncodeOrDie(pod), CreatedIndex: 1, ModifiedIndex: 1, }, @@ -384,7 +385,7 @@ func TestWatchFromZeroIndex(t *testing.T) { EtcdResponseWithError{ R: &etcd.Response{ Node: &etcd.Node{ - Value: api.EncodeOrDie(pod), + Value: apitools.EncodeOrDie(pod), CreatedIndex: 1, ModifiedIndex: 2, }, @@ -442,13 +443,13 @@ func TestWatchListFromZeroIndex(t *testing.T) { Dir: true, Nodes: etcd.Nodes{ &etcd.Node{ - Value: api.EncodeOrDie(pod), + Value: apitools.EncodeOrDie(pod), CreatedIndex: 1, ModifiedIndex: 1, Nodes: etcd.Nodes{}, }, &etcd.Node{ - Value: api.EncodeOrDie(pod), + Value: apitools.EncodeOrDie(pod), CreatedIndex: 2, ModifiedIndex: 2, Nodes: etcd.Nodes{}, diff --git a/plugin/pkg/scheduler/factory/factory_test.go b/plugin/pkg/scheduler/factory/factory_test.go index 31d1b18f659..7de93a0abe1 100644 --- a/plugin/pkg/scheduler/factory/factory_test.go +++ b/plugin/pkg/scheduler/factory/factory_test.go @@ -24,6 +24,7 @@ import ( "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -112,7 +113,7 @@ func TestPollMinions(t *testing.T) { ml := &api.MinionList{Items: item.minions} handler := util.FakeHandler{ StatusCode: 200, - ResponseBody: api.EncodeOrDie(ml), + ResponseBody: apitools.EncodeOrDie(ml), T: t, } mux := http.NewServeMux() @@ -139,7 +140,7 @@ func TestDefaultErrorFunc(t *testing.T) { testPod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}} handler := util.FakeHandler{ StatusCode: 200, - ResponseBody: api.EncodeOrDie(testPod), + ResponseBody: apitools.EncodeOrDie(testPod), T: t, } mux := http.NewServeMux() @@ -258,7 +259,7 @@ func TestBind(t *testing.T) { t.Errorf("Unexpected error: %v", err) continue } - expectedBody := api.EncodeOrDie(item.binding) + expectedBody := apitools.EncodeOrDie(item.binding) handler.ValidateRequest(t, "/api/v1beta1/bindings", "POST", &expectedBody) } } diff --git a/test/integration/etcd_tools_test.go b/test/integration/etcd_tools_test.go index 1e0b4eb9cbf..fcfdf681585 100644 --- a/test/integration/etcd_tools_test.go +++ b/test/integration/etcd_tools_test.go @@ -22,6 +22,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/apitools" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" ) @@ -83,9 +84,9 @@ func TestExtractObj(t *testing.T) { func TestWatch(t *testing.T) { client := newEtcdClient() - helper := tools.EtcdHelper{Client: client, Codec: api.Codec, ResourceVersioner: api.ResourceVersioner} + helper := tools.EtcdHelper{Client: client, Codec: apitools.Codec, ResourceVersioner: apitools.ResourceVersioner} withEtcdKey(func(key string) { - resp, err := client.Set(key, api.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) + resp, err := client.Set(key, apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) if err != nil { t.Fatalf("unexpected error: %v", err) }