mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Rename ID -> Name
This commit is contained in:
@@ -48,10 +48,10 @@ func TestEmbeddedObject(t *testing.T) {
|
||||
s.AddKnownTypeWithName("v1test", "EmbeddedTest", &EmbeddedTestExternal{})
|
||||
|
||||
outer := &EmbeddedTest{
|
||||
TypeMeta: runtime.TypeMeta{ID: "outer"},
|
||||
TypeMeta: runtime.TypeMeta{Name: "outer"},
|
||||
Object: runtime.EmbeddedObject{
|
||||
&EmbeddedTest{
|
||||
TypeMeta: runtime.TypeMeta{ID: "inner"},
|
||||
TypeMeta: runtime.TypeMeta{Name: "inner"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestEmbeddedObject(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected decode error %v", err)
|
||||
}
|
||||
if externalViaJSON.Kind == "" || externalViaJSON.APIVersion == "" || externalViaJSON.ID != "outer" {
|
||||
if externalViaJSON.Kind == "" || externalViaJSON.APIVersion == "" || externalViaJSON.Name != "outer" {
|
||||
t.Errorf("Expected objects to have type info set, got %#v", externalViaJSON)
|
||||
}
|
||||
if !reflect.DeepEqual(externalViaJSON.EmptyObject.RawJSON, []byte("null")) || len(externalViaJSON.Object.RawJSON) == 0 {
|
||||
|
@@ -29,9 +29,9 @@ import (
|
||||
func TestExtractList(t *testing.T) {
|
||||
pl := &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{ID: "1"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "2"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "3"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
},
|
||||
}
|
||||
list, err := runtime.ExtractList(pl)
|
||||
@@ -42,7 +42,7 @@ func TestExtractList(t *testing.T) {
|
||||
t.Fatalf("Expected %v, got %v", e, a)
|
||||
}
|
||||
for i := range list {
|
||||
if e, a := list[i].(*api.Pod).ID, pl.Items[i].ID; e != a {
|
||||
if e, a := list[i].(*api.Pod).Name, pl.Items[i].Name; e != a {
|
||||
t.Fatalf("Expected %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
|
||||
func TestSetList(t *testing.T) {
|
||||
pl := &api.PodList{}
|
||||
list := []runtime.Object{
|
||||
&api.Pod{TypeMeta: api.TypeMeta{ID: "1"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{ID: "2"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{ID: "3"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
}
|
||||
err := runtime.SetList(pl, list)
|
||||
if err != nil {
|
||||
@@ -63,7 +63,7 @@ func TestSetList(t *testing.T) {
|
||||
t.Fatalf("Expected %v, got %v", e, a)
|
||||
}
|
||||
for i := range list {
|
||||
if e, a := list[i].(*api.Pod).ID, pl.Items[i].ID; e != a {
|
||||
if e, a := list[i].(*api.Pod).Name, pl.Items[i].Name; e != a {
|
||||
t.Fatalf("Expected %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
@@ -195,7 +195,7 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
|
||||
// Returns an error if this isn't the case.
|
||||
func newGenericTypeMeta(v reflect.Value) (genericTypeMeta, error) {
|
||||
g := genericTypeMeta{}
|
||||
if err := fieldPtr(v, "ID", &g.id); err != nil {
|
||||
if err := fieldPtr(v, "Name", &g.id); err != nil {
|
||||
return g, err
|
||||
}
|
||||
if err := fieldPtr(v, "APIVersion", &g.apiVersion); err != nil {
|
||||
|
@@ -26,14 +26,14 @@ import (
|
||||
func TestGenericTypeMeta(t *testing.T) {
|
||||
type TypeMeta struct {
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
ID string `json:"id,omitempty" yaml:"id,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
||||
}
|
||||
j := TypeMeta{
|
||||
ID: "foo",
|
||||
Name: "foo",
|
||||
APIVersion: "a",
|
||||
Kind: "b",
|
||||
ResourceVersion: "1",
|
||||
@@ -68,7 +68,7 @@ func TestGenericTypeMeta(t *testing.T) {
|
||||
jbi.SetSelfLink("google.com")
|
||||
|
||||
// Prove that jbi changes the original object.
|
||||
if e, a := "bar", j.ID; e != a {
|
||||
if e, a := "bar", j.Name; e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
if e, a := "c", j.APIVersion; e != a {
|
||||
|
@@ -36,7 +36,7 @@ import (
|
||||
//
|
||||
type TypeMeta struct {
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
ID string `json:"id,omitempty" yaml:"id,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
|
Reference in New Issue
Block a user