func ReportIfNotPresent(recorder *EventReporter, instance runtime.Object,
	eventType, eventReason, msg string) {
	nameSpacedName, err := getNameSpacedName(instance)
	if err != nil {
		return
	}
	eventKey := getEventKey(eventType, eventReason, msg)
	if recorder.lastReportedEvent[nameSpacedName] != eventKey ||
		recorder.lastReportedEventTime[nameSpacedName].Add(time.Second*LastEventValidDuration).Before(time.Now()) {
		recorder.lastReportedEvent[nameSpacedName] = eventKey
		recorder.lastReportedEventTime[nameSpacedName] = time.Now()
		recorder.recorder.Event(instance, eventType, eventReason, msg)
	}
}
ReportIfNotPresent will report event if lastReportedEvent is not the same in last 10 minutes
TODO: The duration 10 minutes can be changed to some other value if necessary
package util
import (
	"fmt"
	"time"
	"k8s.io/apimachinery/pkg/api/meta"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/client-go/tools/record"
)
const (
	LastEventValidDuration = 10
)
const (
	EventReasonValidationFailed = "FailedValidation"
	EventReasonPVCListFailed = "PVCListFailed"
	EventReasonVRCreateFailed = "VRCreateFailed"
	EventReasonVRUpdateFailed = "VRUpdateFailed"
	EventReasonProtectPVCFailed = "ProtectPVCFailed"
	EventReasonPVUploadFailed = "PVUploadFailed"
	EventReasonPrimarySuccess = "PrimaryVRGProcessSuccess"
	EventReasonSecondarySuccess = "SecondaryVRGProcessSuccess"
	EventReasonDeleteSuccess = "VRGDeleteSuccess"
	EventReasonDeploying = "DRPCDeploying"
	EventReasonDeployFail = "DRPCDeployFailed"
	EventReasonDeploySuccess = "DRPCDeploySuccess"
	EventReasonFailingOver = "DRPCFailingOver"
	EventReasonFailoverSuccess = "DRPCFailoverSuccess"
	EventReasonRelocating = "DRPCRelocating"
	EventReasonRelocationSuccess = "DRPCRelocationSuccess"
	EventReasonSwitchFailed = "DRPCClusterSwitchFailed"
)
type EventReporter struct {
	recorder record.EventRecorder
	lastReportedEvent map[string]string
	lastReportedEventTime map[string]time.Time
}
func NewEventReporter(recorder record.EventRecorder) *EventReporter {
	return &EventReporter{
		recorder:              recorder,
		lastReportedEvent:     make(map[string]string),
		lastReportedEventTime: make(map[string]time.Time),
	}
}