mission

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletedError

type CompletedError struct{}

func (*CompletedError) Error

func (e *CompletedError) Error() string

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph object represents the mission DAG in terms of links between stages

func NewGraph

func NewGraph(m *Mission) *Graph

NewGraph builds graph object. note: This runs before we check that all stages are defined, so it just skips stages that can't be found.

func (g *Graph) AddLink(from *Stage, to *Stage)

AddLink is used to create the graph object from each link seen in the graph.

func (*Graph) CheckForCycle

func (g *Graph) CheckForCycle(s *Stage, visited map[*Stage]bool, recursion map[*Stage]bool) bool

CheckForCycle recursively crawls the graph and returns true if starting stage is seen again.

func (*Graph) CheckForIncontiguity

func (g *Graph) CheckForIncontiguity(stages []*Stage) *Stage

CheckForIncontiguity returns the first stage found that can't be reached from the starting stage. If the graph is contiguous then it will return nil.

func (*Graph) Print

func (g *Graph) Print()

type Mission

type Mission struct {
	Id       string                 `json:"i" name:"id"`
	Name     string                 `json:"n" name:"name"` // the plan name, note: not needed in a mission
	Services []string               `json:"a" name:"services"`
	Stages   []*Stage               `json:"s" name:"stages"`
	Params   map[string]interface{} `json:"p" name:"params"`
	Start    time.Time              `json:"t" name:"start"`
	End      time.Time              `json:"e" name:"end"`
	// contains filtered or unexported fields
}

func New

func New(name string, stages []*Stage) Mission

New creates a new mission from the minimum amount of information. Should only be used when converting plans to missions for validation.

func NewFromJSON

func NewFromJSON(jsonString []byte) (Mission, error)

NewFromJSON creates missions objects from their database representation in JSON. Runs every time the mission is modified.

func (*Mission) Bytes

func (m *Mission) Bytes() []byte

Bytes converts mission to it's json representation as bytes. Used for outputting missions.

func (*Mission) CheckComplete

func (m *Mission) CheckComplete()

CheckComplete marks the mission as complete if all stages have been finished, excluded, or skipped. Should run every time a stage is finished, excluded or skipped.

func (*Mission) ExcludeStage

func (m *Mission) ExcludeStage(stageName string) (Response, error)

ExcludeStage changes a stage's state to excluded using the following logic: - does stage exist? - state can't be started, finished, failed or skipped - are all upstream dependencies ready? - all downstream dependencies must be excluded too

func (*Mission) FailStage

func (m *Mission) FailStage(stageName string) (Response, error)

FailStage changes a stage's state to failed using the following logic: - does stage exist? - state can't be ready, failed, excluded, skipped or failed, just started

func (*Mission) FinishStage

func (m *Mission) FinishStage(stageName string, ignoreDependencies bool) (Response, error)

FinishStage changes a stage's state to finished using the following logic: - does stage exist? - is stage ready or failed (all other states are not allowed)? - are all upstream dependencies finished or skipped?

func (*Mission) GetStage

func (m *Mission) GetStage(stageName string) (*Stage, error)

func (*Mission) Next

func (m *Mission) Next() []string

Next finds all stages that are eligible to run.

func (*Mission) Print

func (m *Mission) Print()

Print prints all the information about the mission.

func (*Mission) Report

func (m *Mission) Report() string

Report prints a text alternative to the mission dashboard.

func (*Mission) SkipStage

func (m *Mission) SkipStage(stageName string) (Response, error)

SkipStage changes a stage's state to skip using the following logic: - does stage exist? - state can't be started, excluded or already skipped? - are all upstream dependencies finished or skipped?

func (*Mission) StartStage

func (m *Mission) StartStage(stageName string, ignoreDependencies bool) (Response, error)

StartStage changes a stage's state to started using the following logic: - does stage exist? - is stage ready or failed? (all other states are not allowed) - are all upstream dependencies finished or skipped?

func (*Mission) Validate

func (m *Mission) Validate() error

Validate tests mission is valid using the following logic: - more than 0 stages - no duplicate stage names - all referenced stages exist - graph is not cyclic - graph is contiguous (no orphaned stages)

type PlanValidationError

type PlanValidationError struct {
	Detail string
}

func (*PlanValidationError) Error

func (e *PlanValidationError) Error() string

type Response

type Response struct {
	Success    bool     `json:"success"`
	Next       []string `json:"next"`
	IsComplete bool     `json:"complete"`
}

Response given when the user requests to change the state of a stage, e.g. start, finish, ignore, skip.

type Stage

type Stage struct {
	Name       string                 `json:"n" name:"name"`
	Service    string                 `json:"a" name:"service"`
	Upstream   []string               `json:"u" name:"upstream"`
	Downstream []string               `json:"d" name:"downstream"`
	Params     map[string]interface{} `json:"p" name:"params"`
	State      state                  `json:"s" name:"state"`
	Start      time.Time              `json:"t" name:"start"`
	End        time.Time              `json:"e" name:"end"`
}

func (*Stage) Print

func (s *Stage) Print()

func (*Stage) PrintDuration

func (s *Stage) PrintDuration() string

type StageChangeError

type StageChangeError struct {
	Detail string
}

func (*StageChangeError) Error

func (e *StageChangeError) Error() string

type StageNotFoundError

type StageNotFoundError struct {
	StageName string
}

func (*StageNotFoundError) Error

func (e *StageNotFoundError) Error() string

Jump to

Keyboard shortcuts

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