Documentation
¶
Index ¶
- Variables
- func WithErrCtxLogAdditionalCtx(logAdditionalCtx bool) func(*ErrorCtx)
- type Cache
- type Describer
- type Environment
- type ErrorCtx
- type ExecResult
- type ExecutableStep
- type FileSystemStepResource
- type GitStepResource
- type GlobalContext
- type LazilyLoadedStep
- type NamedStepReference
- type Params
- type Parser
- type SequenceOfSteps
- type Step
- type StepFile
- func (s *StepFile) Path() string
- func (s *StepFile) ReadDotEnv() (map[string]string, error)
- func (s *StepFile) ReadEnvironment() (*Environment, error)
- func (s *StepFile) ReadKeyValueLines() (map[string]*structpb.Value, error)
- func (s *StepFile) ReadStepResult() (*proto.StepResult, error)
- func (s *StepFile) ReadValues(specOutputs map[string]*proto.Spec_Content_Output) (map[string]*structpb.Value, error)
- func (s *StepFile) Remove() error
- type StepFileLine
- type StepParser
- type StepReference
- type StepResource
- type StepResultBuilder
- func (bldr *StepResultBuilder) Build() *proto.StepResult
- func (bldr *StepResultBuilder) BuildFailure() *proto.StepResult
- func (bldr *StepResultBuilder) ObserveEnv(env *Environment, err error) error
- func (bldr *StepResultBuilder) ObserveExecutedCmd(execResult *ExecResult, err error) error
- func (bldr *StepResultBuilder) ObserveExports(exports *Environment, err error) (*Environment, error)
- func (bldr *StepResultBuilder) ObserveOutputs(outputs map[string]*structpb.Value, err error) error
- func (bldr *StepResultBuilder) ObserveStepResult(stepResult *proto.StepResult, err error) (*proto.StepResult, error)
- func (bldr *StepResultBuilder) WithEnv(env map[string]string) *StepResultBuilder
- func (bldr *StepResultBuilder) WithExecResult(executedCmd *ExecResult) *StepResultBuilder
- func (bldr *StepResultBuilder) WithExports(exports *Environment) *StepResultBuilder
- func (bldr *StepResultBuilder) WithOutputs(outputs map[string]*structpb.Value) *StepResultBuilder
- func (bldr *StepResultBuilder) WithSubStepResult(result *proto.StepResult) *StepResultBuilder
- type StepsContext
- func (s *StepsContext) Cleanup()
- func (s *StepsContext) ExpandAndApplyEnv(env map[string]string) (*Environment, error)
- func (s *StepsContext) GetEnvList() []string
- func (s *StepsContext) GetEnvs() map[string]string
- func (s *StepsContext) RecordResult(stepResult *proto.StepResult)
- func (s *StepsContext) StepResults() []*proto.StepResult
- func (s *StepsContext) View() *expression.InterpolationContext
Constants ¶
This section is empty.
Variables ¶
var RunningInDebugMode, _ = strconv.ParseBool(os.Getenv("CI_STEPS_DEBUG"))
var StepDefinedInGitLabJob = NewNamedStepReference("", nil)
StepDefinedInGitLabJob is a step defined in a GitLab jobs using the run: syntax or STEPS: variable
Functions ¶
func WithErrCtxLogAdditionalCtx ¶ added in v0.2.0
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, parentDir string, stepResource StepResource) (*proto.SpecDefinition, error)
}
type Describer ¶
type Describer interface {
Describe() string
}
Describer types know how to describe themselves in a language to be read by humans
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment represents environment variables. Environment variables are used in places such as the step export_file, step definitions with ENV, and OS environment. Environment does not merge maps, and so does not lose information. Merging of environments occurs when values are retrieved. An environment can be added as "lexical scope", these values have higher precedence when looking up a variable. Mutations to the environment take precedence over initialized variables, most recent mutations have the highest precedence
func NewEmptyEnvironment ¶
func NewEmptyEnvironment() *Environment
func NewEnvironment ¶
func NewEnvironment(vars map[string]string) *Environment
func NewEnvironmentFromOS ¶
func NewEnvironmentFromOS(rejectIf ...func(string) bool) (*Environment, error)
NewEnvironmentFromOS returns the environment variables found in the OS runtime. Variables can be filtered by name, passing no names will return all variables.
func NewEnvironmentFromOSWithKnownVars ¶
func NewEnvironmentFromOSWithKnownVars() (*Environment, error)
func NewKVEnvironment ¶
func NewKVEnvironment(keyValues ...string) *Environment
NewKVEnvironment creates an environment from a list of key values
func (*Environment) AddLexicalScope ¶
func (e *Environment) AddLexicalScope(vars map[string]string) *Environment
func (*Environment) Len ¶
func (e *Environment) Len() int
func (*Environment) Mutate ¶
func (e *Environment) Mutate(env *Environment)
func (*Environment) ValueOf ¶
func (e *Environment) ValueOf(key string) string
func (*Environment) Values ¶
func (e *Environment) Values() map[string]string
type ErrorCtx ¶ added in v0.2.0
type ErrorCtx struct {
// contains filtered or unexported fields
}
func NewErrorCtx ¶ added in v0.2.0
type ExecResult ¶
type ExecResult struct {
// contains filtered or unexported fields
}
func NewExecResult ¶
func NewExecResult(workDir string, cmdArgs []string, exitCode int) *ExecResult
func (*ExecResult) ToProto ¶
func (ec *ExecResult) ToProto() *proto.StepResult_ExecResult
type ExecutableStep ¶
type ExecutableStep struct {
// contains filtered or unexported fields
}
ExecutableStep is a step that executes a command.
func NewExecutableStep ¶
func NewExecutableStep(loadedFrom StepReference, params *Params, specDef *proto.SpecDefinition) *ExecutableStep
func (*ExecutableStep) Describe ¶
func (s *ExecutableStep) Describe() string
func (*ExecutableStep) Run ¶
func (s *ExecutableStep) Run(ctx ctx.Context, stepsCtx *StepsContext) (*proto.StepResult, error)
type FileSystemStepResource ¶
type FileSystemStepResource struct {
// contains filtered or unexported fields
}
FileSystemStepResource knows how to load a step from the file system
func NewFileSystemStepResource ¶
func NewFileSystemStepResource(path []string, filename string) *FileSystemStepResource
func (*FileSystemStepResource) Describe ¶
func (sr *FileSystemStepResource) Describe() string
func (*FileSystemStepResource) Interpolate ¶
func (sr *FileSystemStepResource) Interpolate(_ *expression.InterpolationContext) (StepResource, error)
func (*FileSystemStepResource) ToProtoStepRef ¶
func (sr *FileSystemStepResource) ToProtoStepRef() *proto.Step_Reference
type GitStepResource ¶
type GitStepResource struct {
// contains filtered or unexported fields
}
GitStepResource knows how to load a step from a Git repository
func NewGitStepResource ¶
func NewGitStepResource(url string, version string, path []string, filename string) *GitStepResource
func (*GitStepResource) Describe ¶
func (sr *GitStepResource) Describe() string
func (*GitStepResource) Interpolate ¶
func (sr *GitStepResource) Interpolate(view *expression.InterpolationContext) (StepResource, error)
func (*GitStepResource) ToProtoStepRef ¶
func (sr *GitStepResource) ToProtoStepRef() *proto.Step_Reference
type GlobalContext ¶
type GlobalContext struct { WorkDir string Job map[string]string Env *Environment Stdout io.Writer Stderr io.Writer }
func NewGlobalContext ¶
func NewGlobalContext(env *Environment) *GlobalContext
type LazilyLoadedStep ¶
type LazilyLoadedStep struct {
// contains filtered or unexported fields
}
LazilyLoadedStep is a step that dynamically fetches, parses and executes a step definition.
func NewLazilyLoadedStep ¶
func NewLazilyLoadedStep(globalCtx *GlobalContext, resourceLoader Cache, parser StepParser, stepReference *proto.Step, stepResource StepResource, workDir string) *LazilyLoadedStep
func (*LazilyLoadedStep) Describe ¶
func (s *LazilyLoadedStep) Describe() string
func (*LazilyLoadedStep) Run ¶
func (s *LazilyLoadedStep) Run(ctx ctx.Context, parentStepsCtx *StepsContext) (*proto.StepResult, error)
Run fetches a step definition, parses the step, and executes it. The step reference inputs and environment are expanded. The current environment is cloned into params in preparation for a recursive call to Run.
type NamedStepReference ¶
type NamedStepReference struct {
// contains filtered or unexported fields
}
NamedStepReference is a step that is loaded using a name and a reference
func NewNamedStepReference ¶
func NewNamedStepReference(name string, ref *proto.Step_Reference) *NamedStepReference
func (*NamedStepReference) Describe ¶ added in v0.2.0
func (sr *NamedStepReference) Describe() string
func (*NamedStepReference) ToProtoStep ¶
func (sr *NamedStepReference) ToProtoStep(params *Params) *proto.Step
type Params ¶
Params are the input and environment parameters for an execution.
func (*Params) NewInputsWithDefault ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(globalCtx *GlobalContext, stepCache Cache) *Parser
func (*Parser) Parse ¶
func (p *Parser) Parse(specDef *proto.SpecDefinition, params *Params, loadedFrom StepReference) (Step, error)
type SequenceOfSteps ¶
type SequenceOfSteps struct {
// contains filtered or unexported fields
}
SequenceOfSteps is a step that executes many steps.
func NewSequenceOfSteps ¶
func NewSequenceOfSteps(loadedFrom StepReference, params *Params, specDef *proto.SpecDefinition, steps ...Step) *SequenceOfSteps
func (*SequenceOfSteps) Describe ¶
func (s *SequenceOfSteps) Describe() string
func (*SequenceOfSteps) Run ¶
func (s *SequenceOfSteps) Run(ctx ctx.Context, stepsCtx *StepsContext) (*proto.StepResult, error)
type Step ¶
type Step interface { Describer Run(ctx ctx.Context, stepsCtx *StepsContext) (*proto.StepResult, error) }
type StepFile ¶
type StepFile struct {
// contains filtered or unexported fields
}
func NewStepFile ¶
func NewStepFileInDir ¶
func NewStepFileInTmp ¶
func (*StepFile) ReadEnvironment ¶
func (s *StepFile) ReadEnvironment() (*Environment, error)
func (*StepFile) ReadKeyValueLines ¶
func (*StepFile) ReadStepResult ¶
func (s *StepFile) ReadStepResult() (*proto.StepResult, error)
func (*StepFile) ReadValues ¶
type StepFileLine ¶ added in v0.2.0
type StepParser ¶
type StepParser interface {
Parse(specDef *proto.SpecDefinition, params *Params, loadedFrom StepReference) (Step, error)
}
type StepReference ¶
StepReference knows how the step was loaded
type StepResource ¶
type StepResource interface { Describer Interpolate(*expression.InterpolationContext) (StepResource, error) ToProtoStepRef() *proto.Step_Reference }
StepResource knows how to load a Step
type StepResultBuilder ¶
type StepResultBuilder struct {
// contains filtered or unexported fields
}
func NewStepResultBuilder ¶
func NewStepResultBuilder(loadedFrom StepReference, params *Params, specDef *proto.SpecDefinition) *StepResultBuilder
func (*StepResultBuilder) Build ¶
func (bldr *StepResultBuilder) Build() *proto.StepResult
func (*StepResultBuilder) BuildFailure ¶
func (bldr *StepResultBuilder) BuildFailure() *proto.StepResult
func (*StepResultBuilder) ObserveEnv ¶
func (bldr *StepResultBuilder) ObserveEnv(env *Environment, err error) error
func (*StepResultBuilder) ObserveExecutedCmd ¶
func (bldr *StepResultBuilder) ObserveExecutedCmd(execResult *ExecResult, err error) error
func (*StepResultBuilder) ObserveExports ¶
func (bldr *StepResultBuilder) ObserveExports(exports *Environment, err error) (*Environment, error)
func (*StepResultBuilder) ObserveOutputs ¶
func (*StepResultBuilder) ObserveStepResult ¶
func (bldr *StepResultBuilder) ObserveStepResult(stepResult *proto.StepResult, err error) (*proto.StepResult, error)
func (*StepResultBuilder) WithEnv ¶
func (bldr *StepResultBuilder) WithEnv(env map[string]string) *StepResultBuilder
func (*StepResultBuilder) WithExecResult ¶
func (bldr *StepResultBuilder) WithExecResult(executedCmd *ExecResult) *StepResultBuilder
func (*StepResultBuilder) WithExports ¶
func (bldr *StepResultBuilder) WithExports(exports *Environment) *StepResultBuilder
func (*StepResultBuilder) WithOutputs ¶
func (bldr *StepResultBuilder) WithOutputs(outputs map[string]*structpb.Value) *StepResultBuilder
func (*StepResultBuilder) WithSubStepResult ¶
func (bldr *StepResultBuilder) WithSubStepResult(result *proto.StepResult) *StepResultBuilder
type StepsContext ¶
type StepsContext struct { *GlobalContext StepDir string // The path to the YAML definition directory so steps can find their files and sub-steps with relative references know where to start. OutputFile *StepFile // The path to the output file. ExportFile *StepFile // The path to the export file. Env *Environment // Expanded environment values of the executing step. Inputs map[string]*structpb.Value // Expanded input values of the executing step. Steps map[string]*proto.StepResult // Results of previously executed steps. }
func NewStepsContext ¶
func NewStepsContext(globalCtx *GlobalContext, dir string, inputs map[string]*structpb.Value, env *Environment) (*StepsContext, error)
func (*StepsContext) Cleanup ¶
func (s *StepsContext) Cleanup()
func (*StepsContext) ExpandAndApplyEnv ¶
func (s *StepsContext) ExpandAndApplyEnv(env map[string]string) (*Environment, error)
func (*StepsContext) GetEnvList ¶
func (s *StepsContext) GetEnvList() []string
func (*StepsContext) GetEnvs ¶
func (s *StepsContext) GetEnvs() map[string]string
func (*StepsContext) RecordResult ¶
func (s *StepsContext) RecordResult(stepResult *proto.StepResult)
RecordResult captures the result of a step even if it failed
func (*StepsContext) StepResults ¶
func (s *StepsContext) StepResults() []*proto.StepResult
func (*StepsContext) View ¶
func (s *StepsContext) View() *expression.InterpolationContext
Source Files
¶
- cache.go
- describer.go
- environment.go
- error_ctx.go
- exec_result.go
- executable_step.go
- file_system_step_resource.go
- git_step_resource.go
- global_context.go
- lazily_loaded_step.go
- named_step_reference.go
- runner.go
- sequence_of_steps.go
- step.go
- step_file.go
- step_parser.go
- step_reference.go
- step_resource.go
- step_result_builder.go
- steps_context.go