stages

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package stages defines the stages which are included in pipelines.

Package stages contains functionality for managing stage lifecycle

Package stages contains functionality for managing stage lifecycle

Package stages contains functionality for managing stage lifecycle

Package stages contains functionality for managing stage lifecycle

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareCh

func PrepareCh(stage Stage)

PrepareCh prepares input and output channels.

Types

type BaseStage

type BaseStage struct {
	// Run specified process. The required method (Run) is defined in the inheirted structs.
	Runner

	// Input channel. This channel stores the input of the statge.
	InputCh *chan Mediator

	// Output channel. This channel stores the output of the statge.
	OutputCh *chan Mediator

	// List of child stages.
	ChildStages list.List

	// Stage name.
	StageName string `config:"name"`

	// Results of stdout flush by the stage.
	OutResult string

	// Results of stderr flush by the stage.
	ErrResult string

	// Return value of the stage
	ReturnValue bool

	// options of the stage.
	Opts StageOpts
}

BaseStage is an abstract struct implemented by the inherited struct that wishes to run somthing in a stage.

func (*BaseStage) AddChildStage

func (b *BaseStage) AddChildStage(stage Stage)

AddChildStage appends one child stage.

func (*BaseStage) GetChildStages

func (b *BaseStage) GetChildStages() list.List

GetChildStages returns a list of child stages.

func (*BaseStage) GetErrResult added in v1.1.0

func (b *BaseStage) GetErrResult() string

GetErrResult returns standard error results.

func (*BaseStage) GetInputCh

func (b *BaseStage) GetInputCh() *chan Mediator

GetInputCh retruns input channel.

func (*BaseStage) GetOutResult added in v1.1.0

func (b *BaseStage) GetOutResult() string

GetOutResult returns standard output results.

func (*BaseStage) GetOutputCh

func (b *BaseStage) GetOutputCh() *chan Mediator

GetOutputCh retruns output channel.

func (*BaseStage) GetReturnValue added in v1.3.0

func (b *BaseStage) GetReturnValue() bool

GetReturnValue returns return value of the stage

func (*BaseStage) GetStageName

func (b *BaseStage) GetStageName() string

GetStageName returns the name of the current stage

func (*BaseStage) GetStageOpts added in v1.1.0

func (b *BaseStage) GetStageOpts() StageOpts

GetStageOpts returns stage options.

func (*BaseStage) Run

func (b *BaseStage) Run() bool

Run executes the stage.

func (*BaseStage) SetErrResult added in v1.1.0

func (b *BaseStage) SetErrResult(result string)

SetErrResult sets standard error results.

func (*BaseStage) SetInputCh

func (b *BaseStage) SetInputCh(inputCh *chan Mediator)

SetInputCh sets input channel.

func (*BaseStage) SetOutResult added in v1.1.0

func (b *BaseStage) SetOutResult(result string)

SetOutResult sets standard output results.

func (*BaseStage) SetOutputCh

func (b *BaseStage) SetOutputCh(outputCh *chan Mediator)

SetOutputCh sets output channel.

func (*BaseStage) SetStageName

func (b *BaseStage) SetStageName(stageName string)

SetStageName sets stage name.

func (*BaseStage) SetStageOpts added in v1.1.0

func (b *BaseStage) SetStageOpts(stageOpts StageOpts)

SetStageOpts sets stage options.

type CommandStage

type CommandStage struct {
	BaseStage
	Command   string `config:"command" is_replace:"false"`
	Directory string `config:"directory" is_replace:"true"`
	OnlyIf    string `config:"only_if" is_replace:"false"`
}

CommandStage executes more than one commands.

func NewCommandStage

func NewCommandStage() *CommandStage

NewCommandStage creates one CommandStage object.

func (*CommandStage) AddCommand

func (commandStage *CommandStage) AddCommand(command string)

AddCommand registers the specified command.

func (*CommandStage) GetStdoutResult

func (commandStage *CommandStage) GetStdoutResult() string

GetStdoutResult returns the stdio output from the command.

func (*CommandStage) Run

func (commandStage *CommandStage) Run() bool

Run registered commands.

func (*CommandStage) SetDirectory

func (commandStage *CommandStage) SetDirectory(directory string)

SetDirectory sets the directory where the command is executed.

type Mediator

type Mediator struct {
	States map[string]string
	Type   string
}

Mediator stores the intermidate results.

func (*Mediator) IsAnyFailure added in v0.2.0

func (m *Mediator) IsAnyFailure() bool

IsAnyFailure returns true when mediator found any failures. Otherwise This method returns false.

type ResourceValidator

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

ResourceValidator class check if the resources to run the target staget are satisfied.

func NewResourceValidator

func NewResourceValidator() *ResourceValidator

NewResourceValidator creates a new ResourceValidator

func (*ResourceValidator) AddCommandName

func (resourceValidator *ResourceValidator) AddCommandName(c string)

AddCommandName adds the command to the validator

func (*ResourceValidator) AddFile

func (resourceValidator *ResourceValidator) AddFile(f string)

AddFile add the suplied file to the validator file list TODO add permission

func (*ResourceValidator) Validate

func (resourceValidator *ResourceValidator) Validate() bool

Validate validates if the command can be executed

type Runner

type Runner interface {
	Run() bool
}

Runner contains the Run method which is deined in Stage implemantations.

type ShellScriptStage

type ShellScriptStage struct {
	ResourceValidator
	CommandStage
	File string `config:"file"`
}

ShellScriptStage executes one shell script file.

func NewShellScriptStage

func NewShellScriptStage() *ShellScriptStage

NewShellScriptStage generate one ShellScriptStage object.

func (*ShellScriptStage) Run

func (shellScriptStage *ShellScriptStage) Run() bool

Run exectues specified shell script.

type Stage

type Stage interface {
	AddChildStage(Stage)
	GetChildStages() list.List
	GetStageName() string
	SetStageName(string)
	GetStageOpts() StageOpts
	SetStageOpts(StageOpts)
	GetInputCh() *chan Mediator
	SetInputCh(*chan Mediator)
	GetOutputCh() *chan Mediator
	SetOutputCh(*chan Mediator)
	GetOutResult() string
	SetOutResult(string)
	GetErrResult() string
	SetErrResult(string)
	GetReturnValue() bool
}

Stage is a interface type which declares a list of methods every Stage object should define.

func InitStage

func InitStage(stageType string) (Stage, error)

InitStage initializes a stage with specified stage type.

type StageOpts added in v1.1.0

type StageOpts struct {
	// Flush all output when the value is true.
	ReportingFullOutput bool `config:"report_full_output"`
}

StageOpts struct for handing stage outputs

func NewStageOpts added in v1.1.0

func NewStageOpts() *StageOpts

NewStageOpts creates a new stage output

Jump to

Keyboard shortcuts

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