Add AGE column
This commit is contained in:
@@ -4,10 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/util/duration"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/cli-runtime/pkg/printers"
|
"k8s.io/cli-runtime/pkg/printers"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
@@ -75,6 +77,7 @@ func print(pods []corev1.Pod) error {
|
|||||||
{Name: "Name"},
|
{Name: "Name"},
|
||||||
{Name: "Ready"},
|
{Name: "Ready"},
|
||||||
{Name: "Status"},
|
{Name: "Status"},
|
||||||
|
{Name: "Age"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
@@ -84,6 +87,7 @@ func print(pods []corev1.Pod) error {
|
|||||||
pod.Name,
|
pod.Name,
|
||||||
containerStatuses(pod),
|
containerStatuses(pod),
|
||||||
pod.Status.Phase,
|
pod.Status.Phase,
|
||||||
|
duration.HumanDuration(time.Since(pod.CreationTimestamp.Time)),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user