From 25e0a8f56c361dab99e760952cf132dd7f1f7b4a Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sun, 10 Feb 2019 20:16:07 -0500 Subject: [PATCH] Print the involved object in the event table as resource/name The involved object is important and only some events include its name in the message. Change the `Kind` column to `Object` and print the object in `resource/name` form to allow copy and paste to `kubectl get`. Also move the source field column to the right of involved object since it is related. --- pkg/printers/internalversion/printers.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index a38fba9592..ada804f7e3 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -239,10 +239,10 @@ func AddHandlers(h printers.PrintHandler) { {Name: "Last Seen", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["lastTimestamp"]}, {Name: "Type", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["type"]}, {Name: "Reason", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["reason"]}, - {Name: "Kind", Type: "string", Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["kind"]}, + {Name: "Object", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["involvedObject"]}, + {Name: "Subobject", Type: "string", Priority: 1, Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["fieldPath"]}, {Name: "Source", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["source"]}, {Name: "Message", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["message"]}, - {Name: "Subobject", Type: "string", Priority: 1, Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["fieldPath"]}, {Name: "First Seen", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["firstTimestamp"]}, {Name: "Count", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["count"]}, {Name: "Name", Type: "string", Priority: 1, Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, @@ -1385,15 +1385,21 @@ func printEvent(obj *api.Event, options printers.PrintOptions) ([]metav1beta1.Ta firstTimestamp = translateTimestampSince(obj.FirstTimestamp) lastTimestamp = translateTimestampSince(obj.LastTimestamp) } + var target string + if len(obj.InvolvedObject.Name) > 0 { + target = fmt.Sprintf("%s/%s", strings.ToLower(obj.InvolvedObject.Kind), obj.InvolvedObject.Name) + } else { + target = strings.ToLower(obj.InvolvedObject.Kind) + } if options.Wide { row.Cells = append(row.Cells, lastTimestamp, obj.Type, obj.Reason, - obj.InvolvedObject.Kind, + target, + obj.InvolvedObject.FieldPath, formatEventSource(obj.Source), strings.TrimSpace(obj.Message), - obj.InvolvedObject.FieldPath, firstTimestamp, int64(obj.Count), obj.Name, @@ -1403,7 +1409,7 @@ func printEvent(obj *api.Event, options printers.PrintOptions) ([]metav1beta1.Ta lastTimestamp, obj.Type, obj.Reason, - obj.InvolvedObject.Kind, + target, strings.TrimSpace(obj.Message), ) }