Skip to content

Commit 0d5291c

Browse files
committedNov 9, 2017
UPSTREAM: <drop>: get.go doesn't handle metav1.Status returned by rest.client (drop in 1.9)
1 parent 140fa32 commit 0d5291c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎pkg/kubectl/cmd/get.go

+13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import (
2626

2727
kapierrors "k8s.io/apimachinery/pkg/api/errors"
2828
"k8s.io/apimachinery/pkg/api/meta"
29+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2930
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31+
unstructuredconverter "k8s.io/apimachinery/pkg/conversion/unstructured"
3032
"k8s.io/apimachinery/pkg/runtime"
3133
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3234
"k8s.io/apimachinery/pkg/util/sets"
@@ -364,6 +366,17 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
364366
},
365367
}
366368
for _, info := range infos {
369+
// FIXME: This should be fixed in 1.9 and is needed to handle
370+
// oc get projectrequest -o yaml
371+
if _, ok := info.Object.(*metav1.Status); ok {
372+
obj, err := unstructuredconverter.NewConverter(false).ToUnstructured(info.Object)
373+
if err != nil {
374+
errs = append(errs, err)
375+
} else {
376+
list.Items = append(list.Items, unstructured.Unstructured{Object: obj})
377+
}
378+
continue
379+
}
367380
list.Items = append(list.Items, *info.Object.(*unstructured.Unstructured))
368381
}
369382
obj = list

0 commit comments

Comments
 (0)
Please sign in to comment.