Fix references from serializable types to use v1.ObjectMeta

This commit is contained in:
Jordan Liggitt
2016-12-08 16:26:04 -05:00
parent 711986876b
commit fcf5bbccd6
12 changed files with 67 additions and 64 deletions

View File

@@ -39,6 +39,7 @@ import (
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/v1"
apiv1 "k8s.io/kubernetes/pkg/api/v1"
metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/apiserver/filters"
"k8s.io/kubernetes/pkg/apiserver/request"
@@ -317,7 +318,7 @@ func handleInternal(storage map[string]rest.Storage, admissionControl admission.
}
func TestSimpleSetupRight(t *testing.T) {
s := &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "aName"}}
s := &apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: "aName"}}
wire, err := runtime.Encode(codec, s)
if err != nil {
t.Fatal(err)
@@ -470,7 +471,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string, options *ap
var obj runtime.Object = &metav1.Status{Status: metav1.StatusSuccess}
var err error
if storage.injectedFunction != nil {
obj, err = storage.injectedFunction(&apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: id}})
obj, err = storage.injectedFunction(&apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: id}})
}
return obj, err
}
@@ -1119,7 +1120,7 @@ func TestNonEmptyList(t *testing.T) {
simpleStorage := SimpleRESTStorage{
list: []apiservertesting.Simple{
{
ObjectMeta: api.ObjectMeta{Name: "something", Namespace: "other"},
ObjectMeta: apiv1.ObjectMeta{Name: "something", Namespace: "other"},
Other: "foo",
},
},
@@ -1170,7 +1171,7 @@ func TestSelfLinkSkipsEmptyName(t *testing.T) {
simpleStorage := SimpleRESTStorage{
list: []apiservertesting.Simple{
{
ObjectMeta: api.ObjectMeta{Namespace: "other"},
ObjectMeta: apiv1.ObjectMeta{Namespace: "other"},
Other: "foo",
},
},
@@ -1244,7 +1245,7 @@ func TestExport(t *testing.T) {
storage := map[string]rest.Storage{}
simpleStorage := SimpleRESTStorage{
item: apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
ResourceVersion: "1234",
CreationTimestamp: metav1.NewTime(time.Unix(10, 10)),
},
@@ -2177,7 +2178,7 @@ func TestPatch(t *testing.T) {
storage := map[string]rest.Storage{}
ID := "id"
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: "", // update should allow the client to send an empty namespace
UID: "uid",
@@ -2216,7 +2217,7 @@ func TestPatchRequiresMatchingName(t *testing.T) {
storage := map[string]rest.Storage{}
ID := "id"
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: "", // update should allow the client to send an empty namespace
UID: "uid",
@@ -2257,7 +2258,7 @@ func TestUpdate(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: "", // update should allow the client to send an empty namespace
},
@@ -2294,7 +2295,7 @@ func TestUpdateInvokesAdmissionControl(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: api.NamespaceDefault,
},
@@ -2356,7 +2357,7 @@ func TestUpdateAllowsMissingNamespace(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
},
Other: "bar",
@@ -2393,7 +2394,7 @@ func TestUpdateAllowsMismatchedNamespaceOnError(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: "other", // does not match request
},
@@ -2430,7 +2431,7 @@ func TestUpdatePreventsMismatchedNamespace(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: "other",
},
@@ -2465,7 +2466,7 @@ func TestUpdateMissing(t *testing.T) {
defer server.Close()
item := &apiservertesting.Simple{
ObjectMeta: api.ObjectMeta{
ObjectMeta: apiv1.ObjectMeta{
Name: ID,
Namespace: api.NamespaceDefault,
},
@@ -3226,7 +3227,7 @@ func TestUpdateChecksAPIVersion(t *testing.T) {
defer server.Close()
client := http.Client{}
simple := &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "bar"}}
simple := &apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: "bar"}}
data, err := runtime.Encode(newCodec, simple)
if err != nil {
t.Fatalf("unexpected error: %v", err)

View File

@@ -25,7 +25,7 @@ import (
"errors"
"fmt"
codec1978 "github.com/ugorji/go/codec"
pkg2_api "k8s.io/kubernetes/pkg/api"
pkg2_v1 "k8s.io/kubernetes/pkg/api/v1"
pkg1_v1 "k8s.io/kubernetes/pkg/apis/meta/v1"
pkg3_types "k8s.io/kubernetes/pkg/types"
"reflect"
@@ -63,7 +63,7 @@ func init() {
panic(err)
}
if false { // reference the types, but skip this branch at build/run time
var v0 pkg2_api.ObjectMeta
var v0 pkg2_v1.ObjectMeta
var v1 pkg1_v1.TypeMeta
var v2 pkg3_types.UID
var v3 time.Time
@@ -299,7 +299,7 @@ func (x *Simple) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
}
case "metadata":
if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{}
x.ObjectMeta = pkg2_v1.ObjectMeta{}
} else {
yyv23 := &x.ObjectMeta
yyv23.CodecDecodeSelf(d)
@@ -380,7 +380,7 @@ func (x *Simple) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{}
x.ObjectMeta = pkg2_v1.ObjectMeta{}
} else {
yyv30 := &x.ObjectMeta
yyv30.CodecDecodeSelf(d)
@@ -667,7 +667,7 @@ func (x *SimpleRoot) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
}
case "metadata":
if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{}
x.ObjectMeta = pkg2_v1.ObjectMeta{}
} else {
yyv56 := &x.ObjectMeta
yyv56.CodecDecodeSelf(d)
@@ -748,7 +748,7 @@ func (x *SimpleRoot) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{}
x.ObjectMeta = pkg2_v1.ObjectMeta{}
} else {
yyv63 := &x.ObjectMeta
yyv63.CodecDecodeSelf(d)

View File

@@ -17,14 +17,14 @@ limitations under the License.
package testing
import (
"k8s.io/kubernetes/pkg/api"
apiv1 "k8s.io/kubernetes/pkg/api/v1"
metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/runtime/schema"
)
type Simple struct {
metav1.TypeMeta `json:",inline"`
api.ObjectMeta `json:"metadata"`
metav1.TypeMeta `json:",inline"`
apiv1.ObjectMeta `json:"metadata"`
// +optional
Other string `json:"other,omitempty"`
// +optional
@@ -34,8 +34,8 @@ type Simple struct {
func (obj *Simple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
type SimpleRoot struct {
metav1.TypeMeta `json:",inline"`
api.ObjectMeta `json:"metadata"`
metav1.TypeMeta `json:",inline"`
apiv1.ObjectMeta `json:"metadata"`
// +optional
Other string `json:"other,omitempty"`
// +optional

View File

@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
apitesting "k8s.io/kubernetes/pkg/api/testing"
apiv1 "k8s.io/kubernetes/pkg/api/v1"
metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
apiservertesting "k8s.io/kubernetes/pkg/apiserver/testing"
"k8s.io/kubernetes/pkg/fields"
@@ -69,9 +70,9 @@ var watchTestTable = []struct {
t watch.EventType
obj runtime.Object
}{
{watch.Added, &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "foo"}}},
{watch.Modified, &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "bar"}}},
{watch.Deleted, &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "bar"}}},
{watch.Added, &apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: "foo"}}},
{watch.Modified, &apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: "bar"}}},
{watch.Deleted, &apiservertesting.Simple{ObjectMeta: apiv1.ObjectMeta{Name: "bar"}}},
}
var podWatchTestTable = []struct {