Documentation
¶
Index ¶
- Constants
- func NewContextWithCapComm(ctx context.Context, capComm *CapComm) context.Context
- type CapComm
- func (capComm *CapComm) AddAdditionalMissionData(missionData TemplateData) *CapComm
- func (capComm *CapComm) AddFile(ctx context.Context, name NamedIO, filePath string, mode IOMode) error
- func (capComm *CapComm) AttachOutput(ctx context.Context, redirect OutputSpec) error
- func (capComm *CapComm) AttachRedirect(ctx context.Context, redirect Redirection) error
- func (capComm *CapComm) Copy(noTrust bool) *CapComm
- func (capComm *CapComm) ExpandString(ctx context.Context, name, value string) (string, error)
- func (capComm *CapComm) FuncMap() template.FuncMap
- func (capComm *CapComm) GetExecEnv() []string
- func (capComm *CapComm) GetFileDetails(name NamedIO) *FileDetail
- func (capComm *CapComm) GetTemplateData(ctx context.Context) TemplateData
- func (capComm *CapComm) MergeBasicEnvMap(env EnvMap) *CapComm
- func (capComm *CapComm) MergeParams(ctx context.Context, params []Param) error
- func (capComm *CapComm) MergeTemplateEnvs(ctx context.Context, env EnvMap) error
- func (capComm *CapComm) Seal() *CapComm
- func (capComm *CapComm) WithMission(mission *Mission) *CapComm
- type Delims
- type EnvMap
- type ExecuteFunc
- type FileDetail
- type Filter
- type Getter
- type IOMode
- type Include
- type KeyValueGetter
- type Mission
- type MissionControl
- type NamedIO
- type OutputSpec
- type Param
- type PreMission
- type Redirection
- type Runtime
- type Stage
- type Task
- type TaskType
- type TemplateData
Constants ¶
const ( // EnvTag is the root tag used in template data for environment variables // eg PATH is .Env.PATH EnvTag = "Env" // ParentEnvTag is the root tag for stage environment variables when the task is entrusted ParentEnvTag = "ParentEnv" // RunTimeTag is the remplate data key to the run time data RuntimeTag = "Runtime" // BuildTag is the data template key for build information about the hosting application BuildTag = "Build" // AdditionalMissionTag is the data template key to additional mission information AdditionalMissionTag = "Additional" // ConfigFile is the config file ConfigFile = "configFile" // ConfigBaseName is the base name of the config file, not path or extensions ConfigBaseName = "configBaseName" // ConfigDir is the config dir ConfigDir = "configDir" // ConfigFileFullPath is the full path to the config ConfigFileFullPath = "configFullPath" )
const ( InputIO = NamedIO("input") OutputIO = NamedIO("output") ErrorIO = NamedIO("error") )
const ( IOModeInput = IOMode(1 << iota) IOModeOutput IOModeError IOModeCreate IOModeAppend IOModeNone = IOMode(0) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CapComm ¶
type CapComm struct {
// contains filtered or unexported fields
}
CapComm handles all communication between mission control and the mission stages and tasks
func GetCapCommContext ¶
GetRunContext returns the run context
func (*CapComm) AddAdditionalMissionData ¶
func (capComm *CapComm) AddAdditionalMissionData(missionData TemplateData) *CapComm
AddAdditionalMissionData adds the additional mission data
func (*CapComm) AddFile ¶
func (capComm *CapComm) AddFile(ctx context.Context, name NamedIO, filePath string, mode IOMode) error
AddFile adds a key named file specificsation into the CapComm. The filePath follows standard template and environment variable expansion. The mode controls how the file will be used. Files can be added to sealed CapComm's
func (*CapComm) AttachOutput ¶
func (capComm *CapComm) AttachOutput(ctx context.Context, redirect OutputSpec) error
AttachOutput attaches an output specification to a capComm.
func (*CapComm) AttachRedirect ¶
func (capComm *CapComm) AttachRedirect(ctx context.Context, redirect Redirection) error
AttachRedirect attaches a redirection specification to the capComm Redirection covers in, out and error streams.
func (*CapComm) Copy ¶
Copy creates a new unsealed CapComm instance and deep copies the current CapComm's values into it
func (*CapComm) ExpandString ¶
ExpandString expands a templated string using the capComm's template data
func (*CapComm) GetExecEnv ¶
GetExecEnv converts the environment variables map into the string format needed for a exec Cmd
func (*CapComm) GetFileDetails ¶
func (capComm *CapComm) GetFileDetails(name NamedIO) *FileDetail
GetFileDetails returns the file details of the named file. If the file key does not exist nil is returned.
func (*CapComm) GetTemplateData ¶
func (capComm *CapComm) GetTemplateData(ctx context.Context) TemplateData
GetTemplateData gts the data collection supplied to a template
func (*CapComm) MergeBasicEnvMap ¶
MergeBasicEnvMap adds environment variables into an unsealed CapComm
func (*CapComm) MergeParams ¶
MergeParams adds params into an unsealed CapComm instance
func (*CapComm) MergeTemplateEnvs ¶
MergeTemplateEnvs adds params into an unsealed CapComm instance
func (*CapComm) Seal ¶
Seal prevents further editing of the capComm any attempt to edit will cause a panic (as this is a development bug)
func (*CapComm) WithMission ¶
WithMission attaches the mission to the CapComm
type Delims ¶
type Delims struct {
// Left is the opening delimiter
Left string `mapstructure:"left"`
// Right is the closing delimiter
Right string `mapstructure:"right"`
}
Delims are the delimiters to use to escape template functions
type ExecuteFunc ¶
type ExecuteFunc = loggee.ActivityFunc
ExecuteFunc is the function signature of an activity that can be executed
type FileDetail ¶
type FileDetail struct {
// contains filtered or unexported fields
}
FileDetail represents file details
func (*FileDetail) FilePath ¶
func (fd *FileDetail) FilePath() string
func (*FileDetail) InMode ¶
func (fd *FileDetail) InMode(mode IOMode) bool
InMode returns true if the file in in the mode in question
func (*FileDetail) OpenOutput ¶
func (fd *FileDetail) OpenOutput() (*os.File, error)
OpenOutput opens an output file
type Filter ¶
type Filter struct {
// IncludeOS is a list of operating systems to include
IncludeOS []string `mapstructure:"includeOS"`
// IncludeArch is a list of architectures to permit
IncludeArch []string `mapstructure:"includeArch"`
// ExcludeOS restricts an operating system from running
ExcludeOS []string `mapstructure:"excludeOS"`
// ExcludeArch restricts specific architectures from running
ExcludeArch []string `mapstructure:"excludeArch"`
// Skip prevents theactivity from running if true.
Skip bool `mapstructure:"skip"`
}
Filter restricts running an activity The filter applis to the OS and Architecture of the machine running rocket. This allows OS specific scripts to be used.
type Getter ¶
type Getter interface {
// Get a value
Get(key string) string
// All returns all the entries
All() map[string]string
}
Getter returns a value for an input key, iif the key is not found an empty string is returned
type KeyValueGetter ¶
type KeyValueGetter struct {
// contains filtered or unexported fields
}
KeyValueGetter is a value map with fallback to a parent Getter
func NewKeyValueGetter ¶
func NewKeyValueGetter(parent Getter) *KeyValueGetter
NewKeyValueGetter creates a new KeyValueGetter
func (*KeyValueGetter) All ¶
func (kvg *KeyValueGetter) All() map[string]string
All returns the values tp down, where child values override parent key values
func (*KeyValueGetter) Get ¶
func (kvg *KeyValueGetter) Get(key string) string
Get returns the value for a key
type Mission ¶
type Mission struct {
// Mission name, defsaults to the config file name
Name string `mapstructure:"name"`
// Additional contains any additional paramters specified in the
// configuration. They are included in the template data set
// but will be overridden by any other duplicate keys
Additional map[string]interface{} `mapstructure:",remain"`
// BasicEnv is a map of additional environment variables
// They are not template expanded
BasicEnv EnvMap `mapstructure:"basicEnv"`
// Env is a map of additional environment variables
// These are subject to template expansion after the params have been expanded
Env EnvMap `mapstructure:"env"`
// Params is a collection of parameters that can be used within
// the child stages. Paramters are template expanded and can use
// Environment variables defined in Env
Params []Param `mapstructure:"params"`
// Sequences specify a list of stages to run.
// If no sequences are provides all stages are run in the order they are defined.
// If sequences are included in the mission one must be specified or the mission will fail
Sequences map[string][]string `mapstructure:"sequences"`
// Stages represents the stages of the mission
// If no sequences are included in the file all stages are executed in ordinal order.
// If a sequence is included in the mission file the fly mission call must specify the sequence to use.
Stages []Stage `mapstructure:"stages"`
// Version of the mission definition
Version string `mapstructure:"version"`
}
Mission is activity to complete
type MissionControl ¶
type MissionControl interface {
// RegisterTaskTypes we only want the best
RegisterTaskTypes(types ...TaskType)
// FlyMission loads and executes the mission
// flightSequences may be specified, each sequence is run in the order specified
// the coonfig file is the source name iof the config provided
// if its empty the current working 'dir/default' will be used
FlyMission(ctx context.Context, configFile string, spaceDust map[string]interface{}, flightSequences ...string) error
}
MissionControl seeks out new civilizations in te CI space
func NewMissionControl ¶
func NewMissionControl() MissionControl
NewMissionControl create a new mission control
type OutputSpec ¶
type Param ¶
type Param struct {
// Name is the name of the parameter
// Name is mandatory
Name string `mapstructure:"name"`
// Value is the value of the parameter and is subject to expandion
Value string `mapstructure:"value"`
// File is a path to file containing the value.
// If both File and Value are supplied the file will bee appended to the Valued
// The combined value will undergo template expansion
File string `mapstructure:"file"`
// SkipTemplate skip templating the param
SkipTemplate bool `mapstructure:"skipTemplate"`
// FileOptional if truew allows the file not to exist
FileOptional bool `mapstructure:"optional"`
}
Param is an expandible parameter
type PreMission ¶
type PreMission struct {
Mission map[string]interface{} `mapstructure:",remain"`
Includes []Include `mapstructure:"includes"`
}
PreMission preprocesses missions before loading them
type Redirection ¶
type Redirection struct {
OutputSpec `mapstructure:",squash"`
// Input is a file path to an existing input file replacing STDIN
Input string `mapstructure:"input"`
// Error is a path to a file replacing STDERR
Error string `mapstructure:"error"`
// AppendError specifies if error output should append
AppendError bool `mapstructure:"appendError"`
// MergeErrorWithOutput specifies if error output should go to outputt
// if specified Error and AppendError are ignored
MergeErrorWithOutput bool `mapstructure:"merge"`
}
Redirection is provided to a task to interpret Redirection strings need to be expanded by the task
type Runtime ¶
type Runtime struct {
// GOOS is the operating system the host application is running against
GOOS string
// GOARCH is the architecture the host application is running against
GOARCH string
}
Runtime holds runtime data accessible to templates
type Stage ¶
type Stage struct {
// Name of th stage.
// If it is not provided it default to the ordinal ID of the stage within the mission
Name string `mapstructure:"name"`
// BasicEnv is a map of additional environment variables
// They are not template expanded
BasicEnv EnvMap `mapstructure:"basicEnv"`
// Env is a map of additional environment variables
// These are subject to template expansion after the params have been expanded
Env EnvMap `mapstructure:"env"`
// Filter is an optional filter on the stage
// If the filter criteria are not met the stage will not be executed
Filter *Filter `mapstructure:"filter"`
// NoTrust indicates the stage should not inherit environment
// variables or paramters from its parent. This can be used with a run stage
// where you do not want the process to receive API tokens etc
NoTrust bool `mapstructure:"noTrust"`
// Params is a collection of parameters that can be used within
// the child stages. Paramters are template expanded and can use
// Environment variables defined in Env
Params []Param `mapstructure:"params"`
// Tasks is a collection of one or more tasks to complete
// Tasks are executed sequentally
Tasks []Task `mapstructure:"tasks"`
// Try to run the stage but if it fails do no abort the whole run
Try bool `mapstructure:"try"`
}
State iis a collection of tasks that can share a common set of parameters All tasks within a stage are executed sequently
type Task ¶
type Task struct {
// Type is the type of the task. The task type must have been rejiggered
// with the mission control. Tasks not registered will fail the mission.
Type string `mapstructure:"type"`
// Name of the task.
// If it is not provided it default to the ordinal ID of the task within the stage
Name string `mapstructure:"name"`
// Definition contains the additional data required to process the task type
Definition map[string]interface{} `mapstructure:",remain"`
// BasicEnv is a map of additional environment variables
// They are not template expanded
BasicEnv EnvMap `mapstructure:"basicEnv"`
// Env is a map of additional environment variables
// These are subject to template expansion after the params have been expanded
Env EnvMap `mapstructure:"env"`
// Filter is an optional filter on the task
// If the filter criteria are not met the task will not be executed
Filter *Filter `mapstructure:"filter"`
// NoTrust indicates the task should not inherit environment
// variables or paramters from the parent. This can be used with a run task
// where you do not want the process to receive API tokens etc
NoTrust bool `mapstructure:"noTrust"`
// Params is a collection of parameters that can be used within
// the child stages. Paramters are template expanded and can use
// Environment variables defined in Env
Params []Param `mapstructure:"params"`
// Try to run the task but if it fails do no abort the whole run
Try bool `mapstructure:"try"`
}
Task is an activity that is executed
type TaskType ¶
type TaskType interface {
// Type of the task
Type() string
// Prepare the task from the input details
Prepare(ctx context.Context, capComm *CapComm, task Task) (ExecuteFunc, error)
}
TaskType represents a specific task type
type TemplateData ¶
type TemplateData map[string]interface{}
TemplateData represents the data passed t a template