graph

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ImmediateExecutionToken defines the when dependency to indicate a step should execute immediately.
	ImmediateExecutionToken = "-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dag

type Dag struct {
	Root  *Node
	Nodes map[string]*Node
	// contains filtered or unexported fields
}

Dag represents a thread safe directed acyclic graph.

func NewDag

func NewDag() *Dag

NewDag creates a new Dag with a root vertex.

func NewDagFromPipeline

func NewDagFromPipeline(p *Pipeline) (*Dag, error)

NewDagFromPipeline creates a new Dag based on the specified pipeline.

func (*Dag) AddEdge

func (d *Dag) AddEdge(from string, to string) error

AddEdge adds an edge between from and to.

func (*Dag) AddVertex

func (d *Dag) AddVertex(value *Step) (*Node, error)

AddVertex adds a vertex to the Dag with the specified name and value.

func (*Dag) RemoveEdge

func (d *Dag) RemoveEdge(from string, to string) error

RemoveEdge removes the edge between from and to.

type Node

type Node struct {
	Name  string
	Value *Step
	// contains filtered or unexported fields
}

Node represents a vertex in a Dag.

func NewNode

func NewNode(value *Step) *Node

NewNode creates a new Node based on the provided name and value.

func (*Node) Children

func (n *Node) Children() []*Node

Children returns the node's children.

func (*Node) GetDegree

func (n *Node) GetDegree() int

GetDegree returns the degree of the node.

type Pipeline

type Pipeline struct {
	Steps            []*Step   `yaml:"steps"`
	StepTimeout      int       `yaml:"stepTimeout,omitempty"`
	TotalTimeout     int       `yaml:"totalTimeout,omitempty"`
	Push             []string  `yaml:"push,omitempty"`
	Secrets          []*Secret `yaml:"secrets,omitempty"`
	WorkDir          string    `yaml:"workDir,omitempty"`
	RegistryName     string
	RegistryUsername string
	RegistryPassword string
	Dag              *Dag
}

Pipeline represents a build pipeline.

func NewPipeline

func NewPipeline(
	steps []*Step,
	push []string,
	secrets []*Secret,
	registry string,
	user string,
	pw string) (*Pipeline, error)

NewPipeline returns a default Pipeline object.

func UnmarshalPipelineFromFile

func UnmarshalPipelineFromFile(file, registry, user, pw string) (*Pipeline, error)

UnmarshalPipelineFromFile unmarshals a pipeline from a file.

func UnmarshalPipelineFromString

func UnmarshalPipelineFromString(data, registry, user, pw string) (*Pipeline, error)

UnmarshalPipelineFromString unmarshals a pipeline from a raw string.

func (*Pipeline) UsingRegistryCreds

func (p *Pipeline) UsingRegistryCreds() bool

UsingRegistryCreds determines whether or not the pipeline is using registry creds.

type Secret

type Secret struct {
	Akv       string `yaml:"akv,omitempty"`
	SecretEnv string `yaml:"secretEnv,omitempty"`
}

Secret defines a wrapper to translate Azure Key Vault secrets to environment variables.

type SelfReferencedStepError

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

SelfReferencedStepError defines an error to be returned if the Step is self-referenced.

func NewSelfReferencedStepError

func NewSelfReferencedStepError(message string) *SelfReferencedStepError

NewSelfReferencedStepError creates a new SelfReferencedStepError with the specified message.

func (*SelfReferencedStepError) Error

func (e *SelfReferencedStepError) Error() string

Error returns the error message for a SelfReferencedStepError.

type Step

type Step struct {
	ID            string   `yaml:"id"`
	Run           string   `yaml:"run"`
	WorkDir       string   `yaml:"workDir"`
	EntryPoint    string   `yaml:"entryPoint"`
	Envs          []string `yaml:"envs"`
	SecretEnvs    []string `yaml:"secretEnvs"`
	Ports         []string `yaml:"ports"`
	When          []string `yaml:"when"`
	ExitedWith    []int    `yaml:"exitedWith"`
	ExitedWithout []int    `yaml:"exitedWithout"`
	Timeout       int      `yaml:"timeout"`
	Rm            bool     `yaml:"rm"`
	Detach        bool     `yaml:"detach"`
	StartDelay    int      `yaml:"startDelay"`
	Privileged    bool     `yaml:"privileged"`
	User          string   `yaml:"user"`

	StartTime  time.Time
	EndTime    time.Time
	StepStatus StepStatus

	// CompletedChan can be used to signal to readers
	// that the step has been processed.
	CompletedChan chan bool

	ImageDependencies []*models.ImageDependencies
	Tags              []string
	BuildArgs         []string
}

Step is a step in the execution pipeline.

func (*Step) Equals

func (s *Step) Equals(t *Step) bool

Equals determines whether or not two steps are equal.

func (*Step) HasNoWhen

func (s *Step) HasNoWhen() bool

HasNoWhen returns true if the Step has no when clause, false otherwise.

func (*Step) IsBuildStep

func (s *Step) IsBuildStep() bool

IsBuildStep returns true if the Step is a build step, false otherwise.

func (*Step) ShouldExecuteImmediately

func (s *Step) ShouldExecuteImmediately() bool

ShouldExecuteImmediately returns true if the Step should be executed immediately.

func (*Step) Validate

func (s *Step) Validate() error

Validate validates the step and returns an error if the Step has problems.

type StepStatus

type StepStatus string

StepStatus is an enum for step statuses.

const (
	// InProgress means the step is being processed.
	InProgress StepStatus = "inprogress"

	// Successful means the step completed and was successful.
	Successful StepStatus = "successful"

	// Skipped means the step has been skipped.
	Skipped StepStatus = "skipped"

	// Failed means the step failed because of an error.
	Failed StepStatus = "failed"
)

Jump to

Keyboard shortcuts

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