Get the terminated pod by name

This commit is contained in:
feihujiang 2015-09-06 19:39:58 +08:00
parent bb3e20e361
commit 008a26f690

View File

@ -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
}
}