func NewDeleted(obj *unstructured.Unstructured) *Event {
	return &Event{
		Type: TypeDeleted,
		Obj:  obj,
	}
}
NewDeleted creates deleted event
package event
import (
	"github.com/spongeprojects/kubebigbrother/pkg/helpers/style"
	"github.com/spongeprojects/kubebigbrother/pkg/models"
	"github.com/spongeprojects/kubebigbrother/pkg/utils"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime/schema"
)
type Type string
const (
	TypeAdded   = "ADDED"    
	TypeDeleted = "DELETED"  
	TypeUpdated = "UPDATED"  
)
type Event struct {
	Type Type `json:"type"`
	Obj *unstructured.Unstructured `json:"obj"`
	OldObj *unstructured.Unstructured `json:"oldObj,omitempty"`
	gvkNameCache string
}
func (e *Event) GroupVersionKindName() string {
	if e.gvkNameCache == "" {
		e.gvkNameCache = utils.GroupVersionKindName(e.Obj)
	}
	return e.gvkNameCache
}
func (e *Event) NamespaceKey() string {
	return utils.NamespaceKey(e.Obj)
}
func (e *Event) Color() string {
	switch e.Type {
	case TypeAdded:
		return style.Success
	case TypeDeleted:
		return style.Warning
	default:
		return style.Info
	}
}
func (e *Event) ToModel(
	informerName string, gvr schema.GroupVersionResource) *models.Event {
	model := &models.Event{
		InformerName: informerName,
		EventType:    string(e.Type),
		Namespace:    e.Obj.GetNamespace(),
		Name:         e.Obj.GetName(),
	}
	model.Group = gvr.Group
	model.Version = gvr.Version
	model.Resource = gvr.Resource
	gvk := e.Obj.GroupVersionKind()
	model.Kind = gvk.Kind
	objJSON, _ := e.Obj.MarshalJSON()
	model.Obj = objJSON
	if e.OldObj != nil {
		oldObjJSON, _ := e.OldObj.MarshalJSON()
		model.OldObj = oldObjJSON
	}
	return model
}
func NewAdded(obj *unstructured.Unstructured) *Event {
	return &Event{
		Type: TypeAdded,
		Obj:  obj,
	}
}