event

package
v0.0.0-...-1502a4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationEventKeyKind    = "kind"
	AnnotationEventKeyName    = "name"
	AnnotationEventKeyProject = "project" // This is the same as the annotation, but just "project"
	AnnotationEventKeyMessage = "message"
)

Variables

A list of all known event types

Functions

func NewFreightCommon

func NewFreightCommon(message,
	actor, stageName string, freight *kargoapi.Freight,
) (Common, Freight)

NewFreightCommon creates a new `Freight` and `Common` event from the given freight data. Since these fields are common to all events, this is exposed for convenience.

func NewPromotionCommon

func NewPromotionCommon(message,
	actor string, promotion *kargoapi.Promotion,
	freight *kargoapi.Freight,
) (Common, Promotion)

NewPromotionCommon creates a new `Promotion` and `Common` event from the given promotion and freight data. Since these fields are common to all events, this is exposed for convenience. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

Types

type AnnotationMarshaler

type AnnotationMarshaler interface {
	MarshalAnnotations() map[string]string
}

AnnotationMarshaler is an interface for any type that can marshal out to our custom annotation types

type Common

type Common struct {
	Project string  `json:"project"`
	Actor   *string `json:"actor,omitempty"`
	Message string  `json:"message"`
	ID      string  `json:"id"`
}

Common is a struct that contains fields common to all events.

func UnmarshalCommonAnnotations

func UnmarshalCommonAnnotations(eventID string, annotations map[string]string) (Common, error)

UnmarshalCommonAnnotations populates the Common fields from the given kubernetes annotations and event ID

func (Common) GetID

func (c Common) GetID() string

func (Common) GetMessage

func (c Common) GetMessage() string

func (Common) GetProject

func (c Common) GetProject() string

func (*Common) MarshalAnnotationsTo

func (c *Common) MarshalAnnotationsTo(annotations map[string]string)

func (*Common) SetMessage

func (c *Common) SetMessage(message string)

type Custom

type Custom struct {
	ObjectKind string             `json:"kind"`
	Name       string             `json:"name"`
	Project    string             `json:"project"`
	EventType  kargoapi.EventType `json:"type"`
	Message    string             `json:"message,omitempty"`
	Data       map[string]any     `json:"data"`
	ID         string             `json:"id,omitempty"`
}

Custom is a representation of an arbitrary custom event. It contains the raw data from the message, deserialized as `map[string]any` as well as additional data that can be pulled from well-known keys. It implements the `Meta` and `Message` interfaces so it can be used by any of the other methods in the package.

This type is only meant as a way to decode events. Sending custom events should be handled by defining your own structs

func (*Custom) GetID

func (c *Custom) GetID() string

func (*Custom) GetMessage

func (c *Custom) GetMessage() string

func (*Custom) GetName

func (c *Custom) GetName() string

func (*Custom) GetProject

func (c *Custom) GetProject() string

func (*Custom) Kind

func (c *Custom) Kind() string

func (*Custom) SetMessage

func (c *Custom) SetMessage(msg string)

func (*Custom) Type

func (c *Custom) Type() kargoapi.EventType

type Freight

type Freight struct {
	Name       string               `json:"name"`
	StageName  string               `json:"stageName"`
	CreateTime time.Time            `json:"createTime"`
	Alias      *string              `json:"alias,omitempty"`
	Commits    []kargoapi.GitCommit `json:"commits,omitempty"`
	Images     []kargoapi.Image     `json:"images,omitempty"`
	Charts     []kargoapi.Chart     `json:"charts,omitempty"`
}

Freight is a struct that contains common fields for freight-related events.

func UnmarshalFreightAnnotations

func UnmarshalFreightAnnotations(annotations map[string]string) (Freight, error)

UnmarshalFreightAnnotations populates the Freight fields from the given kubernetes annotations.

func (Freight) GetName

func (f Freight) GetName() string

func (Freight) Kind

func (f Freight) Kind() string

func (*Freight) MarshalAnnotationsTo

func (f *Freight) MarshalAnnotationsTo(annotations map[string]string)

type FreightApproved

type FreightApproved struct {
	Common
	Freight
}

func NewFreightApproved

func NewFreightApproved(message, actor, stageName string, freight *kargoapi.Freight,
) *FreightApproved

