mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Get the terminated pod by name
This commit is contained in:
parent
bb3e20e361
commit
008a26f690
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user