Documentation ¶
Overview ¶
Package wharfyml contains code for parsing and validating .wharf-ci.yml files.
Index ¶
- Variables
- func Parse(reader io.Reader, args Args) (def Definition, errSlice Errors)
- func ParseFile(path string, args Args) (Definition, Errors)
- type Args
- type Definition
- type Env
- type EnvRef
- type Errors
- type Input
- type InputChoice
- type InputNumber
- type InputPassword
- type InputString
- type Inputs
- type Pos
- type PosError
- type Stage
- type Step
- type StepContainer
- type StepDocker
- type StepHelm
- type StepHelmPackage
- type StepKubectl
- type StepNuGetPackage
- type StepType
- type StepTypeMeta
- type VarFile
- type VarSubNode
Constants ¶
This section is empty.
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 ( ErrStepTypeUnknown = errors.New("unknown step type") ErrMissingBuiltinVar = errors.New("missing built-in var") )
Errors related to parsing step types.
var ( ErrInvalidFieldType = errors.New("invalid field type") ErrKeyCollision = errors.New("map key appears more than once") ErrKeyEmpty = errors.New("map key must not be empty") ErrKeyNotString = errors.New("map key must be string") ErrMissingDoc = errors.New("empty document") ErrTooManyDocs = errors.New("only 1 document is allowed") )
Generic errors related to parsing.
var (
ErrMissingRequired = errors.New("missing required field")
)
Errors related to parsing map of nodes.
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 (
ErrUnsupportedVarSubType = errors.New("unsupported variable substitution value")
)
Errors specific to performing variable substitution on nodes.
var (
ErrUseOfUndefinedEnv = errors.New("use of undefined environment")
)
Errors specific to parsing definitions.
Functions ¶
Types ¶
type Args ¶
type Args struct { Env string VarSource varsub.Source SkipStageFiltering bool Inputs map[string]any }
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 (*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 Env ¶
type Env struct { Source Pos Name string Vars map[string]VarSubNode }
Env is an environments definition. Used in the root of the definition.
type Errors ¶
type Errors []error
Errors is a slice of errors.
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
type Input ¶
type Input interface { InputTypeName() string InputVarName() string DefaultValue() any ParseValue(value any) (any, error) Pos() 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() 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() 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() 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() 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 Pos ¶
Pos represents a position. Used to declare where an object was defined in the .wharf-ci.yml file. The first line and column starts at 1. The zero value is used to represent an undefined position.
type PosError ¶
PosError is an error type that holds metadata about where the error occurred (line and column).
type Stage ¶
Stage holds the name, environment filter, and list of steps for this Wharf build stage.
type StepContainer ¶
type StepContainer struct { // Step type metadata Meta StepTypeMeta // Required fields Image string Cmds []string // Optional fields OS string Shell string SecretName string ServiceAccount string CertificatesMountPath string }
StepContainer represents a step type for running commands inside a Docker container.
func (StepContainer) StepTypeName ¶
func (StepContainer) StepTypeName() string
StepTypeName returns the name of this step type.
type StepDocker ¶
type StepDocker struct { // Step type metadata Meta StepTypeMeta // Required fields File string Tag string // Optional fields Destination string Name string Group string Context string Secret string Registry string AppendCert bool Push bool Args []string SecretName string SecretArgs []string }
StepDocker represents a step type for building and pushing Docker images.
func (StepDocker) StepTypeName ¶
func (StepDocker) StepTypeName() string
StepTypeName returns the name of this step type.
type StepHelm ¶
type StepHelm struct { // Step type metadata Meta StepTypeMeta // Required fields Chart string Name string Namespace string // Optional fields Repo string Set map[string]string Files []string ChartVersion string HelmVersion string Cluster string }
StepHelm represents a step type for installing a Helm chart into a Kubernetes cluster.
func (StepHelm) StepTypeName ¶
StepTypeName returns the name of this step type.
type StepHelmPackage ¶
type StepHelmPackage struct { // Step type metadata Meta StepTypeMeta // Optional fields Version string ChartPath string Destination string }
StepHelmPackage represents a step type for building and uploading a Helm chart to a chart registry.
func (StepHelmPackage) StepTypeName ¶
func (StepHelmPackage) StepTypeName() string
StepTypeName returns the name of this step type.
type StepKubectl ¶
type StepKubectl struct { // Step type metadata Meta StepTypeMeta // Required fields File string Files []string // Optional fields Namespace string Action string Force bool Cluster string }
StepKubectl represents a step type for running kubectl commands on some Kubernetes manifest files.
func (StepKubectl) StepTypeName ¶
func (StepKubectl) StepTypeName() string
StepTypeName returns the name of this step type.
type StepNuGetPackage ¶
type StepNuGetPackage struct { // Step type metadata Meta StepTypeMeta // Required fields Version string ProjectPath string Repo string // Optional fields SkipDuplicate bool CertificatesMountPath string }
StepNuGetPackage represents a step type used for building .NET NuGet packages.
func (StepNuGetPackage) StepTypeName ¶
func (StepNuGetPackage) StepTypeName() string
StepTypeName returns the name of this step type.
type StepType ¶
type StepType interface {
StepTypeName() string
}
StepType is an interface that is implemented by all step types.
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.
type VarSubNode ¶
type VarSubNode struct {
Node *yaml.Node
}
VarSubNode is a custom varsub variable type that envelops a YAML node. Mostly only used internally inside the wharfyml package.
func (VarSubNode) String ¶
func (v VarSubNode) String() string
String implements the fmt.Stringer interface.
Source Files ¶
- builtins.go
- builtins_linux.go
- definition.go
- doc.go
- environment.go
- error.go
- inputs.go
- inputtypes.go
- magicstrings.go
- nodemapparser.go
- parse.go
- position.go
- stage.go
- step.go
- steptype.go
- steptype_container.go
- steptype_docker.go
- steptype_helm.go
- steptype_helmpackage.go
- steptype_kubectl.go
- steptype_nugetpackage.go
- varsub.go
- visitor.go
- wharfyml.go