NewFreightApproved creates a new `FreightApproved` event.

func UnmarshalFreightApprovedAnnotations

func UnmarshalFreightApprovedAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightApproved, error)

UnmarshalFreightApprovedAnnotations converts the given annotations into a FreightApproved event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightApproved) MarshalAnnotations

func (f *FreightApproved) MarshalAnnotations() map[string]string

func (*FreightApproved) Type

type FreightVerification

type FreightVerification struct {
	StartTime       *time.Time `json:"verificationStartTime,omitempty"`
	FinishTime      *time.Time `json:"verificationFinishTime,omitempty"`
	AnalysisRunName *string    `json:"analysisRunName,omitempty"`
	// AnalysisTriggeredByPromotion is the name of the promotion that triggered the analysis run.
	AnalysisTriggeredByPromotion *string `json:"analysisTriggeredByPromotion,omitempty"`
}

FreightVerification is a struct that contains common fields for a verification event

func NewFreightVerification

func NewFreightVerification(vi *kargoapi.VerificationInfo) FreightVerification

NewFreightVerification creates a new `FreightVerification` struct from a `VerificationInfo`. This is mostly a convenience method if you're constructing an event yourself

func UnmarshalFreightVerificationAnnotations

func UnmarshalFreightVerificationAnnotations(annotations map[string]string) (FreightVerification, error)

func (*FreightVerification) GetTriggeredByPromotion

func (f *FreightVerification) GetTriggeredByPromotion() *string

func (*FreightVerification) MarshalAnnotationsTo

func (f *FreightVerification) MarshalAnnotationsTo(annotations map[string]string)

func (*FreightVerification) SetTriggeredByPromotion

func (f *FreightVerification) SetTriggeredByPromotion(promotionName *string)

type FreightVerificationAborted

type FreightVerificationAborted struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationAborted is an event fired when a freight verification is aborted.

func NewFreightVerificationAborted

func NewFreightVerificationAborted(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationAborted

NewFreightVerificationAborted creates a new `FreightVerificationAborted` event.

func UnmarshalFreightVerificationAbortedAnnotations

func UnmarshalFreightVerificationAbortedAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationAborted, error)

UnmarshalFreightVerificationAbortedAnnotations converts the given annotations into a FreightVerificationAborted event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationAborted) MarshalAnnotations

func (f *FreightVerificationAborted) MarshalAnnotations() map[string]string

func (*FreightVerificationAborted) Type

type FreightVerificationErrored

type FreightVerificationErrored struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationErrored is an event fired when a freight verification errors.

func NewFreightVerificationErrored

func NewFreightVerificationErrored(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationErrored

NewFreightVerificationErrored creates a new `FreightVerificationErrored` event.

func UnmarshalFreightVerificationErroredAnnotations

func UnmarshalFreightVerificationErroredAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationErrored, error)

UnmarshalFreightVerificationErroredAnnotations converts the given annotations into a FreightVerificationErrored event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationErrored) MarshalAnnotations

func (f *FreightVerificationErrored) MarshalAnnotations() map[string]string

func (*FreightVerificationErrored) Type

type FreightVerificationEventMeta

type FreightVerificationEventMeta interface {
	Meta
	GetTriggeredByPromotion() *string
	SetTriggeredByPromotion(promotionName *string)
}

FreightVerificationEventMeta is an interface for metadata associated with freight verification events. It is an extension of the Meta interface with a few verification-specific methods

type FreightVerificationFailed

type FreightVerificationFailed struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationFailed is an event fired when a freight verification fails.

func NewFreightVerificationFailed

func NewFreightVerificationFailed(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationFailed

NewFreightVerificationFailed creates a new `FreightVerificationFailed` event.

func UnmarshalFreightVerificationFailedAnnotations

func UnmarshalFreightVerificationFailedAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationFailed, error)

UnmarshalFreightVerificationFailedAnnotations converts the given annotations into a FreightVerificationFailed event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationFailed) MarshalAnnotations

func (f *FreightVerificationFailed) MarshalAnnotations() map[string]string

func (*FreightVerificationFailed) Type

type FreightVerificationInconclusive

type FreightVerificationInconclusive struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationInconclusive is an event fired when a freight verification is inconclusive.

