Refactor unstructured converter

This commit is contained in:
Mikhail Mazurskiy
2017-06-27 12:58:35 +10:00
parent 956acc2bd8
commit dc1ee493a2
6 changed files with 20 additions and 19 deletions

View File

@@ -97,8 +97,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
return
}
newUnstr := make(map[string]interface{})
err = unstructured.DefaultConverter.ToUnstructured(item, &newUnstr)
newUnstr, err := unstructured.DefaultConverter.ToUnstructured(item)
if err != nil {
t.Errorf("ToUnstructured failed: %v", err)
return
@@ -138,8 +137,8 @@ func BenchmarkToFromUnstructured(b *testing.B) {
size := len(items)
b.ResetTimer()
for i := 0; i < b.N; i++ {
unstr := map[string]interface{}{}
if err := unstructured.DefaultConverter.ToUnstructured(&items[i%size], &unstr); err != nil {
unstr, err := unstructured.DefaultConverter.ToUnstructured(&items[i%size])
if err != nil {
b.Fatalf("unexpected error: %v", err)
}
obj := v1.Pod{}