Add "PrintErrorWithCauses" cmdutil helper

This patch adds a new helper function to cmd/util/helpers.go that
handles errors containing collections of causes and prints each cause in
a separate newline.
This commit is contained in:
juanvallejo
2016-09-19 11:51:47 -04:00
parent e6b5b076b8
commit 643649113f
2 changed files with 25 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/strategicpatch"
@@ -59,6 +60,10 @@ func handlePodUpdateError(out io.Writer, err error, resource string) {
if all && match {
return
}
} else {
if ok := kcmdutil.PrintErrorWithCauses(err, out); ok {
return
}
}
}