func NewFreightVerificationInconclusive

func NewFreightVerificationInconclusive(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationInconclusive

NewFreightVerificationInconclusive creates a new `FreightVerificationInconclusive` event.

func UnmarshalFreightVerificationInconclusiveAnnotations

func UnmarshalFreightVerificationInconclusiveAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationInconclusive, error)

UnmarshalFreightVerificationInconclusiveAnnotations converts the given annotations into a FreightVerificationInconclusive event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationInconclusive) MarshalAnnotations

func (f *FreightVerificationInconclusive) MarshalAnnotations() map[string]string

func (*FreightVerificationInconclusive) Type

type FreightVerificationSucceeded

type FreightVerificationSucceeded struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationSucceeded is an event fired when a freight verification succeeds.

func NewFreightVerificationSucceeded

func NewFreightVerificationSucceeded(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationSucceeded

NewFreightVerificationSucceeded creates a new `FreightVerificationSucceeded` event.

func UnmarshalFreightVerificationSucceededAnnotations

func UnmarshalFreightVerificationSucceededAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationSucceeded, error)

UnmarshalFreightVerificationSucceededAnnotations converts the given annotations into a FreightVerificationSucceeded event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationSucceeded) MarshalAnnotations

func (f *FreightVerificationSucceeded) MarshalAnnotations() map[string]string

func (*FreightVerificationSucceeded) Type

type FreightVerificationUnknown

type FreightVerificationUnknown struct {
	Common
	Freight
	FreightVerification
}

FreightVerificationUnknown is an event fired when a freight verification is unknown.

func NewFreightVerificationUnknown

func NewFreightVerificationUnknown(actor, stageName string, freight *kargoapi.Freight,
	verification *kargoapi.VerificationInfo,
) *FreightVerificationUnknown

NewFreightVerificationUnknown creates a new `FreightVerificationUnknown` event.

func UnmarshalFreightVerificationUnknownAnnotations

func UnmarshalFreightVerificationUnknownAnnotations(
	eventID string,
	annotations map[string]string,
) (*FreightVerificationUnknown, error)

UnmarshalFreightVerificationUnknownAnnotations converts the given annotations into a FreightVerificationUnknown event. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*FreightVerificationUnknown) MarshalAnnotations

func (f *FreightVerificationUnknown) MarshalAnnotations() map[string]string

func (*FreightVerificationUnknown) Type

type Message

type Message interface {
	// GetMessage returns the message of the event
	GetMessage() string
	// SetMessage sets the message of the event
	SetMessage(string)
}

Message is an interface for setting and getting the message of any built in event

type Meta

type Meta interface {
	// Type returns the event type for the struct
	Type() kargoapi.EventType
	// Kind returns the object kind the event is related to (e.g. "Promotion", "Freight", etc.).
	// This is used for constructing a valid object reference for the event source
	Kind() string
	// GetProject returns the project associated with the event
	GetProject() string
	// GetName returns the name of the object associated with the event
	GetName() string
	// GetID returns a unique identifier for the event
	GetID() string
}

Meta is an interface for our built in event types that all of them implement

type Promotion

type Promotion struct {
	Freight      *Freight               `json:"freight,omitempty"`
	Name         string                 `json:"name"`
	StageName    string                 `json:"stageName"`
	CreateTime   time.Time              `json:"createTime"`
	Applications []types.NamespacedName `json:"applications,omitempty"`
}

Promotion is a struct that contains common fields for promotion-related events.

func UnmarshalPromotionAnnotations

func UnmarshalPromotionAnnotations(annotations map[string]string) (Promotion, error)

UnmarshalPromotionAnnotations populates the Promotion fields from the given kubernetes annotations.

func (Promotion) GetName

func (p Promotion) GetName() string

func (Promotion) Kind

func (p Promotion) Kind() string

func (*Promotion) MarshalAnnotationsTo

func (p *Promotion) MarshalAnnotationsTo(annotations map[string]string)

type PromotionAborted

type PromotionAborted struct {
	Common
	Promotion
}

PromotionAborted is event data related to an aborted promotion.

func NewPromotionAborted

func NewPromotionAborted(
	message, actor string, promotion *kargoapi.Promotion, freight *kargoapi.Freight,
) *PromotionAborted

