Issue #13501 - create a formatEventSource func and use it.

This commit is contained in:
Matthias Bertschy 2017-01-18 11:28:25 +01:00
parent 8f99b74466
commit 42eb8ff0e7
2 changed files with 11 additions and 2 deletions

View File

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

View File

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