Documentation ¶
Overview ¶
Package wharfyml contains code for parsing and validating .wharf-ci.yml files.
Index ¶
- Constants
- Variables
- func ParseVarFiles(currentDir string) (varsub.Source, errutil.Slice)
- type Args
- type Definition
- type Env
- type EnvRef
- type Input
- type InputChoice
- type InputNumber
- type InputPassword
- type InputString
- type Inputs
- type Stage
- type StageRunsIf
- type Step
- type StepType
- type StepTypeFactory
- type StepTypeMeta
- type VarFile
Constants ¶
const ( // StageRunsIfSuccess runs the stage if all previous stages were successful. StageRunsIfSuccess = "success" // StageRunsIfFail runs the stage if one or more of the previous stages were // unsuccessful. StageRunsIfFail = "fail" // StageRunsIfAlways always runs the stage, regardless of the success state // of previous stages. StageRunsIfAlways = "always" )
Variables ¶
var ( ErrInputNameCollision = errors.New("input variable name is already used") ErrInputUnknownType = errors.New("unknown input type") ErrUseOfUndefinedInput = errors.New("use of undefined input variable") ErrInputChoiceUnknownValue = errors.New("default value is missing from values array") )
Errors related to parsing environments.
var ( ErrStepEmpty = errors.New("missing a step type") ErrStepMultipleStepTypes = errors.New("contains multiple step types") )
Errors related to parsing steps.
var (
ErrInvalidRunCondition = errors.New("invalid run condition")
)
Errors related to parsing the run conditions.
var (
ErrNoStepTypesRegistered = errors.New("no step types registered")
)
Errors related to parsing step types.
var (
ErrStageEmpty = errors.New("stage is missing steps")
)
Errors related to parsing stages.
var (
ErrStageEnvEmpty = errors.New("environment name cannot be empty")
)
Errors related to parsing environments.
var (
ErrUseOfUndefinedEnv = errors.New("use of undefined environment")
)
Errors specific to parsing definitions.
Functions ¶
func ParseVarFiles ¶
ParseVarFiles produces a varsub.Source of *yaml.Node values. The files it checks depends on your OS.
For GNU/Linux:
/etc/iver-wharf/wharf-cmd/wharf-vars.yml $XDG_CONFIG_HOME/iver-wharf/wharf-cmd/wharf-vars.yml (if $XDG_CONFIG_HOME is unset) $HOME/.config/iver-wharf/wharf-cmd/wharf-vars.yml
For Windows:
%APPDATA%\iver-wharf\wharf-cmd\wharf-vars.yml
For Darwin (Mac OS X):
$HOME/Library/Application Support/iver-wharf/wharf-cmd/wharf-vars.yml
In addition, this function also checks the current directory and parent directories above it, recursively, for a dotfile variant (.wharf-vars.yml):
./.wharf-vars.yml ../.wharf-vars.yml ../../.wharf-vars.yml ../../..(etc)/.wharf-vars.yml
Types ¶
type Args ¶
type Args struct { Env string VarSource varsub.Source SkipStageFiltering bool Inputs map[string]any StepTypeFactory StepTypeFactory }
Args specify arguments used when parsing the .wharf-ci.yml file, such as what environment to use for variable substitution.
type Definition ¶
type Definition struct { Inputs Inputs Envs map[string]Env Env *Env Stages []Stage VarSource varsub.Source }
Definition is the .wharf-ci.yml build definition structure.
func Parse ¶
Parse will parse the YAML content as a .wharf-ci.yml definition structure. Multiple errors may be returned, one for each validation or parsing error.
func ParseFile ¶
func ParseFile(path string, args Args) (Definition, errutil.Slice)
ParseFile will parse the file at the given path. Multiple errors may be returned, one for each validation or parsing error.
func (*Definition) ListAllSteps ¶
func (d *Definition) ListAllSteps() []Step
ListAllSteps aggregates steps from all stages into a single slice.
Makes Definition comply to the StepLister interface.
type Input ¶
type Input interface { InputTypeName() string InputVarName() string DefaultValue() any ParseValue(value any) (any, error) Pos() visit.Pos }
Input is an interface that is implemented by all input types.
type InputChoice ¶
InputChoice represents a choice of multiple string inputs.
func (InputChoice) DefaultValue ¶
func (i InputChoice) DefaultValue() any
DefaultValue returns the default value for this input variable.
func (InputChoice) InputTypeName ¶
func (InputChoice) InputTypeName() string
InputTypeName returns the name of this input type.
func (InputChoice) InputVarName ¶
func (i InputChoice) InputVarName() string
InputVarName returns the name of this input variable.
func (InputChoice) ParseValue ¶
func (i InputChoice) ParseValue(value any) (any, error)
ParseValue will try to parse the value and return the input-compatible value for this input variable type, or returns an error if the type isn't valid.
func (InputChoice) Pos ¶
func (i InputChoice) Pos() visit.Pos
Pos returns the position of where this variable was defined.
type InputNumber ¶
InputNumber represents a number (integer or float) input value.
func (InputNumber) DefaultValue ¶
func (i InputNumber) DefaultValue() any
DefaultValue returns the default value for this input variable.
func (InputNumber) InputTypeName ¶
func (InputNumber) InputTypeName() string
InputTypeName returns the name of this input type.
func (InputNumber) InputVarName ¶
func (i InputNumber) InputVarName() string
InputVarName returns the name of this input variable.
func (InputNumber) ParseValue ¶
func (i InputNumber) ParseValue(value any) (any, error)
ParseValue will try to parse the value and return the input-compatible value for this input variable type, or returns an error if the type isn't valid.
func (InputNumber) Pos ¶
func (i InputNumber) Pos() visit.Pos
Pos returns the position of where this variable was defined.
type InputPassword ¶
InputPassword represents a string (text) input value, but where the value should be concealed in user interfaces.
func (InputPassword) DefaultValue ¶
func (i InputPassword) DefaultValue() any
DefaultValue returns the default value for this input variable.
func (InputPassword) InputTypeName ¶
func (InputPassword) InputTypeName() string
InputTypeName returns the name of this input type.
func (InputPassword) InputVarName ¶
func (i InputPassword) InputVarName() string
InputVarName returns the name of this input variable.
func (InputPassword) ParseValue ¶
func (i InputPassword) ParseValue(value any) (any, error)
ParseValue will try to parse the value and return the input-compatible value for this input variable type, or returns an error if the type isn't valid.
func (InputPassword) Pos ¶
func (i InputPassword) Pos() visit.Pos
Pos returns the position of where this variable was defined.
type InputString ¶
InputString represents a string (text) input value.
func (InputString) DefaultValue ¶
func (i InputString) DefaultValue() any
DefaultValue returns the default value for this input variable.
func (InputString) InputTypeName ¶
func (InputString) InputTypeName() string
InputTypeName returns the name of this input type.
func (InputString) InputVarName ¶
func (i InputString) InputVarName() string
InputVarName returns the name of this input variable.
func (InputString) ParseValue ¶
func (i InputString) ParseValue(value any) (any, error)
ParseValue will try to parse the value and return the input-compatible value for this input variable type, or returns an error if the type isn't valid.
func (InputString) Pos ¶
func (i InputString) Pos() visit.Pos
Pos returns the position of where this variable was defined.
type Inputs ¶
Inputs is a map of Input field definitions, keyed on their names.
func (Inputs) DefaultsVarSource ¶
DefaultsVarSource returns a varsub.Source of the default values from this .wharf-ci.yml's input definitions.
type Stage ¶
type Stage struct { Pos visit.Pos Name string Envs []EnvRef EnvsPos visit.Pos Steps []Step RunsIf StageRunsIf Node visit.MapItem }
Stage holds the name, environment filter, and list of steps for this Wharf build stage.
func (Stage) ShouldSkip ¶ added in v0.9.0
ShouldSkip returns true if the stage should be skipped based on its run conditions.
type StageRunsIf ¶ added in v0.9.0
type StageRunsIf string
StageRunsIf is an enum of different run behaviors for a stage, dependent on previous stages.
type Step ¶
type Step struct { Pos visit.Pos Name string Type StepType Meta StepTypeMeta }
Step holds the step type and name of this Wharf build step.
type StepType ¶
type StepType interface {
StepTypeName() string
}
StepType is an interface that is implemented by all step types.
type StepTypeFactory ¶
type StepTypeFactory interface {
NewStepType(stepTypeName, stepName string, v visit.MapVisitor) (StepType, errutil.Slice)
}
StepTypeFactory is a factory type that can create step types from a step type name. This type is expected to be implemented and injected into wharfyml to provide it with the step type definitons.
type StepTypeMeta ¶
StepTypeMeta contains metadata about a step type.
type VarFile ¶
VarFile is a place and kind definition of a variable file.
func ListPossibleVarsFiles ¶
ListPossibleVarsFiles returns all paths where we look for wharf-vars.yml and .wharf-vars.yml files.
Returned paths include the filename.
The ordering of the returned filenames are in the order of which file should have priority over the other; with the file of highest priority that should override all the others, first.
func (VarFile) PrettyPath ¶
PrettyPath returns a formatted version of the path, based on if its relative, and using "~" as shorthand for the user's home directory.