From ceac670eae22ad773056370c15637d3b0becf6b0 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 26 Feb 2015 16:32:14 -0800 Subject: [PATCH] Add a human readable created since column to kubectl. --- pkg/kubectl/resource_printer.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index b92f93783c4..ee2a385acd2 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -33,6 +33,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" + "github.com/docker/docker/pkg/units" "github.com/ghodss/yaml" "github.com/golang/glog" ) @@ -217,7 +218,7 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value) return nil } -var podColumns = []string{"POD", "IP", "CONTAINER(S)", "IMAGE(S)", "HOST", "LABELS", "STATUS"} +var podColumns = []string{"POD", "IP", "CONTAINER(S)", "IMAGE(S)", "HOST", "LABELS", "STATUS", "CREATED"} var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE(S)", "SELECTOR", "REPLICAS"} var serviceColumns = []string{"NAME", "LABELS", "SELECTOR", "IP", "PORT"} var endpointColumns = []string{"NAME", "ENDPOINTS"} @@ -296,20 +297,21 @@ func printPod(pod *api.Pod, w io.Writer) error { if len(containers) > 0 { firstContainer, containers = containers[0], containers[1:] } - _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", pod.Name, pod.Status.PodIP, firstContainer.Name, firstContainer.Image, podHostString(pod.Status.Host, pod.Status.HostIP), formatLabels(pod.Labels), - pod.Status.Phase) + pod.Status.Phase, + units.HumanDuration(time.Now().Sub(pod.CreationTimestamp.Time))) if err != nil { return err } // Lay out all the other containers on separate lines. for _, container := range containers { - _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "", "", container.Name, container.Image, "", "", "") + _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "", "", container.Name, container.Image, "", "", "", "") if err != nil { return err }