Merge pull request #13626 from feihujiang/getTerminatedPodByName

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2015-09-11 12:57:03 -07:00
commit b67aa39c73

View File

@ -519,6 +519,10 @@ func translateTimestamp(timestamp util.Time) string {
}
func printPod(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
return printPodBase(pod, w, withNamespace, wide, showAll, true, columnLabels)
}
func printPodBase(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll bool, showIfTerminating bool, columnLabels []string) error {
name := pod.Name
namespace := pod.Namespace
@ -528,7 +532,7 @@ func printPod(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll
reason := string(pod.Status.Phase)
// if not printing all pods, skip terminated pods (default)
if !showAll && (reason == string(api.PodSucceeded) || reason == string(api.PodFailed)) {
if !showIfTerminating && !showAll && (reason == string(api.PodSucceeded) || reason == string(api.PodFailed)) {
return nil
}
if pod.Status.Reason != "" {
@ -588,7 +592,7 @@ func printPod(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll
func printPodList(podList *api.PodList, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
for _, pod := range podList.Items {
if err := printPod(&pod, w, withNamespace, wide, showAll, columnLabels); err != nil {
if err := printPodBase(&pod, w, withNamespace, wide, showAll, false, columnLabels); err != nil {
return err
}
}