Add TypeAccessor to api/meta for objects without Object/ListMeta
Adding objects that have TypeMeta (use runtime.Scheme) but do not expose ObjectMeta/ListMeta (because they are not Kube API objects) and wanted to get the simpler access path for in memory objects.
This commit is contained in:
@@ -79,6 +79,17 @@ func TestGenericTypeMeta(t *testing.T) {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
|
||||
typeAccessor, err := TypeAccessor(&j)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if e, a := "a", accessor.APIVersion(); e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
if e, a := "b", accessor.Kind(); e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
|
||||
accessor.SetNamespace("baz")
|
||||
accessor.SetName("bar")
|
||||
accessor.SetUID("other")
|
||||
@@ -109,6 +120,15 @@ func TestGenericTypeMeta(t *testing.T) {
|
||||
if e, a := "google.com", j.SelfLink; e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
|
||||
typeAccessor.SetAPIVersion("d")
|
||||
typeAccessor.SetKind("e")
|
||||
if e, a := "d", j.APIVersion; e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
if e, a := "e", j.Kind; e != a {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
type InternalTypeMeta struct {
|
||||
|
Reference in New Issue
Block a user