Documentation ¶
Index ¶
- Variables
- type Cache
- type Describer
- type Environment
- type ExecResult
- type ExecutableStep
- type FileSystemStepResource
- type Files
- type GitStepResource
- type GlobalContext
- type LazilyLoadedStep
- type NamedStepReference
- type Params
- type Parser
- type SequenceOfSteps
- type Step
- type StepParser
- type StepReference
- type StepResource
- type StepResultBuilder
- func (bldr *StepResultBuilder) Build() *proto.StepResult
- func (bldr *StepResultBuilder) BuildFailure() *proto.StepResult
- func (bldr *StepResultBuilder) WithEnv(env map[string]string) *StepResultBuilder
- func (bldr *StepResultBuilder) WithExecResult(executedCmd *ExecResult) *StepResultBuilder
- func (bldr *StepResultBuilder) WithExports(exports map[string]string) *StepResultBuilder
- func (bldr *StepResultBuilder) WithMergedOutputs(outputs map[string]*structpb.Value) *StepResultBuilder
- func (bldr *StepResultBuilder) WithSubStepResult(result *proto.StepResult) *StepResultBuilder
- type StepsContext
Constants ¶
This section is empty.
Variables ¶
var StepDefinedInGitLabJob = NewNamedStepReference("", nil)
StepDefinedInGitLabJob is a step defined in a GitLab jobs using the run: syntax or STEPS: variable
Functions ¶
This section is empty.
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 is immutable. Environment variables are used in places such as the step export_file, step definitions with ENV, and OS environment. An environment can be added as "lexical scope", these values have higher precedence when looking up a variable.
func NewEmptyEnvironment ¶
func NewEmptyEnvironment() *Environment
func NewEnvironment ¶
func NewEnvironment(vars map[string]string) *Environment
func NewEnvironmentFromOS ¶
func NewEnvironmentFromOS(names ...string) (*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 (*Environment) AddLexicalScope ¶
func (e *Environment) AddLexicalScope(vars map[string]string) *Environment
func (*Environment) ValueOf ¶
func (e *Environment) ValueOf(key string) string
func (*Environment) Values ¶
func (e *Environment) Values() map[string]string
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, specDef *proto.SpecDefinition) (*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 Files ¶
type Files struct {
// contains filtered or unexported fields
}
func NewFiles ¶
func NewFiles( stepCtx *StepsContext, outputMethod proto.OutputMethod, specOutputs map[string]*proto.Spec_Content_Output, ) (*Files, error)
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 ExportFile string Env *Environment Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
func NewGlobalContext ¶
func NewGlobalContext(env *Environment) (*GlobalContext, error)
func (*GlobalContext) Cleanup ¶
func (g *GlobalContext) Cleanup()
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) *LazilyLoadedStep
func (*LazilyLoadedStep) Describe ¶
func (s *LazilyLoadedStep) Describe() string
func (*LazilyLoadedStep) Run ¶
func (s *LazilyLoadedStep) Run(ctx ctx.Context, parentStepsCtx *StepsContext, specDefinition *proto.SpecDefinition) (*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) 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, steps ...Step) *SequenceOfSteps
func (*SequenceOfSteps) Describe ¶
func (s *SequenceOfSteps) Describe() string
func (*SequenceOfSteps) Run ¶
func (s *SequenceOfSteps) Run(ctx ctx.Context, stepsCtx *StepsContext, specDefinition *proto.SpecDefinition) (*proto.StepResult, error)
type Step ¶
type Step interface { Describer Run(ctx ctx.Context, stepsCtx *StepsContext, specDefinition *proto.SpecDefinition) (*proto.StepResult, error) }
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) 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 map[string]string) *StepResultBuilder
func (*StepResultBuilder) WithMergedOutputs ¶
func (bldr *StepResultBuilder) WithMergedOutputs(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 string // The path to the output 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 map[string]string) *StepsContext
func (*StepsContext) ExpandAndApplyEnv ¶
func (s *StepsContext) ExpandAndApplyEnv(env map[string]string) error
func (*StepsContext) GetEnvList ¶
func (s *StepsContext) GetEnvList() []string
func (*StepsContext) GetEnvs ¶
func (s *StepsContext) GetEnvs() map[string]string
func (*StepsContext) View ¶
func (s *StepsContext) View() *expression.InterpolationContext
Source Files ¶
- cache.go
- describer.go
- environment.go
- exec_result.go
- executable_step.go
- file_system_step_resource.go
- files.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_parser.go
- step_reference.go
- step_resource.go
- step_result_builder.go
- steps_context.go