NewPromotionAborted creates a new PromotionAborted event from the given promotion and freight data. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

func UnmarshalPromotionAbortedAnnotations

func UnmarshalPromotionAbortedAnnotations(
	eventID string, annotations map[string]string,
) (*PromotionAborted, error)

UnmarshalPromotionAbortedAnnotations converts the given annotations into a PromotionAborted. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*PromotionAborted) MarshalAnnotations

func (p *PromotionAborted) MarshalAnnotations() map[string]string

func (*PromotionAborted) Type

type PromotionCreated

type PromotionCreated struct {
	Common
	Promotion
}

PromotionCreated is event data related to a created promotion.

func NewPromotionCreated

func NewPromotionCreated(
	message, actor string, promotion *kargoapi.Promotion, freight *kargoapi.Freight,
) *PromotionCreated

NewPromotionCreated creates a new PromotionCreated event from the given promotion and freight data. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

func UnmarshalPromotionCreatedAnnotations

func UnmarshalPromotionCreatedAnnotations(
	eventID string, annotations map[string]string,
) (*PromotionCreated, error)

UnmarshalPromotionCreatedAnnotations converts the given annotations into a PromotionCreated. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*PromotionCreated) MarshalAnnotations

func (p *PromotionCreated) MarshalAnnotations() map[string]string

func (*PromotionCreated) Type

type PromotionErrored

type PromotionErrored struct {
	Common
	Promotion
}

PromotionErrored is event data related to an errored promotion.

func NewPromotionErrored

func NewPromotionErrored(
	message, actor string, promotion *kargoapi.Promotion, freight *kargoapi.Freight,
) *PromotionErrored

NewPromotionErrored creates a new PromotionErrored event from the given promotion and freight data. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

func UnmarshalPromotionErroredAnnotations

func UnmarshalPromotionErroredAnnotations(
	eventID string, annotations map[string]string,
) (*PromotionErrored, error)

UnmarshalPromotionErroredAnnotations converts the given annotations into a PromotionErrored. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*PromotionErrored) MarshalAnnotations

func (p *PromotionErrored) MarshalAnnotations() map[string]string

func (*PromotionErrored) Type

type PromotionFailed

type PromotionFailed struct {
	Common
	Promotion
}

PromotionFailed is event data related to a failed promotion.

func NewPromotionFailed

func NewPromotionFailed(
	message, actor string, promotion *kargoapi.Promotion, freight *kargoapi.Freight,
) *PromotionFailed

NewPromotionFailed creates a new PromotionFailed event from the given promotion and freight data. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

func UnmarshalPromotionFailedAnnotations

func UnmarshalPromotionFailedAnnotations(
	eventID string, annotations map[string]string,
) (*PromotionFailed, error)

UnmarshalPromotionFailedAnnotations converts the given annotations into a PromotionFailed. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*PromotionFailed) MarshalAnnotations

func (p *PromotionFailed) MarshalAnnotations() map[string]string

func (*PromotionFailed) Type

type PromotionSucceeded

type PromotionSucceeded struct {
	Common
	Promotion
	VerificationPending *bool `json:"verificationPending,omitempty"`
}

PromotionSucceeded is event data related to a successful promotion.

func NewPromotionSucceeded

func NewPromotionSucceeded(
	message, actor string, promotion *kargoapi.Promotion, freight *kargoapi.Freight,
) *PromotionSucceeded

NewPromotionSucceeded creates a new PromotionSucceeded event from the given promotion and freight data. The given actor will be used if it is not empty, but it will be overridden if the promotion has an actor annotation.

func UnmarshalPromotionSucceededAnnotations

func UnmarshalPromotionSucceededAnnotations(
	eventID string, annotations map[string]string,
) (*PromotionSucceeded, error)

UnmarshalPromotionSucceededAnnotations converts the given annotations into a PromotionSucceeded. This is used by the main event handler to convert the data into a normal structured event, but is exposed for convenience.

func (*PromotionSucceeded) MarshalAnnotations

func (p *PromotionSucceeded) MarshalAnnotations() map[string]string

func (*PromotionSucceeded) Type

type Sender

type Sender interface {
	// Send sends the event to the configured destination, returning an error if the send fails.
	Send(ctx context.Context, evt Meta) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL