mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #13626 from feihujiang/getTerminatedPodByName
Auto commit by PR queue bot
This commit is contained in:
commit
b67aa39c73
@ -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 {
|
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
|
name := pod.Name
|
||||||
namespace := pod.Namespace
|
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)
|
reason := string(pod.Status.Phase)
|
||||||
// if not printing all pods, skip terminated pods (default)
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
if pod.Status.Reason != "" {
|
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 {
|
func printPodList(podList *api.PodList, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
|
||||||
for _, pod := range podList.Items {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user