mirror of https://github.com/k3s-io/k3s
Combine pkg/apitools and pkg/api/common and call the result pkg/runtime
parent
099c8fd36f
commit
a63966e73c
|
@ -29,9 +29,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubecfg"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubecfg"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
verflag "github.com/GoogleCloudPlatform/kubernetes/pkg/version/flag"
|
verflag "github.com/GoogleCloudPlatform/kubernetes/pkg/version/flag"
|
||||||
|
@ -238,7 +238,7 @@ func executeAPIRequest(method string, c *client.Client) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error obtaining resource version for update: %v", err)
|
glog.Fatalf("error obtaining resource version for update: %v", err)
|
||||||
}
|
}
|
||||||
jsonBase, err := apitools.FindJSONBase(obj)
|
jsonBase, err := runtime.FindJSONBase(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error finding json base for update: %v", err)
|
glog.Fatalf("error finding json base for update: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -258,16 +258,16 @@ func executeAPIRequest(method string, c *client.Client) bool {
|
||||||
if setBody {
|
if setBody {
|
||||||
if version != 0 {
|
if version != 0 {
|
||||||
data := readConfig(storage)
|
data := readConfig(storage)
|
||||||
obj, err := apitools.Decode(data)
|
obj, err := runtime.Decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error setting resource version: %v", err)
|
glog.Fatalf("error setting resource version: %v", err)
|
||||||
}
|
}
|
||||||
jsonBase, err := apitools.FindJSONBase(obj)
|
jsonBase, err := runtime.FindJSONBase(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error setting resource version: %v", err)
|
glog.Fatalf("error setting resource version: %v", err)
|
||||||
}
|
}
|
||||||
jsonBase.SetResourceVersion(version)
|
jsonBase.SetResourceVersion(version)
|
||||||
data, err = apitools.Encode(obj)
|
data, err = runtime.Encode(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error setting resource version: %v", err)
|
glog.Fatalf("error setting resource version: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ func TestApiExamples(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tested += 1
|
tested += 1
|
||||||
if err := apitools.DecodeInto(data, expectedType); err != nil {
|
if err := runtime.DecodeInto(data, expectedType); err != nil {
|
||||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ func TestExamples(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tested += 1
|
tested += 1
|
||||||
if err := apitools.DecodeInto(data, expectedType); err != nil {
|
if err := runtime.DecodeInto(data, expectedType); err != nil {
|
||||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -168,14 +168,14 @@ func TestReadme(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, json := range match[1:] {
|
for _, json := range match[1:] {
|
||||||
expectedType := &api.Pod{}
|
expectedType := &api.Pod{}
|
||||||
if err := apitools.DecodeInto([]byte(json), expectedType); err != nil {
|
if err := runtime.DecodeInto([]byte(json), expectedType); err != nil {
|
||||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||||
}
|
}
|
||||||
encoded, err := apitools.Encode(expectedType)
|
encoded, err := runtime.Encode(expectedType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Could not encode object: %v", err)
|
t.Errorf("Could not encode object: %v", err)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2014 Google Inc. All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package common provides types useful for all versions of any object
|
|
||||||
// that conforms to the kubernetes API object expectations.
|
|
||||||
package common
|
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
apitools.AddKnownTypes("",
|
runtime.AddKnownTypes("",
|
||||||
PodList{},
|
PodList{},
|
||||||
Pod{},
|
Pod{},
|
||||||
ReplicationControllerList{},
|
ReplicationControllerList{},
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
"github.com/google/gofuzz"
|
"github.com/google/gofuzz"
|
||||||
|
@ -108,20 +108,20 @@ func objDiff(a, b interface{}) string {
|
||||||
func runTest(t *testing.T, source interface{}) {
|
func runTest(t *testing.T, source interface{}) {
|
||||||
name := reflect.TypeOf(source).Elem().Name()
|
name := reflect.TypeOf(source).Elem().Name()
|
||||||
apiObjectFuzzer.Fuzz(source)
|
apiObjectFuzzer.Fuzz(source)
|
||||||
j, err := apitools.FindJSONBase(source)
|
j, err := runtime.FindJSONBase(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error %v for %#v", err, source)
|
t.Fatalf("Unexpected error %v for %#v", err, source)
|
||||||
}
|
}
|
||||||
j.SetKind("")
|
j.SetKind("")
|
||||||
j.SetAPIVersion("")
|
j.SetAPIVersion("")
|
||||||
|
|
||||||
data, err := apitools.Encode(source)
|
data, err := runtime.Encode(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v: %v (%#v)", name, err, source)
|
t.Errorf("%v: %v (%#v)", name, err, source)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
obj2, err := apitools.Decode(data)
|
obj2, err := runtime.Decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v: %v", name, err)
|
t.Errorf("%v: %v", name, err)
|
||||||
return
|
return
|
||||||
|
@ -132,7 +132,7 @@ func runTest(t *testing.T, source interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface()
|
obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface()
|
||||||
err = apitools.DecodeInto(data, obj3)
|
err = runtime.DecodeInto(data, obj3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("2: %v: %v", name, err)
|
t.Errorf("2: %v: %v", name, err)
|
||||||
return
|
return
|
||||||
|
@ -174,8 +174,8 @@ func TestEncode_NonPtr(t *testing.T) {
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
obj2, err2 := apitools.Decode(data)
|
obj2, err2 := runtime.Decode(data)
|
||||||
if err != nil || err2 != nil {
|
if err != nil || err2 != nil {
|
||||||
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
||||||
}
|
}
|
||||||
|
@ -192,8 +192,8 @@ func TestEncode_Ptr(t *testing.T) {
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
obj2, err2 := apitools.Decode(data)
|
obj2, err2 := runtime.Decode(data)
|
||||||
if err != nil || err2 != nil {
|
if err != nil || err2 != nil {
|
||||||
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
||||||
}
|
}
|
||||||
|
@ -207,11 +207,11 @@ func TestEncode_Ptr(t *testing.T) {
|
||||||
|
|
||||||
func TestBadJSONRejection(t *testing.T) {
|
func TestBadJSONRejection(t *testing.T) {
|
||||||
badJSONMissingKind := []byte(`{ }`)
|
badJSONMissingKind := []byte(`{ }`)
|
||||||
if _, err := apitools.Decode(badJSONMissingKind); err == nil {
|
if _, err := runtime.Decode(badJSONMissingKind); err == nil {
|
||||||
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
|
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
|
||||||
}
|
}
|
||||||
badJSONUnknownType := []byte(`{"kind": "bar"}`)
|
badJSONUnknownType := []byte(`{"kind": "bar"}`)
|
||||||
if _, err1 := apitools.Decode(badJSONUnknownType); err1 == nil {
|
if _, err1 := runtime.Decode(badJSONUnknownType); err1 == nil {
|
||||||
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
|
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
|
||||||
}
|
}
|
||||||
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)
|
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/common"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
|
@ -522,5 +522,5 @@ type WatchEvent struct {
|
||||||
|
|
||||||
// For added or modified objects, this is the new object; for deleted objects,
|
// For added or modified objects, this is the new object; for deleted objects,
|
||||||
// it's the state of the object immediately prior to its deletion.
|
// it's the state of the object immediately prior to its deletion.
|
||||||
Object common.Object
|
Object runtime.Object
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@ package v1beta1
|
||||||
import (
|
import (
|
||||||
// Alias this so it can be easily changed when we cut the next version.
|
// Alias this so it can be easily changed when we cut the next version.
|
||||||
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Shortcut for sub-conversions. TODO: This should possibly be refactored
|
// Shortcut for sub-conversions. TODO: This should possibly be refactored
|
||||||
// such that this convert function is passed to each conversion func.
|
// such that this convert function is passed to each conversion func.
|
||||||
Convert := apitools.Convert
|
Convert := runtime.Convert
|
||||||
apitools.AddConversionFuncs(
|
runtime.AddConversionFuncs(
|
||||||
// EnvVar's Key is deprecated in favor of Name.
|
// EnvVar's Key is deprecated in favor of Name.
|
||||||
func(in *newer.EnvVar, out *EnvVar) error {
|
func(in *newer.EnvVar, out *EnvVar) error {
|
||||||
out.Value = in.Value
|
out.Value = in.Value
|
||||||
|
|
|
@ -22,10 +22,10 @@ import (
|
||||||
|
|
||||||
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Convert = apitools.Convert
|
var Convert = runtime.Convert
|
||||||
|
|
||||||
func TestEnvConversion(t *testing.T) {
|
func TestEnvConversion(t *testing.T) {
|
||||||
nonCanonical := []v1beta1.EnvVar{
|
nonCanonical := []v1beta1.EnvVar{
|
||||||
|
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
apitools.AddKnownTypes("v1beta1",
|
runtime.AddKnownTypes("v1beta1",
|
||||||
PodList{},
|
PodList{},
|
||||||
Pod{},
|
Pod{},
|
||||||
ReplicationControllerList{},
|
ReplicationControllerList{},
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/common"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/third_party/docker-api-structs"
|
"github.com/GoogleCloudPlatform/kubernetes/third_party/docker-api-structs"
|
||||||
|
@ -522,5 +522,5 @@ type WatchEvent struct {
|
||||||
|
|
||||||
// For added or modified objects, this is the new object; for deleted objects,
|
// For added or modified objects, this is the new object; for deleted objects,
|
||||||
// it's the state of the object immediately prior to its deletion.
|
// it's the state of the object immediately prior to its deletion.
|
||||||
Object common.Object
|
Object runtime.Object
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
@ -41,11 +41,11 @@ func convert(obj interface{}) (interface{}, error) {
|
||||||
return obj, nil
|
return obj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var codec = apitools.Codec
|
var codec = runtime.Codec
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
apitools.AddKnownTypes("", Simple{}, SimpleList{})
|
runtime.AddKnownTypes("", Simple{}, SimpleList{})
|
||||||
apitools.AddKnownTypes("v1beta1", Simple{}, SimpleList{})
|
runtime.AddKnownTypes("v1beta1", Simple{}, SimpleList{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Simple struct {
|
type Simple struct {
|
||||||
|
@ -697,7 +697,7 @@ func TestWriteJSONDecodeError(t *testing.T) {
|
||||||
type T struct {
|
type T struct {
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
writeJSON(http.StatusOK, apitools.Codec, &T{"Undecodable"}, w)
|
writeJSON(http.StatusOK, runtime.Codec, &T{"Undecodable"}, w)
|
||||||
}))
|
}))
|
||||||
status := expectApiStatus(t, "GET", server.URL, nil, http.StatusInternalServerError)
|
status := expectApiStatus(t, "GET", server.URL, nil, http.StatusInternalServerError)
|
||||||
if status.Reason != api.StatusReasonUnknown {
|
if status.Reason != api.StatusReasonUnknown {
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
|
|
||||||
"code.google.com/p/go.net/websocket"
|
"code.google.com/p/go.net/websocket"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/common"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func (w *WatchServer) HandleWS(ws *websocket.Conn) {
|
||||||
}
|
}
|
||||||
err := websocket.JSON.Send(ws, &api.WatchEvent{
|
err := websocket.JSON.Send(ws, &api.WatchEvent{
|
||||||
Type: event.Type,
|
Type: event.Type,
|
||||||
Object: common.Object{event.Object},
|
Object: runtime.Object{event.Object},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Client disconnect.
|
// Client disconnect.
|
||||||
|
@ -160,7 +160,7 @@ func (self *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
err := encoder.Encode(&api.WatchEvent{
|
err := encoder.Encode(&api.WatchEvent{
|
||||||
Type: event.Type,
|
Type: event.Type,
|
||||||
Object: common.Object{event.Object},
|
Object: runtime.Object{event.Object},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Client disconnect.
|
// Client disconnect.
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
"github.com/golang/glog"
|
"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)
|
glog.Errorf("expected type %v, but watch event object had type %v", e, a)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
jsonBase, err := apitools.FindJSONBase(event.Object)
|
jsonBase, err := runtime.FindJSONBase(event.Object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unable to understand watch event %#v", event)
|
glog.Errorf("unable to understand watch event %#v", event)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -27,8 +27,8 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
@ -217,7 +217,7 @@ func (c *RESTClient) doRequest(request *http.Request) ([]byte, error) {
|
||||||
// Did the server give us a status response?
|
// Did the server give us a status response?
|
||||||
isStatusResponse := false
|
isStatusResponse := false
|
||||||
var status api.Status
|
var status api.Status
|
||||||
if err := apitools.DecodeInto(body, &status); err == nil && status.Status != "" {
|
if err := runtime.DecodeInto(body, &status); err == nil && status.Status != "" {
|
||||||
isStatusResponse = true
|
isStatusResponse = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
)
|
)
|
||||||
|
@ -309,7 +309,7 @@ func TestCreateController(t *testing.T) {
|
||||||
|
|
||||||
func body(obj interface{}, raw *string) *string {
|
func body(obj interface{}, raw *string) *string {
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
bs, _ := apitools.Encode(obj)
|
bs, _ := runtime.Encode(obj)
|
||||||
body := string(bs)
|
body := string(bs)
|
||||||
return &body
|
return &body
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ func TestDoRequest(t *testing.T) {
|
||||||
|
|
||||||
func TestDoRequestAccepted(t *testing.T) {
|
func TestDoRequestAccepted(t *testing.T) {
|
||||||
status := api.Status{Status: api.StatusWorking}
|
status := api.Status{Status: api.StatusWorking}
|
||||||
expectedBody, _ := apitools.Encode(status)
|
expectedBody, _ := runtime.Encode(status)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 202,
|
StatusCode: 202,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -508,7 +508,7 @@ func TestDoRequestAccepted(t *testing.T) {
|
||||||
|
|
||||||
func TestDoRequestAcceptedSuccess(t *testing.T) {
|
func TestDoRequestAcceptedSuccess(t *testing.T) {
|
||||||
status := api.Status{Status: api.StatusSuccess}
|
status := api.Status{Status: api.StatusSuccess}
|
||||||
expectedBody, _ := apitools.Encode(status)
|
expectedBody, _ := runtime.Encode(status)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 202,
|
StatusCode: 202,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -528,7 +528,7 @@ func TestDoRequestAcceptedSuccess(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %#v", err)
|
t.Errorf("Unexpected error %#v", err)
|
||||||
}
|
}
|
||||||
statusOut, err := apitools.Decode(body)
|
statusOut, err := runtime.Decode(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %#v", err)
|
t.Errorf("Unexpected error %#v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
|
@ -205,7 +205,7 @@ func (r *Request) Body(obj interface{}) *Request {
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
r.body = t
|
r.body = t
|
||||||
default:
|
default:
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.err = err
|
r.err = err
|
||||||
return r
|
return r
|
||||||
|
@ -318,7 +318,7 @@ func (r Result) Get() (interface{}, error) {
|
||||||
if r.err != nil {
|
if r.err != nil {
|
||||||
return nil, r.err
|
return nil, r.err
|
||||||
}
|
}
|
||||||
return apitools.Decode(r.body)
|
return runtime.Decode(r.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Into stores the result into obj, if possible.
|
// Into stores the result into obj, if possible.
|
||||||
|
@ -326,7 +326,7 @@ func (r Result) Into(obj interface{}) error {
|
||||||
if r.err != nil {
|
if r.err != nil {
|
||||||
return r.err
|
return r.err
|
||||||
}
|
}
|
||||||
return apitools.DecodeInto(r.body, obj)
|
return runtime.DecodeInto(r.body, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns the error executing the request, nil if no error occurred.
|
// Error returns the error executing the request, nil if no error occurred.
|
||||||
|
|
|
@ -29,9 +29,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"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/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
@ -39,7 +38,7 @@ import (
|
||||||
func TestDoRequestNewWay(t *testing.T) {
|
func TestDoRequestNewWay(t *testing.T) {
|
||||||
reqBody := "request body"
|
reqBody := "request body"
|
||||||
expectedObj := &api.Service{Port: 12345}
|
expectedObj := &api.Service{Port: 12345}
|
||||||
expectedBody, _ := apitools.Encode(expectedObj)
|
expectedBody, _ := runtime.Encode(expectedObj)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -72,9 +71,9 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||||
|
|
||||||
func TestDoRequestNewWayReader(t *testing.T) {
|
func TestDoRequestNewWayReader(t *testing.T) {
|
||||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||||
reqBodyExpected, _ := apitools.Encode(reqObj)
|
reqBodyExpected, _ := runtime.Encode(reqObj)
|
||||||
expectedObj := &api.Service{Port: 12345}
|
expectedObj := &api.Service{Port: 12345}
|
||||||
expectedBody, _ := apitools.Encode(expectedObj)
|
expectedBody, _ := runtime.Encode(expectedObj)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -109,9 +108,9 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
||||||
|
|
||||||
func TestDoRequestNewWayObj(t *testing.T) {
|
func TestDoRequestNewWayObj(t *testing.T) {
|
||||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||||
reqBodyExpected, _ := apitools.Encode(reqObj)
|
reqBodyExpected, _ := runtime.Encode(reqObj)
|
||||||
expectedObj := &api.Service{Port: 12345}
|
expectedObj := &api.Service{Port: 12345}
|
||||||
expectedBody, _ := apitools.Encode(expectedObj)
|
expectedBody, _ := runtime.Encode(expectedObj)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -145,7 +144,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
||||||
|
|
||||||
func TestDoRequestNewWayFile(t *testing.T) {
|
func TestDoRequestNewWayFile(t *testing.T) {
|
||||||
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||||
reqBodyExpected, err := apitools.Encode(reqObj)
|
reqBodyExpected, err := runtime.Encode(reqObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +160,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedObj := &api.Service{Port: 12345}
|
expectedObj := &api.Service{Port: 12345}
|
||||||
expectedBody, _ := apitools.Encode(expectedObj)
|
expectedBody, _ := runtime.Encode(expectedObj)
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(expectedBody),
|
ResponseBody: string(expectedBody),
|
||||||
|
@ -296,7 +295,7 @@ func TestPolling(t *testing.T) {
|
||||||
|
|
||||||
callNumber := 0
|
callNumber := 0
|
||||||
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
data, err := apitools.Encode(objects[callNumber])
|
data, err := runtime.Encode(objects[callNumber])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected encode error")
|
t.Errorf("Unexpected encode error")
|
||||||
}
|
}
|
||||||
|
@ -402,7 +401,7 @@ func TestWatch(t *testing.T) {
|
||||||
|
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
for _, item := range table {
|
for _, item := range table {
|
||||||
encoder.Encode(&api.WatchEvent{item.t, common.Object{item.obj}})
|
encoder.Encode(&api.WatchEvent{item.t, runtime.Object{item.obj}})
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -27,9 +27,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
|
@ -109,7 +109,7 @@ func validateSyncReplication(t *testing.T, fakePodControl *FakePodControl, expec
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncReplicationControllerDoesNothing(t *testing.T) {
|
func TestSyncReplicationControllerDoesNothing(t *testing.T) {
|
||||||
body, _ := apitools.Encode(newPodList(2))
|
body, _ := runtime.Encode(newPodList(2))
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(body),
|
ResponseBody: string(body),
|
||||||
|
@ -129,7 +129,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncReplicationControllerDeletes(t *testing.T) {
|
func TestSyncReplicationControllerDeletes(t *testing.T) {
|
||||||
body, _ := apitools.Encode(newPodList(2))
|
body, _ := runtime.Encode(newPodList(2))
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(body),
|
ResponseBody: string(body),
|
||||||
|
@ -149,7 +149,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncReplicationControllerCreates(t *testing.T) {
|
func TestSyncReplicationControllerCreates(t *testing.T) {
|
||||||
body, _ := apitools.Encode(newPodList(0))
|
body, _ := runtime.Encode(newPodList(0))
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(body),
|
ResponseBody: string(body),
|
||||||
|
@ -169,7 +169,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateReplica(t *testing.T) {
|
func TestCreateReplica(t *testing.T) {
|
||||||
body, _ := apitools.Encode(api.Pod{})
|
body, _ := runtime.Encode(api.Pod{})
|
||||||
fakeHandler := util.FakeHandler{
|
fakeHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: string(body),
|
ResponseBody: string(body),
|
||||||
|
@ -292,7 +292,7 @@ func TestSyncronize(t *testing.T) {
|
||||||
}
|
}
|
||||||
fakeControllerHandler := util.FakeHandler{
|
fakeControllerHandler := util.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: apitools.EncodeOrDie(&api.ReplicationControllerList{
|
ResponseBody: runtime.EncodeOrDie(&api.ReplicationControllerList{
|
||||||
Items: []api.ReplicationController{
|
Items: []api.ReplicationController{
|
||||||
controllerSpec1,
|
controllerSpec1,
|
||||||
controllerSpec2,
|
controllerSpec2,
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
|
@ -44,11 +44,11 @@ func (p *Parser) ToWireFormat(data []byte, storage string) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
obj := reflect.New(prototypeType).Interface()
|
obj := reflect.New(prototypeType).Interface()
|
||||||
err := apitools.DecodeInto(data, obj)
|
err := runtime.DecodeInto(data, obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return apitools.Encode(obj)
|
return runtime.Encode(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) SupportedWireStorage() []string {
|
func (p *Parser) SupportedWireStorage() []string {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ func TestParseBadStorage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DoParseTest(t *testing.T, storage string, obj interface{}, p *Parser) {
|
func DoParseTest(t *testing.T, storage string, obj interface{}, p *Parser) {
|
||||||
jsonData, _ := apitools.Encode(obj)
|
jsonData, _ := runtime.Encode(obj)
|
||||||
yamlData, _ := yaml.Marshal(obj)
|
yamlData, _ := yaml.Marshal(obj)
|
||||||
t.Logf("Intermediate yaml:\n%v\n", string(yamlData))
|
t.Logf("Intermediate yaml:\n%v\n", string(yamlData))
|
||||||
t.Logf("Intermediate json:\n%v\n", string(jsonData))
|
t.Logf("Intermediate json:\n%v\n", string(jsonData))
|
||||||
|
@ -120,8 +120,8 @@ type TestParseType struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseCustomType(t *testing.T) {
|
func TestParseCustomType(t *testing.T) {
|
||||||
apitools.AddKnownTypes("", TestParseType{})
|
runtime.AddKnownTypes("", TestParseType{})
|
||||||
apitools.AddKnownTypes("v1beta1", TestParseType{})
|
runtime.AddKnownTypes("v1beta1", TestParseType{})
|
||||||
parser := NewParser(map[string]interface{}{
|
parser := NewParser(map[string]interface{}{
|
||||||
"custom": TestParseType{},
|
"custom": TestParseType{},
|
||||||
})
|
})
|
||||||
|
|
|
@ -21,8 +21,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.
|
// ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.
|
||||||
|
@ -53,7 +53,7 @@ func (s *ProxyServer) Serve() error {
|
||||||
func (s *ProxyServer) doError(w http.ResponseWriter, err error) {
|
func (s *ProxyServer) doError(w http.ResponseWriter, err error) {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Header().Add("Content-type", "application/json")
|
w.Header().Add("Content-type", "application/json")
|
||||||
data, _ := apitools.Encode(api.Status{
|
data, _ := runtime.Encode(api.Status{
|
||||||
Status: api.StatusFailure,
|
Status: api.StatusFailure,
|
||||||
Message: fmt.Sprintf("internal error: %#v", err),
|
Message: fmt.Sprintf("internal error: %#v", err),
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,8 +26,8 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
)
|
)
|
||||||
|
@ -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.
|
// 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 {
|
func (i *IdentityPrinter) PrintObj(obj interface{}, output io.Writer) error {
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ func (h *HumanReadablePrinter) Print(data []byte, output io.Writer) error {
|
||||||
return fmt.Errorf("unexpected object with no 'kind' field: %s", data)
|
return fmt.Errorf("unexpected object with no 'kind' field: %s", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
obj, err := apitools.Decode(data)
|
obj, err := runtime.Decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ type TemplatePrinter struct {
|
||||||
|
|
||||||
// Print parses the data as JSON, and re-formats it with the Go Template.
|
// Print parses the data as JSON, and re-formats it with the Go Template.
|
||||||
func (t *TemplatePrinter) Print(data []byte, w io.Writer) error {
|
func (t *TemplatePrinter) Print(data []byte, w io.Writer) error {
|
||||||
obj, err := apitools.Decode(data)
|
obj, err := runtime.Decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func TestIdentityPrinter(t *testing.T) {
|
||||||
}
|
}
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
printer.PrintObj(obj, buff)
|
printer.PrintObj(obj, buff)
|
||||||
objOut, err := apitools.Decode([]byte(buff.String()))
|
objOut, err := runtime.Decode([]byte(buff.String()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpeted error: %#v", err)
|
t.Errorf("Unexpeted error: %#v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,7 @@ func TestGetEtcdData(t *testing.T) {
|
||||||
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: apitools.EncodeOrDie(&api.ContainerManifestList{
|
Value: runtime.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{{ID: "foo"}},
|
Items: []api.ContainerManifest{{ID: "foo"}},
|
||||||
}),
|
}),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
|
@ -79,7 +79,7 @@ func TestGetEtcd(t *testing.T) {
|
||||||
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: apitools.EncodeOrDie(&api.ContainerManifestList{
|
Value: runtime.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{manifest},
|
Items: []api.ContainerManifest{manifest},
|
||||||
}),
|
}),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
|
@ -113,7 +113,7 @@ func TestWatchEtcd(t *testing.T) {
|
||||||
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{
|
||||||
R: &etcd.Response{
|
R: &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: apitools.EncodeOrDie(&api.ContainerManifestList{}),
|
Value: runtime.EncodeOrDie(&api.ContainerManifestList{}),
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,6 @@ import (
|
||||||
|
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/binding"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/binding"
|
||||||
|
@ -32,6 +31,7 @@ import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
servicecontroller "github.com/GoogleCloudPlatform/kubernetes/pkg/service"
|
servicecontroller "github.com/GoogleCloudPlatform/kubernetes/pkg/service"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
|
||||||
|
@ -136,5 +136,5 @@ func (m *Master) API_v1beta1() (map[string]apiserver.RESTStorage, apiserver.Code
|
||||||
for k, v := range m.storage {
|
for k, v := range m.storage {
|
||||||
storage[k] = v
|
storage[k] = v
|
||||||
}
|
}
|
||||||
return storage, apitools.Codec
|
return storage, runtime.Codec
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
|
@ -133,7 +133,7 @@ func (s ConfigSourceEtcd) GetServices() ([]api.Service, []api.Endpoints, error)
|
||||||
// and create a Service entry for it.
|
// and create a Service entry for it.
|
||||||
for i, node := range response.Node.Nodes {
|
for i, node := range response.Node.Nodes {
|
||||||
var svc api.Service
|
var svc api.Service
|
||||||
err = apitools.DecodeInto([]byte(node.Value), &svc)
|
err = runtime.DecodeInto([]byte(node.Value), &svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to load Service: %s (%#v)", node.Value, err)
|
glog.Errorf("Failed to load Service: %s (%#v)", node.Value, err)
|
||||||
continue
|
continue
|
||||||
|
@ -166,7 +166,7 @@ func (s ConfigSourceEtcd) GetEndpoints(service string) (api.Endpoints, error) {
|
||||||
}
|
}
|
||||||
// Parse all the endpoint specifications in this value.
|
// Parse all the endpoint specifications in this value.
|
||||||
var e api.Endpoints
|
var e api.Endpoints
|
||||||
err = apitools.DecodeInto([]byte(response.Node.Value), &e)
|
err = runtime.DecodeInto([]byte(response.Node.Value), &e)
|
||||||
return e, err
|
return e, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func etcdResponseToService(response *etcd.Response) (*api.Service, error) {
|
||||||
return nil, fmt.Errorf("invalid response from etcd: %#v", response)
|
return nil, fmt.Errorf("invalid response from etcd: %#v", response)
|
||||||
}
|
}
|
||||||
var svc api.Service
|
var svc api.Service
|
||||||
err := apitools.DecodeInto([]byte(response.Node.Value), &svc)
|
err := runtime.DecodeInto([]byte(response.Node.Value), &svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
|
||||||
func (s ConfigSourceEtcd) ProcessEndpointResponse(response *etcd.Response) {
|
func (s ConfigSourceEtcd) ProcessEndpointResponse(response *etcd.Response) {
|
||||||
glog.Infof("Processing a change in endpoint configuration... %s", *response)
|
glog.Infof("Processing a change in endpoint configuration... %s", *response)
|
||||||
var endpoints api.Endpoints
|
var endpoints api.Endpoints
|
||||||
err := apitools.DecodeInto([]byte(response.Node.Value), &endpoints)
|
err := runtime.DecodeInto([]byte(response.Node.Value), &endpoints)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to parse service out of etcd key: %v : %+v", response.Node.Value, err)
|
glog.Errorf("Failed to parse service out of etcd key: %v : %+v", response.Node.Value, err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -24,8 +24,8 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewBindingStorage(t *testing.T) {
|
func TestNewBindingStorage(t *testing.T) {
|
||||||
|
@ -38,12 +38,12 @@ func TestNewBindingStorage(t *testing.T) {
|
||||||
PodID: "foo",
|
PodID: "foo",
|
||||||
Host: "bar",
|
Host: "bar",
|
||||||
}
|
}
|
||||||
body, err := apitools.Encode(binding)
|
body, err := runtime.Encode(binding)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected encode error %v", err)
|
t.Fatalf("Unexpected encode error %v", err)
|
||||||
}
|
}
|
||||||
obj := b.New()
|
obj := b.New()
|
||||||
err = apitools.DecodeInto(body, obj)
|
err = runtime.DecodeInto(body, obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestListControllersError(t *testing.T) {
|
func TestListControllersError(t *testing.T) {
|
||||||
|
@ -112,13 +112,13 @@ func TestControllerDecode(t *testing.T) {
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
body, err := apitools.Encode(controller)
|
body, err := runtime.Encode(controller)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerOut := storage.New()
|
controllerOut := storage.New()
|
||||||
if err := apitools.DecodeInto(body, controllerOut); err != nil {
|
if err := runtime.DecodeInto(body, controllerOut); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ func NewRegistry(client tools.EtcdClient) *Registry {
|
||||||
registry := &Registry{
|
registry := &Registry{
|
||||||
EtcdHelper: tools.EtcdHelper{
|
EtcdHelper: tools.EtcdHelper{
|
||||||
client,
|
client,
|
||||||
apitools.Codec,
|
runtime.Codec,
|
||||||
apitools.ResourceVersioner,
|
runtime.ResourceVersioner,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
registry.manifestFactory = &BasicManifestFactory{
|
registry.manifestFactory = &BasicManifestFactory{
|
||||||
|
|
|
@ -23,9 +23,9 @@ import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
|
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
|
@ -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", apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/pods/foo", runtime.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", apitools.EncodeOrDie(&api.ContainerManifestList{}), 0)
|
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.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{
|
||||||
|
@ -108,7 +108,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var pod api.Pod
|
var pod api.Pod
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &pod)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||||
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
||||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||||
}
|
}
|
||||||
|
@ -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: apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: runtime.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
E: nil,
|
E: nil,
|
||||||
|
@ -235,7 +235,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var pod api.Pod
|
var pod api.Pod
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &pod)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||||
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
|
||||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
||||||
},
|
},
|
||||||
E: tools.EtcdErrorNotFound,
|
E: tools.EtcdErrorNotFound,
|
||||||
}
|
}
|
||||||
fakeClient.Set("/registry/hosts/machine/kubelet", apitools.EncodeOrDie(api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "bar"},
|
{ID: "bar"},
|
||||||
},
|
},
|
||||||
|
@ -300,7 +300,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var pod api.Pod
|
var pod api.Pod
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &pod)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &manifests)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &manifests)
|
||||||
if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" {
|
if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" {
|
||||||
t.Errorf("Unexpected manifest list: %#v", manifests)
|
t.Errorf("Unexpected manifest list: %#v", manifests)
|
||||||
}
|
}
|
||||||
|
@ -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, apitools.EncodeOrDie(api.Pod{
|
fakeClient.Set(key, runtime.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", apitools.EncodeOrDie(&api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "foo"},
|
{ID: "foo"},
|
||||||
},
|
},
|
||||||
|
@ -350,7 +350,7 @@ func TestEtcdDeletePod(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var manifests api.ContainerManifestList
|
var manifests api.ContainerManifestList
|
||||||
apitools.DecodeInto([]byte(response.Node.Value), &manifests)
|
runtime.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||||
if len(manifests.Items) != 0 {
|
if len(manifests.Items) != 0 {
|
||||||
t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value)
|
t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value)
|
||||||
}
|
}
|
||||||
|
@ -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, apitools.EncodeOrDie(api.Pod{
|
fakeClient.Set(key, runtime.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", apitools.EncodeOrDie(&api.ContainerManifestList{
|
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(&api.ContainerManifestList{
|
||||||
Items: []api.ContainerManifest{
|
Items: []api.ContainerManifest{
|
||||||
{ID: "foo"},
|
{ID: "foo"},
|
||||||
{ID: "bar"},
|
{ID: "bar"},
|
||||||
|
@ -388,7 +388,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var manifests api.ContainerManifestList
|
var manifests api.ContainerManifestList
|
||||||
apitools.DecodeInto([]byte(response.Node.Value), &manifests)
|
runtime.DecodeInto([]byte(response.Node.Value), &manifests)
|
||||||
if len(manifests.Items) != 1 {
|
if len(manifests.Items) != 1 {
|
||||||
t.Fatalf("Unexpected manifest set: %#v, expected empty", manifests)
|
t.Fatalf("Unexpected manifest set: %#v, expected empty", manifests)
|
||||||
}
|
}
|
||||||
|
@ -445,13 +445,13 @@ func TestEtcdListPods(t *testing.T) {
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Nodes: []*etcd.Node{
|
Nodes: []*etcd.Node{
|
||||||
{
|
{
|
||||||
Value: apitools.EncodeOrDie(api.Pod{
|
Value: runtime.EncodeOrDie(api.Pod{
|
||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
DesiredState: api.PodState{Host: "machine"},
|
DesiredState: api.PodState{Host: "machine"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: apitools.EncodeOrDie(api.Pod{
|
Value: runtime.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: apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: runtime.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}),
|
Value: runtime.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", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/controllers/foo", runtime.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 {
|
||||||
|
@ -607,7 +607,7 @@ func TestEtcdCreateController(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var ctrl api.ReplicationController
|
var ctrl api.ReplicationController
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &ctrl)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &ctrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -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", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/controllers/foo", runtime.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", apitools.EncodeOrDie(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, _ := fakeClient.Set("/registry/controllers/foo", runtime.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: apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}),
|
Value: runtime.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "bar"}}),
|
Value: runtime.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "bar"}}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -699,7 +699,7 @@ func TestEtcdCreateService(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var service api.Service
|
var service api.Service
|
||||||
err = apitools.DecodeInto([]byte(resp.Node.Value), &service)
|
err = runtime.DecodeInto([]byte(resp.Node.Value), &service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -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", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/services/specs/foo", runtime.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", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
fakeClient.Set("/registry/services/specs/foo", runtime.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", apitools.EncodeOrDie(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, _ := fakeClient.Set("/registry/services/specs/foo", runtime.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,7 +812,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", apitools.EncodeOrDie(endpoints), 0)
|
fakeClient.Set("/registry/services/endpoints/foo", runtime.EncodeOrDie(endpoints), 0)
|
||||||
|
|
||||||
got, err := registry.GetEndpoints("foo")
|
got, err := registry.GetEndpoints("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -833,7 +833,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
||||||
Endpoints: []string{"baz", "bar"},
|
Endpoints: []string{"baz", "bar"},
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeClient.Set("/registry/services/endpoints/foo", apitools.EncodeOrDie(api.Endpoints{}), 0)
|
fakeClient.Set("/registry/services/endpoints/foo", runtime.EncodeOrDie(api.Endpoints{}), 0)
|
||||||
|
|
||||||
err := registry.UpdateEndpoints(endpoints)
|
err := registry.UpdateEndpoints(endpoints)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -845,7 +845,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
||||||
t.Fatalf("Unexpected error %v", err)
|
t.Fatalf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
var endpointsOut api.Endpoints
|
var endpointsOut api.Endpoints
|
||||||
err = apitools.DecodeInto([]byte(response.Node.Value), &endpointsOut)
|
err = runtime.DecodeInto([]byte(response.Node.Value), &endpointsOut)
|
||||||
if !reflect.DeepEqual(endpoints, endpointsOut) {
|
if !reflect.DeepEqual(endpoints, endpointsOut) {
|
||||||
t.Errorf("Unexpected endpoints: %#v, expected %#v", endpointsOut, endpoints)
|
t.Errorf("Unexpected endpoints: %#v, expected %#v", endpointsOut, endpoints)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
|
@ -178,13 +178,13 @@ func TestPodDecode(t *testing.T) {
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
body, err := apitools.Encode(expected)
|
body, err := runtime.Encode(expected)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual := storage.New()
|
actual := storage.New()
|
||||||
if err := apitools.DecodeInto(body, actual); err != nil {
|
if err := runtime.DecodeInto(body, actual); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package apitools includes helper functions for working with API objects
|
// Package runtime includes helper functions for working with API objects
|
||||||
// that follow the kubernetes API object conventions, which are:
|
// that follow the kubernetes API object conventions, which are:
|
||||||
//
|
//
|
||||||
// 0. Your API objects have a common metadata struct member, JSONBase.
|
// 0. Your API objects have a common metadata struct member, JSONBase.
|
||||||
|
@ -33,10 +33,12 @@ limitations under the License.
|
||||||
// 7. All of your serializations and deserializations are handled in a
|
// 7. All of your serializations and deserializations are handled in a
|
||||||
// centralized place.
|
// centralized place.
|
||||||
//
|
//
|
||||||
// Package apitools provides a conversion helper to make 5 easy, and the
|
// Package runtime provides a conversion helper to make 5 easy, and the
|
||||||
// Encode/Decode/DecodeInto trio to accomplish 7. You can also register
|
// Encode/Decode/DecodeInto trio to accomplish 7. You can also register
|
||||||
// additional "codecs" which use a version of your choice. It's
|
// additional "codecs" which use a version of your choice. It's
|
||||||
// recommended that you register your types with apitools in your
|
// recommended that you register your types with runtime in your
|
||||||
// package's init function.
|
// package's init function.
|
||||||
//
|
//
|
||||||
package apitools
|
// As a bonus, a few common types useful from all api objects and versions
|
||||||
|
// are provided in types.go.
|
||||||
|
package runtime
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package apitools
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package apitools_test
|
package runtime_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEncode_NonPtr(t *testing.T) {
|
func TestEncode_NonPtr(t *testing.T) {
|
||||||
|
@ -30,8 +30,8 @@ func TestEncode_NonPtr(t *testing.T) {
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
obj2, err2 := apitools.Decode(data)
|
obj2, err2 := runtime.Decode(data)
|
||||||
if err != nil || err2 != nil {
|
if err != nil || err2 != nil {
|
||||||
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ func TestEncode_Ptr(t *testing.T) {
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := apitools.Encode(obj)
|
data, err := runtime.Encode(obj)
|
||||||
obj2, err2 := apitools.Decode(data)
|
obj2, err2 := runtime.Decode(data)
|
||||||
if err != nil || err2 != nil {
|
if err != nil || err2 != nil {
|
||||||
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
t.Fatalf("Failure: '%v' '%v'", err, err2)
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,11 @@ func TestEncode_Ptr(t *testing.T) {
|
||||||
|
|
||||||
func TestBadJSONRejection(t *testing.T) {
|
func TestBadJSONRejection(t *testing.T) {
|
||||||
badJSONMissingKind := []byte(`{ }`)
|
badJSONMissingKind := []byte(`{ }`)
|
||||||
if _, err := apitools.Decode(badJSONMissingKind); err == nil {
|
if _, err := runtime.Decode(badJSONMissingKind); err == nil {
|
||||||
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
|
t.Errorf("Did not reject despite lack of kind field: %s", badJSONMissingKind)
|
||||||
}
|
}
|
||||||
badJSONUnknownType := []byte(`{"kind": "bar"}`)
|
badJSONUnknownType := []byte(`{"kind": "bar"}`)
|
||||||
if _, err1 := apitools.Decode(badJSONUnknownType); err1 == nil {
|
if _, err1 := runtime.Decode(badJSONUnknownType); err1 == nil {
|
||||||
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
|
t.Errorf("Did not reject despite use of unknown type: %s", badJSONUnknownType)
|
||||||
}
|
}
|
||||||
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)
|
/*badJSONKindMismatch := []byte(`{"kind": "Pod"}`)
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package apitools
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package apitools
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -126,7 +126,7 @@ func TestResourceVersionerOfAPI(t *testing.T) {
|
||||||
Object interface{}
|
Object interface{}
|
||||||
Expected uint64
|
Expected uint64
|
||||||
}{
|
}{
|
||||||
"pointer to api object with version": {&Service{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
|
"pointer to api object with version": {&MyAPIObject{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
|
||||||
}
|
}
|
||||||
for key, testCase := range setCases {
|
for key, testCase := range setCases {
|
||||||
if err := versioning.SetResourceVersion(testCase.Object, 5); err != nil {
|
if err := versioning.SetResourceVersion(testCase.Object, 5); err != nil {
|
||||||
|
@ -145,8 +145,8 @@ func TestResourceVersionerOfAPI(t *testing.T) {
|
||||||
Object interface{}
|
Object interface{}
|
||||||
Expected uint64
|
Expected uint64
|
||||||
}{
|
}{
|
||||||
"empty api object": {Service{}, 0},
|
"empty api object": {MyAPIObject{}, 0},
|
||||||
"api object with version": {Service{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
|
"api object with version": {MyAPIObject{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
|
||||||
}
|
}
|
||||||
for key, testCase := range failingSetCases {
|
for key, testCase := range failingSetCases {
|
||||||
if err := versioning.SetResourceVersion(testCase.Object, 5); err == nil {
|
if err := versioning.SetResourceVersion(testCase.Object, 5); err == nil {
|
|
@ -14,12 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package common
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Encode()/Decode() are the canonical way of converting an API object to/from
|
// Encode()/Decode() are the canonical way of converting an API object to/from
|
||||||
|
@ -35,7 +33,7 @@ func (a *Object) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
obj, err := apitools.Decode(b)
|
obj, err := Decode(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -50,7 +48,7 @@ func (a Object) MarshalJSON() ([]byte, error) {
|
||||||
return []byte("null"), nil
|
return []byte("null"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return apitools.Encode(a.Object)
|
return Encode(a.Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetYAML implements the yaml.Setter interface.
|
// SetYAML implements the yaml.Setter interface.
|
||||||
|
@ -69,7 +67,7 @@ func (a *Object) SetYAML(tag string, value interface{}) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("yaml can't reverse its own object")
|
panic("yaml can't reverse its own object")
|
||||||
}
|
}
|
||||||
obj, err := apitools.Decode(b)
|
obj, err := Decode(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -84,7 +82,7 @@ func (a Object) GetYAML() (tag string, value interface{}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Encode returns JSON, which is conveniently a subset of YAML.
|
// Encode returns JSON, which is conveniently a subset of YAML.
|
||||||
v, err := apitools.Encode(a.Object)
|
v, err := Encode(a.Object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("impossible to encode API object!")
|
panic("impossible to encode API object!")
|
||||||
}
|
}
|
|
@ -14,14 +14,12 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package common
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestObject(t *testing.T) {
|
func TestObject(t *testing.T) {
|
||||||
|
@ -30,8 +28,8 @@ func TestObject(t *testing.T) {
|
||||||
Object Object `yaml:"object,omitempty" json:"object,omitempty"`
|
Object Object `yaml:"object,omitempty" json:"object,omitempty"`
|
||||||
EmptyObject Object `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
|
EmptyObject Object `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
|
||||||
}
|
}
|
||||||
apitools.AddKnownTypes("", EmbeddedTest{})
|
AddKnownTypes("", EmbeddedTest{})
|
||||||
apitools.AddKnownTypes("v1beta1", EmbeddedTest{})
|
AddKnownTypes("v1beta1", EmbeddedTest{})
|
||||||
|
|
||||||
outer := &EmbeddedTest{
|
outer := &EmbeddedTest{
|
||||||
JSONBase: JSONBase{ID: "outer"},
|
JSONBase: JSONBase{ID: "outer"},
|
||||||
|
@ -42,14 +40,14 @@ func TestObject(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wire, err := apitools.Encode(outer)
|
wire, err := Encode(outer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected encode error '%v'", err)
|
t.Fatalf("Unexpected encode error '%v'", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Wire format is:\n%v\n", string(wire))
|
t.Logf("Wire format is:\n%v\n", string(wire))
|
||||||
|
|
||||||
decoded, err := apitools.Decode(wire)
|
decoded, err := Decode(wire)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected decode error %v", err)
|
t.Fatalf("Unexpected decode error %v", err)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +56,7 @@ func TestObject(t *testing.T) {
|
||||||
t.Errorf("Expected: %#v but got %#v", e, a)
|
t.Errorf("Expected: %#v but got %#v", e, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test JSON decoding, too, since apitools.Decode uses yaml unmarshalling.
|
// test JSON decoding, too, since Decode uses yaml unmarshalling.
|
||||||
var decodedViaJSON EmbeddedTest
|
var decodedViaJSON EmbeddedTest
|
||||||
err = json.Unmarshal(wire, &decodedViaJSON)
|
err = json.Unmarshal(wire, &decodedViaJSON)
|
||||||
if err != nil {
|
if err != nil {
|
|
@ -14,16 +14,19 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package common
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Note that the types provided in this file are not versioned and are intended to be
|
||||||
|
// safe to use from within all versions of every API object.
|
||||||
|
|
||||||
// JSONBase is shared by all top level objects. The proper way to use it is to inline it in your type,
|
// JSONBase is shared by all top level objects. The proper way to use it is to inline it in your type,
|
||||||
// like this:
|
// like this:
|
||||||
// type MyAwesomeAPIObject struct {
|
// type MyAwesomeAPIObject struct {
|
||||||
// common.JSONBase `yaml:",inline" json:",inline"`
|
// runtime.JSONBase `yaml:",inline" json:",inline"`
|
||||||
// ... // other fields
|
// ... // other fields
|
||||||
// }
|
// }
|
||||||
//
|
//
|
|
@ -24,8 +24,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"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/api/v1beta1"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
|
||||||
|
|
||||||
expect := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
expect := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
|
||||||
go func() {
|
go func() {
|
||||||
err := encoder.Encode(api.WatchEvent{watch.Added, common.Object{expect}})
|
err := encoder.Encode(api.WatchEvent{watch.Added, runtime.Object{expect}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error %v", err)
|
t.Errorf("Unexpected error %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
@ -41,8 +41,8 @@ type TestResource struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var scheme *conversion.Scheme
|
var scheme *conversion.Scheme
|
||||||
var codec = apitools.Codec
|
var codec = runtime.Codec
|
||||||
var versioner = apitools.ResourceVersioner
|
var versioner = runtime.ResourceVersioner
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
scheme = conversion.NewScheme()
|
scheme = conversion.NewScheme()
|
||||||
|
@ -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: apitools.EncodeOrDie(obj),
|
Value: runtime.EncodeOrDie(obj),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -236,7 +236,7 @@ func TestAtomicUpdate(t *testing.T) {
|
||||||
fakeClient := NewFakeEtcdClient(t)
|
fakeClient := NewFakeEtcdClient(t)
|
||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
codec := scheme
|
codec := scheme
|
||||||
helper := EtcdHelper{fakeClient, codec, apitools.NewJSONBaseResourceVersioner()}
|
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
|
||||||
|
|
||||||
// Create a new node.
|
// Create a new node.
|
||||||
fakeClient.ExpectNotFoundGet("/some/key")
|
fakeClient.ExpectNotFoundGet("/some/key")
|
||||||
|
@ -290,7 +290,7 @@ func TestAtomicUpdate(t *testing.T) {
|
||||||
func TestAtomicUpdateNoChange(t *testing.T) {
|
func TestAtomicUpdateNoChange(t *testing.T) {
|
||||||
fakeClient := NewFakeEtcdClient(t)
|
fakeClient := NewFakeEtcdClient(t)
|
||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
helper := EtcdHelper{fakeClient, scheme, apitools.NewJSONBaseResourceVersioner()}
|
helper := EtcdHelper{fakeClient, scheme, runtime.NewJSONBaseResourceVersioner()}
|
||||||
|
|
||||||
// Create a new node.
|
// Create a new node.
|
||||||
fakeClient.ExpectNotFoundGet("/some/key")
|
fakeClient.ExpectNotFoundGet("/some/key")
|
||||||
|
@ -322,7 +322,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
|
||||||
fakeClient := NewFakeEtcdClient(t)
|
fakeClient := NewFakeEtcdClient(t)
|
||||||
fakeClient.TestIndex = true
|
fakeClient.TestIndex = true
|
||||||
codec := scheme
|
codec := scheme
|
||||||
helper := EtcdHelper{fakeClient, codec, apitools.NewJSONBaseResourceVersioner()}
|
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
|
||||||
|
|
||||||
fakeClient.ExpectNotFoundGet("/some/key")
|
fakeClient.ExpectNotFoundGet("/some/key")
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
@ -48,62 +48,62 @@ func TestWatchInterpretations(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
"create": {
|
"create": {
|
||||||
actions: []string{"create", "get"},
|
actions: []string{"create", "get"},
|
||||||
nodeValue: apitools.EncodeOrDie(podBar),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podFoo),
|
nodeValue: runtime.EncodeOrDie(podFoo),
|
||||||
expectEmit: false,
|
expectEmit: false,
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
actions: []string{"delete"},
|
actions: []string{"delete"},
|
||||||
prevNodeValue: apitools.EncodeOrDie(podBar),
|
prevNodeValue: runtime.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: apitools.EncodeOrDie(podFoo),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podBar),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podFoo),
|
prevNodeValue: runtime.EncodeOrDie(podFoo),
|
||||||
nodeValue: apitools.EncodeOrDie(podBar),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podBar),
|
prevNodeValue: runtime.EncodeOrDie(podBar),
|
||||||
nodeValue: apitools.EncodeOrDie(podFoo),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podBar),
|
prevNodeValue: runtime.EncodeOrDie(podBar),
|
||||||
nodeValue: apitools.EncodeOrDie(podBaz),
|
nodeValue: runtime.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: apitools.EncodeOrDie(podFoo),
|
nodeValue: runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
Value: string(runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
Value: string(runtime.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(apitools.EncodeOrDie(&api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
|
Value: string(runtime.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: apitools.EncodeOrDie(pod),
|
Value: runtime.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: apitools.EncodeOrDie(pod),
|
Value: runtime.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: apitools.EncodeOrDie(pod),
|
Value: runtime.EncodeOrDie(pod),
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
Nodes: etcd.Nodes{},
|
Nodes: etcd.Nodes{},
|
||||||
},
|
},
|
||||||
&etcd.Node{
|
&etcd.Node{
|
||||||
Value: apitools.EncodeOrDie(pod),
|
Value: runtime.EncodeOrDie(pod),
|
||||||
CreatedIndex: 2,
|
CreatedIndex: 2,
|
||||||
ModifiedIndex: 2,
|
ModifiedIndex: 2,
|
||||||
Nodes: etcd.Nodes{},
|
Nodes: etcd.Nodes{},
|
||||||
|
|
|
@ -24,10 +24,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
@ -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: apitools.EncodeOrDie(ml),
|
ResponseBody: runtime.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: apitools.EncodeOrDie(testPod),
|
ResponseBody: runtime.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 := apitools.EncodeOrDie(item.binding)
|
expectedBody := runtime.EncodeOrDie(item.binding)
|
||||||
handler.ValidateRequest(t, "/api/v1beta1/bindings", "POST", &expectedBody)
|
handler.ValidateRequest(t, "/api/v1beta1/bindings", "POST", &expectedBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apitools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
@ -84,9 +84,9 @@ func TestExtractObj(t *testing.T) {
|
||||||
|
|
||||||
func TestWatch(t *testing.T) {
|
func TestWatch(t *testing.T) {
|
||||||
client := newEtcdClient()
|
client := newEtcdClient()
|
||||||
helper := tools.EtcdHelper{Client: client, Codec: apitools.Codec, ResourceVersioner: apitools.ResourceVersioner}
|
helper := tools.EtcdHelper{Client: client, Codec: runtime.Codec, ResourceVersioner: runtime.ResourceVersioner}
|
||||||
withEtcdKey(func(key string) {
|
withEtcdKey(func(key string) {
|
||||||
resp, err := client.Set(key, apitools.EncodeOrDie(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
|
resp, err := client.Set(key, runtime.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