Version: v0.0.0-...-d1b097e Latest Latest

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

Go to latest
Published: Feb 19, 2019 License: Apache-2.0 Imports: 8 Imported by: 0




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"


This section is empty.


This section is empty.


type AutoReleaseEventMetadata

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

AutoReleaseEventMetadata is for when service(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"`

	// ServiceIDs affected by this event.
	ServiceIDs []flux.ResourceID `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) ServiceIDStrings

func (e Event) ServiceIDStrings() []string

func (Event) String

func (e Event) String() string

func (*Event) UnmarshalJSON

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

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 arbitary.

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 {
	Spec  ReleaseSpec  `json:"spec"`
	Cause update.Cause `json:"cause"`

ReleaseEventMetadata is the metadata for when service(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    flux.ResourceID
	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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL