mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Issue #13501 - create a formatEventSource func and use it.
This commit is contained in:
parent
8f99b74466
commit
42eb8ff0e7
@ -2235,7 +2235,7 @@ func DescribeEvents(el *api.EventList, w *PrefixWriter) {
|
||||
translateTimestamp(e.FirstTimestamp),
|
||||
translateTimestamp(e.LastTimestamp),
|
||||
e.Count,
|
||||
e.Source,
|
||||
formatEventSource(e.Source),
|
||||
e.InvolvedObject.FieldPath,
|
||||
e.Type,
|
||||
e.Reason,
|
||||
|
@ -1728,7 +1728,7 @@ func printEvent(event *api.Event, w io.Writer, options PrintOptions) error {
|
||||
event.InvolvedObject.FieldPath,
|
||||
event.Type,
|
||||
event.Reason,
|
||||
event.Source,
|
||||
formatEventSource(event.Source),
|
||||
event.Message,
|
||||
); err != nil {
|
||||
return err
|
||||
@ -2727,3 +2727,12 @@ func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
func (p *JSONPathPrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// formatEventSource formats EventSource as a comma separated string excluding Host when empty
|
||||
func formatEventSource(es api.EventSource) string {
|
||||
EventSourceString := []string{es.Component}
|
||||
if len(es.Host) > 0 {
|
||||
EventSourceString = append(EventSourceString, es.Host)
|
||||
}
|
||||
return strings.Join(EventSourceString, ", ")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user