mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
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.
This commit is contained in:
parent
903cdff633
commit
25e0a8f56c
@ -239,10 +239,10 @@ func AddHandlers(h printers.PrintHandler) {
|
|||||||
{Name: "Last Seen", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["lastTimestamp"]},
|
{Name: "Last Seen", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["lastTimestamp"]},
|
||||||
{Name: "Type", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["type"]},
|
{Name: "Type", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["type"]},
|
||||||
{Name: "Reason", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["reason"]},
|
{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: "Source", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["source"]},
|
||||||
{Name: "Message", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["message"]},
|
{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: "First Seen", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["firstTimestamp"]},
|
||||||
{Name: "Count", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["count"]},
|
{Name: "Count", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["count"]},
|
||||||
{Name: "Name", Type: "string", Priority: 1, Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
{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)
|
firstTimestamp = translateTimestampSince(obj.FirstTimestamp)
|
||||||
lastTimestamp = translateTimestampSince(obj.LastTimestamp)
|
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 {
|
if options.Wide {
|
||||||
row.Cells = append(row.Cells,
|
row.Cells = append(row.Cells,
|
||||||
lastTimestamp,
|
lastTimestamp,
|
||||||
obj.Type,
|
obj.Type,
|
||||||
obj.Reason,
|
obj.Reason,
|
||||||
obj.InvolvedObject.Kind,
|
target,
|
||||||
|
obj.InvolvedObject.FieldPath,
|
||||||
formatEventSource(obj.Source),
|
formatEventSource(obj.Source),
|
||||||
strings.TrimSpace(obj.Message),
|
strings.TrimSpace(obj.Message),
|
||||||
obj.InvolvedObject.FieldPath,
|
|
||||||
firstTimestamp,
|
firstTimestamp,
|
||||||
int64(obj.Count),
|
int64(obj.Count),
|
||||||
obj.Name,
|
obj.Name,
|
||||||
@ -1403,7 +1409,7 @@ func printEvent(obj *api.Event, options printers.PrintOptions) ([]metav1beta1.Ta
|
|||||||
lastTimestamp,
|
lastTimestamp,
|
||||||
obj.Type,
|
obj.Type,
|
||||||
obj.Reason,
|
obj.Reason,
|
||||||
obj.InvolvedObject.Kind,
|
target,
|
||||||
strings.TrimSpace(obj.Message),
|
strings.TrimSpace(obj.Message),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user