event

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	EventCommit       = "commit"
	EventSync         = "sync"
	EventRelease      = "release"
	EventAutoRelease  = "autorelease"
	EventAutomate     = "automate"
	EventDeautomate   = "deautomate"
	EventLock         = "lock"
	EventUnlock       = "unlock"
	EventUpdatePolicy = "update_policy"

	// This is used to label e.g., commits that we _don't_ consider an event in themselves.
	NoneOfTheAbove = "other"

	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
)

These are all the types of events.

View Source
const (
	// ReleaseImageSpecType is a type of release spec when there are update.Images
	ReleaseImageSpecType = "releaseImageSpecType"
	// ReleaseContainersSpecType is a type of release spec when there are update.Containers
	ReleaseContainersSpecType = "releaseContainersSpecType"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoReleaseEventMetadata

type AutoReleaseEventMetadata struct {
	ReleaseEventCommon
	Spec update.Automated `json:"spec"`
}

AutoReleaseEventMetadata is for when workloads(s) are released automatically because there's a new image or images

func (*AutoReleaseEventMetadata) Type

func (rem *AutoReleaseEventMetadata) Type() string

type Commit

type Commit struct {
	Revision string `json:"revision"`
	Message  string `json:"message"`
}

Commit represents the commit information in a sync event. We could use git.Commit, but that would lead to an import cycle, and may anyway represent coupling (of an internal API to serialised data) that we don't want.

type CommitEventMetadata

type CommitEventMetadata struct {
	Revision string        `json:"revision,omitempty"`
	Spec     *update.Spec  `json:"spec"`
	Result   update.Result `json:"result,omitempty"`
}

CommitEventMetadata is the metadata for when new git commits are created

func (CommitEventMetadata) ShortRevision

func (c CommitEventMetadata) ShortRevision() string

func (*CommitEventMetadata) Type

func (cem *CommitEventMetadata) Type() string

type Event

type Event struct {
	// ID is a UUID for this event. Will be auto-set when saving if blank.
	ID EventID `json:"id"`

	// Identifiers of workloads affected by this event.
	// TODO: rename to WorkloadIDs after adding versioning.
	ServiceIDs []resource.ID `json:"serviceIDs"`

	// Type is the type of event, usually "release" for now, but could be other
	// things later
	Type string `json:"type"`

	// StartedAt is the time the event began.
	StartedAt time.Time `json:"startedAt"`

	// EndedAt is the time the event ended. For instantaneous events, this will
	// be the same as StartedAt.
	EndedAt time.Time `json:"endedAt"`

	// LogLevel for this event. Used to indicate how important it is.
	// `debug|info|warn|error`
	LogLevel string `json:"logLevel"`

	// Message is a pre-formatted string for errors and other stuff. Included for
	// backwards-compatibility, and is now somewhat unnecessary. Should only be
	// used if metadata is empty.
	Message string `json:"message,omitempty"`

	// Metadata is Event.Type-specific metadata. If an event has no metadata,
	// this will be nil.
	Metadata EventMetadata `json:"metadata,omitempty"`
}

func (Event) String

func (e Event) String() string

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(in []byte) error

func (Event) WorkloadIDStrings

func (e Event) WorkloadIDStrings() []string

type EventID

type EventID int64

type EventMetadata

type EventMetadata interface {
	Type() string
}

EventMetadata is a type safety trick used to make sure that Metadata field of Event is always a pointer, so that consumers can cast without being concerned about encountering a value type instead. It works by virtue of the fact that the method is only defined for pointer receivers; the actual method chosen is entirely arbitrary.

type EventWriter

type EventWriter interface {
	// LogEvent records a message in the history.
	LogEvent(Event) error
}

type ReleaseEventCommon

type ReleaseEventCommon struct {
	Revision string        // the revision which has the changes for the release
	Result   update.Result `json:"result"`
	// Message of the error if there was one.
	Error string `json:"error,omitempty"`
}

type ReleaseEventMetadata

type ReleaseEventMetadata struct {
	ReleaseEventCommon
	Spec  ReleaseSpec  `json:"spec"`
	Cause update.Cause `json:"cause"`
}

ReleaseEventMetadata is the metadata for when workloads(s) are released

func (*ReleaseEventMetadata) Type

func (rem *ReleaseEventMetadata) Type() string

type ReleaseSpec

type ReleaseSpec struct {
	// Type is ReleaseImageSpecType or ReleaseContainersSpecType
	// if empty (for previous version), then use ReleaseImageSpecType
	Type                  string
	ReleaseImageSpec      *update.ReleaseImageSpec
	ReleaseContainersSpec *update.ReleaseContainersSpec
}

ReleaseSpec is a spec for images and containers release

func (ReleaseSpec) IsKindExecute

func (s ReleaseSpec) IsKindExecute() (bool, error)

IsKindExecute reports whether the release spec s has ReleaseImageSpec or ReleaseImageSpec with Kind execute or error if s has invalid Type

func (*ReleaseSpec) UnmarshalJSON

func (s *ReleaseSpec) UnmarshalJSON(b []byte) error

UnmarshalJSON for old version of spec (update.ReleaseImageSpec) where Type is empty

type ResourceError

type ResourceError struct {
	ID    resource.ID
	Path  string
	Error string
}

type SyncEventMetadata

type SyncEventMetadata struct {
	// for parsing old events; Commits is now used in preference
	Revs    []string `json:"revisions,omitempty"`
	Commits []Commit `json:"commits,omitempty"`
	// Which "kinds" of commit this includes; release, autoreleases,
	// policy changes, and "other" (meaning things we didn't commit
	// ourselves)
	Includes map[string]bool `json:"includes,omitempty"`
	// Per-resource errors
	Errors []ResourceError `json:"errors,omitempty"`
	// `true` if we have no record of having synced before
	InitialSync bool `json:"initialSync,omitempty"`
}

SyncEventMetadata is the metadata for when new a commit is synced to the cluster

func (*SyncEventMetadata) Type

func (cem *SyncEventMetadata) Type() string

func (*SyncEventMetadata) UnmarshalJSON

func (ev *SyncEventMetadata) UnmarshalJSON(b []byte) error

Account for old events, which used the revisions field rather than commits

type UnknownEventMetadata

type UnknownEventMetadata map[string]interface{}

func (UnknownEventMetadata) Type

func (uem UnknownEventMetadata) Type() string

Special exception from pointer receiver rule, as UnknownEventMetadata is a type alias for a map

Jump to

Keyboard shortcuts

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