func formatEventSource(es corev1.EventSource) string {
	EventSourceString := []string{es.Component}
	if len(es.Host) > 0 {
		EventSourceString = append(EventSourceString, es.Host)
	}
	return strings.Join(EventSourceString, ", ")
}
formatEventSource formats EventSource as a comma separated string excluding Host when empty
package util
import (
	"fmt"
	"io"
	"sort"
	"strings"
	"text/tabwriter"
	"time"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/duration"
	"k8s.io/kubectl/pkg/describe"
	"k8s.io/kubectl/pkg/util/event"
)
func DescribeEvents(el *corev1.EventList, w describe.PrefixWriter, baseLevel int) {
	if el == nil || len(el.Items) == 0 {
		w.Write(baseLevel, "Events:\t<none>\n")
		w.Flush()
		return
	}
	w.Flush()
	sort.Sort(event.SortableEvents(el.Items))
	w.Write(baseLevel, "Events:\n")
	w.Write(baseLevel+1, "Type\tReason\tAge\tFrom\tMessage\n")
	w.Write(baseLevel+1, "----\t------\t----\t----\t-------\n")
	for _, e := range el.Items {
		var interval string
		if e.Count > 1 {
			interval = fmt.Sprintf("%s (x%d over %s)", translateTimestampSince(e.LastTimestamp), e.Count, translateTimestampSince(e.FirstTimestamp))
		} else {
			interval = translateTimestampSince(e.FirstTimestamp)
		}
		w.Write(baseLevel+1, "%v\t%v\t%s\t%v\t%v\n",
			e.Type,
			e.Reason,
			interval,
			formatEventSource(e.Source),
			strings.TrimSpace(e.Message),
		)
	}
	w.Flush()
}
func NewTabWriter(writer io.Writer) *tabwriter.Writer {
	return tabwriter.NewWriter(writer, 0, 8, 2, ' ', 0)
}