Merge pull request #73894 from smarterclayton/event_involved

Print the involved object in the event table as resource/name
pull/564/head
Kubernetes Prow Robot 2019-02-13 14:31:50 -08:00 committed by GitHub
commit 400502577c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -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),
)
}