package notifications import ( "encoding/json" "fmt" "github.com/google/uuid" ) const ( IMAGE_TYPE = "image" STACK_TYPE = "list" ) type ImageNotification struct { Type string ImageID uuid.UUID ImageName string Status string } type StackNotification struct { Type string StackID uuid.UUID Name string Status string } type Notification struct { image *ImageNotification stack *StackNotification } func GetImageNotification(image ImageNotification) Notification { return Notification{ image: &image, } } func GetStackNotification(list StackNotification) Notification { return Notification{ stack: &list, } } func (n Notification) MarshalJSON() ([]byte, error) { if n.image != nil { return json.Marshal(n.image) } if n.stack != nil { return json.Marshal(n.stack) } return nil, fmt.Errorf("no image or list present") } func (n *Notification) UnmarshalJSON(data []byte) error { return fmt.Errorf("unimplemented") }