Remove runtime.Typer, reduce to ObjectKinds(1) (3)

Remove the unnecessary variants, which avoids allocations in several
core paths.
This commit is contained in:
Clayton Coleman
2016-05-21 00:15:31 -04:00
parent a24936355e
commit c6961d6fd6
38 changed files with 159 additions and 210 deletions

View File

@@ -41,7 +41,7 @@ func (d *testDecodable) GroupVersionKind() unversioned.GroupVersionKind {
func TestDecode(t *testing.T) {
testCases := []struct {
creater runtime.ObjectCreater
typer runtime.Typer
typer runtime.ObjectTyper
yaml bool
pretty bool
@@ -260,6 +260,13 @@ type mockTyper struct {
err error
}
func (t *mockTyper) ObjectKind(obj runtime.Object) (*unversioned.GroupVersionKind, bool, error) {
return t.gvk, false, t.err
func (t *mockTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersionKind, bool, error) {
if t.gvk == nil {
return nil, false, t.err
}
return []unversioned.GroupVersionKind{*t.gvk}, false, t.err
}
func (t *mockTyper) Recognizes(_ unversioned.GroupVersionKind) bool {
return false
}