From 008a26f6901af7f9c9614c0b50b944e80747b9a0 Mon Sep 17 00:00:00 2001 From: feihujiang Date: Sun, 6 Sep 2015 19:39:58 +0800 Subject: [PATCH] Get the terminated pod by name --- pkg/kubectl/resource_printer.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index fc9ea6b58dd..5105c75c9ed 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -504,6 +504,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 @@ -513,7 +517,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 != "" { @@ -573,7 +577,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 } }