mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #1117 from lavalamp/fixApi
Invert api and api/v1beta1 dependencies
This commit is contained in:
commit
2d8e160775
@ -25,6 +25,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
)
|
)
|
||||||
@ -65,22 +64,6 @@ func init() {
|
|||||||
Endpoints{},
|
Endpoints{},
|
||||||
Binding{},
|
Binding{},
|
||||||
)
|
)
|
||||||
AddKnownTypes("v1beta1",
|
|
||||||
v1beta1.PodList{},
|
|
||||||
v1beta1.Pod{},
|
|
||||||
v1beta1.ReplicationControllerList{},
|
|
||||||
v1beta1.ReplicationController{},
|
|
||||||
v1beta1.ServiceList{},
|
|
||||||
v1beta1.Service{},
|
|
||||||
v1beta1.MinionList{},
|
|
||||||
v1beta1.Minion{},
|
|
||||||
v1beta1.Status{},
|
|
||||||
v1beta1.ServerOpList{},
|
|
||||||
v1beta1.ServerOp{},
|
|
||||||
v1beta1.ContainerManifestList{},
|
|
||||||
v1beta1.Endpoints{},
|
|
||||||
v1beta1.Binding{},
|
|
||||||
)
|
|
||||||
|
|
||||||
Codec = conversionScheme
|
Codec = conversionScheme
|
||||||
ResourceVersioner = NewJSONBaseResourceVersioner()
|
ResourceVersioner = NewJSONBaseResourceVersioner()
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package api
|
package api_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -23,6 +23,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"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"
|
||||||
@ -32,7 +34,7 @@ var fuzzIters = flag.Int("fuzz_iters", 50, "How many fuzzing iterations to do.")
|
|||||||
|
|
||||||
// apiObjectFuzzer can randomly populate api objects.
|
// apiObjectFuzzer can randomly populate api objects.
|
||||||
var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||||
func(j *JSONBase, c fuzz.Continue) {
|
func(j *api.JSONBase, c fuzz.Continue) {
|
||||||
// We have to customize the randomization of JSONBases because their
|
// We have to customize the randomization of JSONBases because their
|
||||||
// APIVersion and Kind must remain blank in memory.
|
// APIVersion and Kind must remain blank in memory.
|
||||||
j.APIVersion = ""
|
j.APIVersion = ""
|
||||||
@ -105,20 +107,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 := FindJSONBase(source)
|
j, err := api.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 := Encode(source)
|
data, err := api.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 := Decode(data)
|
obj2, err := api.Decode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v: %v", name, err)
|
t.Errorf("%v: %v", name, err)
|
||||||
return
|
return
|
||||||
@ -129,7 +131,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 = DecodeInto(data, obj3)
|
err = api.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
|
||||||
@ -142,22 +144,21 @@ func runTest(t *testing.T, source interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTypes(t *testing.T) {
|
func TestTypes(t *testing.T) {
|
||||||
// TODO: auto-fill all fields.
|
|
||||||
table := []interface{}{
|
table := []interface{}{
|
||||||
&PodList{},
|
&api.PodList{},
|
||||||
&Pod{},
|
&api.Pod{},
|
||||||
&ServiceList{},
|
&api.ServiceList{},
|
||||||
&Service{},
|
&api.Service{},
|
||||||
&ReplicationControllerList{},
|
&api.ReplicationControllerList{},
|
||||||
&ReplicationController{},
|
&api.ReplicationController{},
|
||||||
&MinionList{},
|
&api.MinionList{},
|
||||||
&Minion{},
|
&api.Minion{},
|
||||||
&Status{},
|
&api.Status{},
|
||||||
&ServerOpList{},
|
&api.ServerOpList{},
|
||||||
&ServerOp{},
|
&api.ServerOp{},
|
||||||
&ContainerManifestList{},
|
&api.ContainerManifestList{},
|
||||||
&Endpoints{},
|
&api.Endpoints{},
|
||||||
&Binding{},
|
&api.Binding{},
|
||||||
}
|
}
|
||||||
for _, item := range table {
|
for _, item := range table {
|
||||||
// Try a few times, since runTest uses random values.
|
// Try a few times, since runTest uses random values.
|
||||||
@ -168,16 +169,16 @@ func TestTypes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEncode_NonPtr(t *testing.T) {
|
func TestEncode_NonPtr(t *testing.T) {
|
||||||
pod := Pod{
|
pod := api.Pod{
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := Encode(obj)
|
data, err := api.Encode(obj)
|
||||||
obj2, err2 := Decode(data)
|
obj2, err2 := api.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)
|
||||||
}
|
}
|
||||||
if _, ok := obj2.(*Pod); !ok {
|
if _, ok := obj2.(*api.Pod); !ok {
|
||||||
t.Fatalf("Got wrong type")
|
t.Fatalf("Got wrong type")
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(obj2, &pod) {
|
if !reflect.DeepEqual(obj2, &pod) {
|
||||||
@ -186,16 +187,16 @@ func TestEncode_NonPtr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEncode_Ptr(t *testing.T) {
|
func TestEncode_Ptr(t *testing.T) {
|
||||||
pod := &Pod{
|
pod := &api.Pod{
|
||||||
Labels: map[string]string{"name": "foo"},
|
Labels: map[string]string{"name": "foo"},
|
||||||
}
|
}
|
||||||
obj := interface{}(pod)
|
obj := interface{}(pod)
|
||||||
data, err := Encode(obj)
|
data, err := api.Encode(obj)
|
||||||
obj2, err2 := Decode(data)
|
obj2, err2 := api.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)
|
||||||
}
|
}
|
||||||
if _, ok := obj2.(*Pod); !ok {
|
if _, ok := obj2.(*api.Pod); !ok {
|
||||||
t.Fatalf("Got wrong type")
|
t.Fatalf("Got wrong type")
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(obj2, pod) {
|
if !reflect.DeepEqual(obj2, pod) {
|
||||||
@ -205,11 +206,11 @@ func TestEncode_Ptr(t *testing.T) {
|
|||||||
|
|
||||||
func TestBadJSONRejection(t *testing.T) {
|
func TestBadJSONRejection(t *testing.T) {
|
||||||
badJSONMissingKind := []byte(`{ }`)
|
badJSONMissingKind := []byte(`{ }`)
|
||||||
if _, err := Decode(badJSONMissingKind); err == nil {
|
if _, err := api.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 := Decode(badJSONUnknownType); err1 == nil {
|
if _, err1 := api.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,25 +14,28 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package api
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
// Alias this so it can be easily changed when we cut the next version.
|
||||||
|
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
// Also import under original name for Convert and AddConversionFuncs.
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// TODO: Consider inverting dependency chain-- imagine v1beta1 package
|
// Shortcut for sub-conversions. TODO: This should possibly be refactored
|
||||||
// registering all of these functions. Then, if you want to be able to understand
|
// such that this convert function is passed to each conversion func.
|
||||||
// v1beta1 objects, you just import that package for its side effects.
|
Convert := api.Convert
|
||||||
AddConversionFuncs(
|
api.AddConversionFuncs(
|
||||||
// EnvVar's Key is deprecated in favor of Name.
|
// EnvVar's Key is deprecated in favor of Name.
|
||||||
func(in *EnvVar, out *v1beta1.EnvVar) error {
|
func(in *newer.EnvVar, out *EnvVar) error {
|
||||||
out.Value = in.Value
|
out.Value = in.Value
|
||||||
out.Key = in.Name
|
out.Key = in.Name
|
||||||
out.Name = in.Name
|
out.Name = in.Name
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *v1beta1.EnvVar, out *EnvVar) error {
|
func(in *EnvVar, out *newer.EnvVar) error {
|
||||||
out.Value = in.Value
|
out.Value = in.Value
|
||||||
if in.Name != "" {
|
if in.Name != "" {
|
||||||
out.Name = in.Name
|
out.Name = in.Name
|
||||||
@ -43,7 +46,7 @@ func init() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Path & MountType are deprecated.
|
// Path & MountType are deprecated.
|
||||||
func(in *VolumeMount, out *v1beta1.VolumeMount) error {
|
func(in *newer.VolumeMount, out *VolumeMount) error {
|
||||||
out.Name = in.Name
|
out.Name = in.Name
|
||||||
out.ReadOnly = in.ReadOnly
|
out.ReadOnly = in.ReadOnly
|
||||||
out.MountPath = in.MountPath
|
out.MountPath = in.MountPath
|
||||||
@ -51,7 +54,7 @@ func init() {
|
|||||||
out.MountType = "" // MountType is ignored.
|
out.MountType = "" // MountType is ignored.
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *v1beta1.VolumeMount, out *VolumeMount) error {
|
func(in *VolumeMount, out *newer.VolumeMount) error {
|
||||||
out.Name = in.Name
|
out.Name = in.Name
|
||||||
out.ReadOnly = in.ReadOnly
|
out.ReadOnly = in.ReadOnly
|
||||||
if in.MountPath == "" {
|
if in.MountPath == "" {
|
||||||
@ -63,13 +66,13 @@ func init() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// MinionList.Items had a wrong name in v1beta1
|
// MinionList.Items had a wrong name in v1beta1
|
||||||
func(in *MinionList, out *v1beta1.MinionList) error {
|
func(in *newer.MinionList, out *MinionList) error {
|
||||||
Convert(&in.JSONBase, &out.JSONBase)
|
Convert(&in.JSONBase, &out.JSONBase)
|
||||||
Convert(&in.Items, &out.Items)
|
Convert(&in.Items, &out.Items)
|
||||||
out.Minions = out.Items
|
out.Minions = out.Items
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *v1beta1.MinionList, out *MinionList) error {
|
func(in *MinionList, out *newer.MinionList) error {
|
||||||
Convert(&in.JSONBase, &out.JSONBase)
|
Convert(&in.JSONBase, &out.JSONBase)
|
||||||
if len(in.Items) == 0 {
|
if len(in.Items) == 0 {
|
||||||
Convert(&in.Minions, &out.Items)
|
Convert(&in.Minions, &out.Items)
|
@ -14,26 +14,29 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package api
|
package v1beta1_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Convert = newer.Convert
|
||||||
|
|
||||||
func TestEnvConversion(t *testing.T) {
|
func TestEnvConversion(t *testing.T) {
|
||||||
nonCanonical := []v1beta1.EnvVar{
|
nonCanonical := []v1beta1.EnvVar{
|
||||||
{Key: "EV"},
|
{Key: "EV"},
|
||||||
{Key: "EV", Name: "EX"},
|
{Key: "EV", Name: "EX"},
|
||||||
}
|
}
|
||||||
canonical := []EnvVar{
|
canonical := []newer.EnvVar{
|
||||||
{Name: "EV"},
|
{Name: "EV"},
|
||||||
{Name: "EX"},
|
{Name: "EX"},
|
||||||
}
|
}
|
||||||
for i := range nonCanonical {
|
for i := range nonCanonical {
|
||||||
var got EnvVar
|
var got newer.EnvVar
|
||||||
err := Convert(&nonCanonical[i], &got)
|
err := Convert(&nonCanonical[i], &got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
@ -61,11 +64,11 @@ func TestEnvConversion(t *testing.T) {
|
|||||||
|
|
||||||
func TestVolumeMountConversionToOld(t *testing.T) {
|
func TestVolumeMountConversionToOld(t *testing.T) {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
in VolumeMount
|
in newer.VolumeMount
|
||||||
out v1beta1.VolumeMount
|
out v1beta1.VolumeMount
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
in: VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
in: newer.VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
||||||
out: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", Path: "/dev/foo", ReadOnly: true},
|
out: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", Path: "/dev/foo", ReadOnly: true},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -85,21 +88,21 @@ func TestVolumeMountConversionToOld(t *testing.T) {
|
|||||||
func TestVolumeMountConversionToNew(t *testing.T) {
|
func TestVolumeMountConversionToNew(t *testing.T) {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
in v1beta1.VolumeMount
|
in v1beta1.VolumeMount
|
||||||
out VolumeMount
|
out newer.VolumeMount
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
in: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
in: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
||||||
out: VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
out: newer.VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
||||||
}, {
|
}, {
|
||||||
in: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", Path: "/dev/bar", ReadOnly: true},
|
in: v1beta1.VolumeMount{Name: "foo", MountPath: "/dev/foo", Path: "/dev/bar", ReadOnly: true},
|
||||||
out: VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
out: newer.VolumeMount{Name: "foo", MountPath: "/dev/foo", ReadOnly: true},
|
||||||
}, {
|
}, {
|
||||||
in: v1beta1.VolumeMount{Name: "foo", Path: "/dev/bar", ReadOnly: true},
|
in: v1beta1.VolumeMount{Name: "foo", Path: "/dev/bar", ReadOnly: true},
|
||||||
out: VolumeMount{Name: "foo", MountPath: "/dev/bar", ReadOnly: true},
|
out: newer.VolumeMount{Name: "foo", MountPath: "/dev/bar", ReadOnly: true},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, item := range table {
|
for _, item := range table {
|
||||||
got := VolumeMount{}
|
got := newer.VolumeMount{}
|
||||||
err := Convert(&item.in, &got)
|
err := Convert(&item.in, &got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
@ -115,39 +118,39 @@ func TestMinionListConversionToNew(t *testing.T) {
|
|||||||
oldMinion := func(id string) v1beta1.Minion {
|
oldMinion := func(id string) v1beta1.Minion {
|
||||||
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
||||||
}
|
}
|
||||||
newMinion := func(id string) Minion {
|
newMinion := func(id string) newer.Minion {
|
||||||
return Minion{JSONBase: JSONBase{ID: id}}
|
return newer.Minion{JSONBase: newer.JSONBase{ID: id}}
|
||||||
}
|
}
|
||||||
oldMinions := []v1beta1.Minion{
|
oldMinions := []v1beta1.Minion{
|
||||||
oldMinion("foo"),
|
oldMinion("foo"),
|
||||||
oldMinion("bar"),
|
oldMinion("bar"),
|
||||||
}
|
}
|
||||||
newMinions := []Minion{
|
newMinions := []newer.Minion{
|
||||||
newMinion("foo"),
|
newMinion("foo"),
|
||||||
newMinion("bar"),
|
newMinion("bar"),
|
||||||
}
|
}
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
oldML *v1beta1.MinionList
|
oldML *v1beta1.MinionList
|
||||||
newML *MinionList
|
newML *newer.MinionList
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
oldML: &v1beta1.MinionList{Items: oldMinions},
|
oldML: &v1beta1.MinionList{Items: oldMinions},
|
||||||
newML: &MinionList{Items: newMinions},
|
newML: &newer.MinionList{Items: newMinions},
|
||||||
}, {
|
}, {
|
||||||
oldML: &v1beta1.MinionList{Minions: oldMinions},
|
oldML: &v1beta1.MinionList{Minions: oldMinions},
|
||||||
newML: &MinionList{Items: newMinions},
|
newML: &newer.MinionList{Items: newMinions},
|
||||||
}, {
|
}, {
|
||||||
oldML: &v1beta1.MinionList{
|
oldML: &v1beta1.MinionList{
|
||||||
Items: oldMinions,
|
Items: oldMinions,
|
||||||
Minions: []v1beta1.Minion{oldMinion("baz")},
|
Minions: []v1beta1.Minion{oldMinion("baz")},
|
||||||
},
|
},
|
||||||
newML: &MinionList{Items: newMinions},
|
newML: &newer.MinionList{Items: newMinions},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range table {
|
for _, item := range table {
|
||||||
got := &MinionList{}
|
got := &newer.MinionList{}
|
||||||
err := Convert(item.oldML, got)
|
err := Convert(item.oldML, got)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
@ -162,19 +165,19 @@ func TestMinionListConversionToOld(t *testing.T) {
|
|||||||
oldMinion := func(id string) v1beta1.Minion {
|
oldMinion := func(id string) v1beta1.Minion {
|
||||||
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
||||||
}
|
}
|
||||||
newMinion := func(id string) Minion {
|
newMinion := func(id string) newer.Minion {
|
||||||
return Minion{JSONBase: JSONBase{ID: id}}
|
return newer.Minion{JSONBase: newer.JSONBase{ID: id}}
|
||||||
}
|
}
|
||||||
oldMinions := []v1beta1.Minion{
|
oldMinions := []v1beta1.Minion{
|
||||||
oldMinion("foo"),
|
oldMinion("foo"),
|
||||||
oldMinion("bar"),
|
oldMinion("bar"),
|
||||||
}
|
}
|
||||||
newMinions := []Minion{
|
newMinions := []newer.Minion{
|
||||||
newMinion("foo"),
|
newMinion("foo"),
|
||||||
newMinion("bar"),
|
newMinion("bar"),
|
||||||
}
|
}
|
||||||
|
|
||||||
newML := &MinionList{Items: newMinions}
|
newML := &newer.MinionList{Items: newMinions}
|
||||||
oldML := &v1beta1.MinionList{
|
oldML := &v1beta1.MinionList{
|
||||||
Items: oldMinions,
|
Items: oldMinions,
|
||||||
Minions: oldMinions,
|
Minions: oldMinions,
|
40
pkg/api/v1beta1/register.go
Normal file
40
pkg/api/v1beta1/register.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
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 v1beta1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
api.AddKnownTypes("v1beta1",
|
||||||
|
PodList{},
|
||||||
|
Pod{},
|
||||||
|
ReplicationControllerList{},
|
||||||
|
ReplicationController{},
|
||||||
|
ServiceList{},
|
||||||
|
Service{},
|
||||||
|
MinionList{},
|
||||||
|
Minion{},
|
||||||
|
Status{},
|
||||||
|
ServerOpList{},
|
||||||
|
ServerOp{},
|
||||||
|
ContainerManifestList{},
|
||||||
|
Endpoints{},
|
||||||
|
Binding{},
|
||||||
|
)
|
||||||
|
}
|
@ -25,7 +25,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
// TODO: remove dependency on api, apiserver should be generic
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOperation(t *testing.T) {
|
func TestOperation(t *testing.T) {
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||||
"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"
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user