Documentation ¶
Index ¶
- Constants
- Variables
- func CloseAllFiles()
- func ExpandEnvVars(ctx context.Context, value string) (string, error)
- func NewLogger(baseDefinition *LogDefinition, loggingContext *LoggingContext) (*logrus.Logger, error)
- func PrintError(format string, a ...interface{})
- type CtxKey
- type Event
- type LogDefinition
- type LogWriter
- type LoggingContext
- type Payload
- type Preflight
- type Probe
- type Spinner
- type Step
- type StepOptions
- type Workflow
- type WorkflowOptions
Constants ¶
const ( // EventRunRequested run requested EventRunRequested = "run.requested" // EventRunStarted run started EventRunStarted = "run.started" // EventRunError start failed EventRunError = "run.error" // EventRunFail ran but the command failed EventRunFail = "run.fail" // EventRunWaitError ran but failed on wait EventRunWaitError = "run.wait.error" // EventRunSuccess ran with success EventRunSuccess = "run.success" // EventRunTimeout run timed out EventRunTimeout = "run.timeout" // EventRunningProbe announces probing EventRunningProbe = "run.probing" )
const (
// FldStep is a logger field
FldStep = "Step"
)
Variables ¶
var ( // Version is trackman version Version = "0.0.1" // Channel is the build channel Channel = "dev" )
var ( // CtxSpinner is the key to a spinner on the context CtxSpinner = CtxKey{1} )
Functions ¶
func ExpandEnvVars ¶
ExpandEnvVars replaces any reference to environment variables with the OS envs
func NewLogger ¶
func NewLogger(baseDefinition *LogDefinition, loggingContext *LoggingContext) (*logrus.Logger, error)
NewLogger creates a new logger instance and sets the right log level based
func PrintError ¶
func PrintError(format string, a ...interface{})
PrintError prints an error to the console in red
Types ¶
type CtxKey ¶
type CtxKey struct {
// contains filtered or unexported fields
}
CtxKey is a context key
type LogDefinition ¶
type LogDefinition struct { Level string `yaml:"level" json:"level"` Type string `yaml:"type" json:"type"` Format string `yaml:"format" json:"format"` Destination string `yaml:"destination" json:"destination"` }
LogDefinition is used to define where a logger should log to
func DefaultLogDefinition ¶
func DefaultLogDefinition(baseDefinition *LogDefinition) *LogDefinition
DefaultLogDefinition returns a LogDefintion based on the given base if the base is nil it creates a new one if not nil, it fills the empty values with the defaults
type LogWriter ¶
type LogWriter struct {
// contains filtered or unexported fields
}
LogWriter implements io.Writer so it can be used to dump a process output but links it to logrus
func NewLogWriter ¶
NewLogWriter creates a new LogWriter
type LoggingContext ¶
LoggingContext is a structure that holds workflow and step and is used to determine log configuration
func NewLoggingContext ¶
func NewLoggingContext(workflow *Workflow, step *Step) *LoggingContext
NewLoggingContext creates a new logging context. Da
type Preflight ¶
type Preflight struct { Command string `yaml:"command" json:"command"` Message string `yaml:"message" json:"message"` Workdir string `yaml:"workdir" json:"workdir"` Timeout *time.Duration `yaml:"timeout" json:"timeout"` // contains filtered or unexported fields }
Preflight is a check that runs at the beginning of the workflow
type Probe ¶
type Probe struct { Command string `yaml:"command" json:"command"` Workdir string `yaml:"workdir" json:"workdir"` // contains filtered or unexported fields }
Probe defines a checker for a Step's health
type Spinner ¶
Spinner is the main component that runs a process
func NewSpinnerForPreflight ¶
NewSpinnerForPreflight creates a new instance of Spinner based on the Options
func NewSpinnerForProbe ¶
NewSpinnerForProbe creates a new instance of Spinner based on the Options
func NewSpinnerForStep ¶
NewSpinnerForStep creates a new instance of Spinner based on the Options
type Step ¶
type Step struct { Metadata map[string]string `yaml:"metadata" json:"metadata"` Name string `yaml:"name" json:"name"` Command string `yaml:"command" json:"command"` ContinueOnFail bool `yaml:"continue_on_fail" json:"continue_on_fail"` Timeout *time.Duration `yaml:"timeout" json:"timeout"` Workdir string `yaml:"workdir" json:"workdir"` Env []string `yaml:"env" json:"env"` Probe *Probe `yaml:"probe" json:"probe"` DependsOn []string `yaml:"depends_on" json:"depends_on"` Preflights []Preflight `yaml:"preflights" json:"preflights"` AskToProceed bool `yaml:"ask_to_proceed" json:"ask_to_proceed"` ShowCommand bool `yaml:"show_command" json:"show_command"` Disabled bool `yaml:"disabled" json:"disabled"` Logger *LogDefinition `yaml:"logger" json:"logger"` SessionID string // contains filtered or unexported fields }
Step is a single running Step
func (*Step) EnrichStep ¶
EnrichStep resolves environment variables and parses the command for the step on all applicable attributes
func (*Step) GetMetaData ¶
GetMetaData returns metadata value of the key from this Step. this is useful in event notifiers. It will return "" if there is no metadata with the given key
func (*Step) MarkAsPending ¶
func (s *Step) MarkAsPending()
MarkAsPending marks the step as pending meaning it's waiting to run
func (*Step) MergedMetadata ¶
MergedMetadata merges step and workflow metadata
type StepOptions ¶
type StepOptions struct {
Notifier func(ctx context.Context, logger *logrus.Logger, event *Event) error
}
StepOptions provides options for a Step
type Workflow ¶
type Workflow struct { Version string `yaml:"version" json:"version"` Metadata map[string]string `yaml:"metadata" json:"metadata"` Steps []*Step `yaml:"steps" json:"steps"` Logger *LogDefinition `yaml:"logger" json:"logger"` // contains filtered or unexported fields }
Workflow is the internal object to hold a workflow file
func LoadWorkflowFromBytes ¶
func LoadWorkflowFromBytes(ctx context.Context, options *WorkflowOptions, buff []byte) (*Workflow, error)
LoadWorkflowFromBytes loads a workflow from bytes
func LoadWorkflowFromReader ¶
func LoadWorkflowFromReader(ctx context.Context, options *WorkflowOptions, reader io.Reader) (*Workflow, error)
LoadWorkflowFromReader loads a workflow from an io reader
func (*Workflow) EnrichWorkflow ¶
EnrichWorkflow parses and replaces any placeholders in the workflow