// UpdateEventForCluster records an event on MySQL cluster resource
UpdateEventForCluster records an event on MySQL cluster resource
// UpdateEventForCluster records an event on MySQL cluster resource
func UpdateEventForCluster(c client.Client, s *runtime.Scheme, clusterName, evReason, evMsg string, warning bool) error {
	key, err := orcNameToKey(clusterName)
	if err != nil {
		return err
	}
	cluster := mysqlcluster.New(&api.MysqlCluster{})
	if err = c.Get(context.TODO(), key, cluster.Unwrap()); err != nil {
		return err
	}
	evType := corev1.EventTypeNormal
	if warning {
		evType = corev1.EventTypeWarning
	}
	ref, err := reference.GetReference(s, cluster.Unwrap())
	if err != nil {
		return err
	}
	randStr, err := rand.AlphaNumericString(5)
	if err != nil {
		return err
	}
	event := &corev1.Event{
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s-%s.%d", cluster.Name, randStr, time.Now().Unix()),
			Namespace: cluster.Namespace,
		},
		FirstTimestamp: metav1.Now(),
		Type:           evType,
		Reason:         evReason,
		Message:        evMsg,
		Source:         corev1.EventSource{Component: "orchestrator"},
		InvolvedObject: *ref,
	}
	if err := c.Create(context.TODO(), event); err != nil {
		return err
	}
	return nil
}
func UpdateEventForCluster ( c client . Client , s * runtime . Scheme , clusterName , evReason , evMsg string , warning bool ) error { key , err := orcNameToKey ( clusterName ) if err != nil { return err } cluster := mysqlcluster . New ( & api . MysqlCluster { } ) if err = c . Get ( context . TODO ( ) , key , cluster . Unwrap ( ) ) ; err != nil { return err } evType := corev1 . EventTypeNormal if warning { evType = corev1 . EventTypeWarning } ref , err := reference . GetReference ( s , cluster . Unwrap ( ) ) if err != nil { return err } randStr , err := rand . AlphaNumericString ( 5 ) if err != nil { return err } event := & corev1 . Event { ObjectMeta : metav1 . ObjectMeta { Name : fmt . Sprintf ( " " , cluster . Name , randStr , time . Now ( ) . Unix ( ) ) , Namespace : cluster . Namespace , } , FirstTimestamp : metav1 . Now ( ) , Type : evType , Reason : evReason , Message : evMsg , Source : corev1 . EventSource { Component : " " } , InvolvedObject : * ref , } if err := c . Create ( context . TODO ( ) , event ) ; err != nil { return err } return nil }
UpdateEventForCluster records an event on MySQL cluster resource
UpdateEventForCluster records an event on MySQL cluster resource
// get cluster from k8s