resource_printer was not leveraging runtime interfaces

In general, everything in kubectl/* needs to be ignorant of api/* unless
it deals with a concrete type - this change forces resource_printer to
accept interface abstractions (that are already part of kubectl).
This commit is contained in:
Clayton Coleman
2015-12-21 00:34:11 -05:00
parent efe88e0818
commit fb4ea845f1
4 changed files with 57 additions and 67 deletions

View File

@@ -20,12 +20,13 @@ import (
"reflect"
"testing"
"k8s.io/kubernetes/pkg/api/latest"
api "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/runtime"
)
func encodeOrDie(obj runtime.Object) []byte {
data, err := api.Codec.Encode(obj)
data, err := runtime.Encode(latest.Codecs.LegacyCodec(api.SchemeGroupVersion), obj)
if err != nil {
panic(err.Error())
}
@@ -223,7 +224,7 @@ func TestSortingPrinter(t *testing.T) {
},
}
for _, test := range tests {
sort := &SortingPrinter{SortField: test.field}
sort := &SortingPrinter{SortField: test.field, Decoder: latest.Codecs.UniversalDecoder()}
if err := sort.sortObj(test.obj); err != nil {
t.Errorf("unexpected error: %v (%s)", err, test.name)
continue