@@ -2,11 +2,14 @@ package main
22
33import (
44 "fmt"
5+ "io"
6+ "strings"
7+ "time"
8+
59 "github.com/fatih/color"
610 "github.com/gosuri/uitable"
7- "io"
811 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
9- "strings "
12+ "k8s.io/apimachinery/pkg/util/duration "
1013)
1114
1215const (
2629func treeView (out io.Writer , objs objectDirectory , obj unstructured.Unstructured ) {
2730 tbl := uitable .New ()
2831 tbl .Separator = " "
29- tbl .AddRow ("NAMESPACE" , "NAME" , "READY" , "REASON" )
32+ tbl .AddRow ("NAMESPACE" , "NAME" , "READY" , "REASON" , "AGE" )
3033 treeViewInner ("" , tbl , objs , obj )
3134 fmt .Fprintln (out , tbl )
3235}
@@ -47,12 +50,19 @@ func treeViewInner(prefix string, tbl *uitable.Table, objs objectDirectory, obj
4750 ready = "-"
4851 }
4952
53+ c := obj .GetCreationTimestamp ()
54+ age := duration .HumanDuration (time .Since (c .Time ))
55+ if c .IsZero () {
56+ age = "<unknown>"
57+ }
58+
5059 tbl .AddRow (obj .GetNamespace (), fmt .Sprintf ("%s%s/%s" ,
5160 gray .Sprint (printPrefix (prefix )),
5261 obj .GetKind (),
5362 color .New (color .Bold ).Sprint (obj .GetName ())),
5463 readyColor .Sprint (ready ),
55- readyColor .Sprint (reason ))
64+ readyColor .Sprint (reason ),
65+ age )
5666 chs := objs .ownedBy (obj .GetUID ())
5767 for i , child := range chs {
5868 var p string
0 commit comments