Documentation
¶
Overview ¶
Package pipeline implements the pieces necessary for the agent to work with pipelines (typically in YAML or JSON form).
The pipeline object model (Pipeline, Steps, Plugin, etc) have these caveats:
- It is incomplete: there may be fields accepted by the API that are not listed. Do not treat Pipeline, CommandStep, etc, as comprehensive reference guides for how to write a pipeline.
- It normalises: unmarshaling accepts a variety of step forms, but marshaling back out produces more normalised output. An unmarshal/marshal round-trip may produce different output.
- It is non-canonical: using the object model does not guarantee that a pipeline will be accepted by the pipeline upload API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandStep ¶
type CommandStep struct {
Command string `yaml:"command"`
Plugins Plugins `yaml:"plugins,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Signature *Signature `yaml:"signature,omitempty"`
Matrix *Matrix `yaml:"matrix,omitempty"`
// RemainingFields stores any other top-level mapping items so they at least
// survive an unmarshal-marshal round-trip.
RemainingFields map[string]any `yaml:",inline"`
}
CommandStep models a command step.
Standard caveats apply - see the package comment.
func (*CommandStep) InterpolateMatrixPermutation ¶
func (c *CommandStep) InterpolateMatrixPermutation(mp MatrixPermutation) error
InterpolateMatrixPermutation validates and then interpolates the choice of matrix values into the step. This should only be used in order to validate a job that's about to be run, and not used before pipeline upload.
func (*CommandStep) MarshalJSON ¶
func (c *CommandStep) MarshalJSON() ([]byte, error)
MarshalJSON marshals the step to JSON. Special handling is needed because yaml.v3 has "inline" but encoding/json has no concept of it.
func (*CommandStep) UnmarshalJSON ¶
func (c *CommandStep) UnmarshalJSON(b []byte) error
UnmarshalJSON is used when unmarshalling an individual step directly, e.g. from the Agent API Accept Job.
func (*CommandStep) UnmarshalOrdered ¶
func (c *CommandStep) UnmarshalOrdered(src any) error
UnmarshalOrdered unmarshals a command step from an ordered map.
type GroupStep ¶
type GroupStep struct {
// Group is typically a key with no value. Since it must always exist in
// a group step, here it is.
Group *string `yaml:"group"`
Steps Steps `yaml:"steps"`
// RemainingFields stores any other top-level mapping items so they at least
// survive an unmarshal-marshal round-trip.
RemainingFields map[string]any `yaml:",inline"`
}
GroupStep models a group step.
Standard caveats apply - see the package comment.
func (*GroupStep) MarshalJSON ¶
MarshalJSON marshals the step to JSON. Special handling is needed because yaml.v3 has "inline" but encoding/json has no concept of it.
func (*GroupStep) UnmarshalOrdered ¶
UnmarshalOrdered unmarshals a group step from an ordered map.
type InputStep ¶
InputStep models a block or input step.
Standard caveats apply - see the package comment.
func (*InputStep) MarshalJSON ¶
type Matrix ¶
type Matrix struct {
Setup MatrixSetup `yaml:"setup"`
Adjustments MatrixAdjustments `yaml:"adjustments,omitempty"`
RemainingFields map[string]any `yaml:",inline"`
}
Matrix models the matrix specification for command steps.
func (*Matrix) MarshalJSON ¶
MarshalJSON is needed to use inlineFriendlyMarshalJSON, and reduces the representation to a single list if the matrix is simple.
func (*Matrix) MarshalYAML ¶
MarshalYAML is needed to reduce the representation to a single slice if the matrix is simple.
func (*Matrix) UnmarshalOrdered ¶
UnmarshalOrdererd unmarshals from either []any or *ordered.MapSA.
type MatrixAdjustment ¶
type MatrixAdjustment struct {
With MatrixAdjustmentWith `yaml:"with"`
Skip any `yaml:"skip,omitempty"`
RemainingFields map[string]any `yaml:",inline"` // NB: soft_fail is in the remaining fields
}
MatrixAdjustment models an adjustment - a combination of (possibly new) matrix values, and skip/soft fail configuration.
func (*MatrixAdjustment) MarshalJSON ¶
func (ma *MatrixAdjustment) MarshalJSON() ([]byte, error)
MarshalJSON is needed to use inlineFriendlyMarshalJSON.
func (*MatrixAdjustment) ShouldSkip ¶
func (ma *MatrixAdjustment) ShouldSkip() bool
type MatrixAdjustmentWith ¶
MatrixAdjustmentWith is either a map of dimension key -> dimension value, or a single value (for single anonymous dimension matrices).
func (MatrixAdjustmentWith) MarshalJSON ¶
func (maw MatrixAdjustmentWith) MarshalJSON() ([]byte, error)
MarshalJSON returns either a single scalar or an object.
func (MatrixAdjustmentWith) MarshalYAML ¶
func (maw MatrixAdjustmentWith) MarshalYAML() (any, error)
MarshalYAML returns either a single scalar or a map.
func (*MatrixAdjustmentWith) UnmarshalOrdered ¶
func (maw *MatrixAdjustmentWith) UnmarshalOrdered(o any) error
UnmarshalOrdered unmarshals from either a scalar value (string, bool, or int) or *ordered.MapSA.
type MatrixAdjustments ¶
type MatrixAdjustments []*MatrixAdjustment
MatrixAdjustments is a set of adjustments.
type MatrixPermutation ¶
MatrixPermutation represents a possible permutation of a matrix.
type MatrixSetup ¶
MatrixSetup is the main setup of a matrix - one or more dimensions. The cross product of the dimensions in the setup produces the base combinations of matrix values.
func (MatrixSetup) MarshalJSON ¶
func (ms MatrixSetup) MarshalJSON() ([]byte, error)
MarshalJSON returns either a list (if the setup is a single anonymous dimension) or an object (if it contains one or more (named) dimensions).
func (MatrixSetup) MarshalYAML ¶
func (ms MatrixSetup) MarshalYAML() (any, error)
MarshalYAML returns either a Scalars (if the setup is a single anonymous dimension) or a map (if it contains one or more (named) dimensions).
func (*MatrixSetup) UnmarshalOrdered ¶
func (ms *MatrixSetup) UnmarshalOrdered(o any) error
UnmarshalOrdered unmarshals from either []any or *ordered.MapSA.
type Pipeline ¶
type Pipeline struct {
Steps Steps `yaml:"steps"`
Env *ordered.MapSS `yaml:"env,omitempty"`
// RemainingFields stores any other top-level mapping items so they at least
// survive an unmarshal-marshal round-trip.
RemainingFields map[string]any `yaml:",inline"`
}
Pipeline models a pipeline.
Standard caveats apply - see the package comment.
func (*Pipeline) Interpolate ¶
Interpolate interpolates variables defined in both env and p.Env into the pipeline. More specifically, it does these things:
- Interpolate pipeline.Env and copy the results into env to apply later.
- Interpolate any string value in the rest of the pipeline.
func (*Pipeline) MarshalJSON ¶
MarshalJSON marshals a pipeline to JSON. Special handling is needed because yaml.v3 has "inline" but encoding/json has no concept of it.
func (*Pipeline) UnmarshalOrdered ¶
UnmarshalOrdered unmarshals the pipeline from either []any (a legacy sequence of steps) or *ordered.MapSA (a modern pipeline configuration).
type Plugin ¶
Plugin models plugin configuration.
Standard caveats apply - see the package comment.
func (*Plugin) FullSource ¶
FullSource attempts to canonicalise Source. If it fails, it returns Source unaltered. Otherwise, it resolves sources in a manner described at https://buildkite.com/docs/plugins/using#plugin-sources.
func (*Plugin) MarshalJSON ¶
MarshalJSON returns the plugin in "one-key object" form, or "single string" form (no config, only plugin source). Plugin sources are marshalled into "full" form.
func (*Plugin) MarshalYAML ¶
MarshalYAML returns the plugin in either "one-item map" form, or "scalar" form (no config, only plugin source). Plugin sources are marshalled into "full" form.
type Plugins ¶
type Plugins []*Plugin
Plugins is a sequence of plugins. It is useful for unmarshaling.
func (*Plugins) UnmarshalJSON ¶
UnmarshalJSON is used mainly to normalise the BUILDKITE_PLUGINS env var.
func (*Plugins) UnmarshalOrdered ¶
UnmarshalOrdered unmarshals Plugins from either
- []any - originally a sequence of "one-item mappings" (normal form), or
- *ordered.MapSA - a mapping (where order is important...non-normal form).
"plugins" is supposed to be a sequence of one-item maps, since order matters. But some people (even us) write plugins into one big mapping and rely on order preservation.
type Signature ¶
type Signature struct {
Algorithm string `json:"algorithm" yaml:"algorithm"`
SignedFields []string `json:"signed_fields" yaml:"signed_fields"`
Value string `json:"value" yaml:"value"`
}
Signature models a signature (on a step, etc).
type Step ¶
type Step interface {
// contains filtered or unexported methods
}
Step models a step in the pipeline. It will be a pointer to one of: - CommandStep - WaitStep - InputStep - TriggerStep - GroupStep
func NewScalarStep ¶
type Steps ¶
type Steps []Step
Steps contains multiple steps. It is useful for unmarshaling step sequences, since it has custom logic for determining the correct step type.
func (*Steps) UnmarshalOrdered ¶
UnmarshalOrdered unmarshals a slice ([]any) into a slice of steps.
type TriggerStep ¶
TriggerStep models a trigger step.
Standard caveats apply - see the package comment.
func (TriggerStep) MarshalJSON ¶
func (t TriggerStep) MarshalJSON() ([]byte, error)
MarshalJSON marshals the contents of the step.
type UnknownStep ¶
type UnknownStep struct {
Contents any
}
UnknownStep models any step we don't know how to represent in this version. When future step types are added, they should be parsed with more specific types. UnknownStep is present to allow older parsers to preserve newer pipelines.
func (UnknownStep) MarshalJSON ¶
func (u UnknownStep) MarshalJSON() ([]byte, error)
MarshalJSON marshals the contents of the step.
func (UnknownStep) MarshalYAML ¶
func (u UnknownStep) MarshalYAML() (any, error)
MarshalYAML returns the contents of the step.
func (*UnknownStep) UnmarshalOrdered ¶
func (u *UnknownStep) UnmarshalOrdered(src any) error
UnmarshalOrdered unmarshals an unknown step.
type WaitStep ¶
WaitStep models a wait step.
Standard caveats apply - see the package comment.
func (*WaitStep) MarshalJSON ¶
MarshalJSON marshals a wait step as "wait" if w is empty, or as the step's scalar if it's set. If scalar is empty, it marshals as the remaining fields
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package jwkutil provides utilities for working with JSON Web Keys and JSON Web Key Sets as defined in [RFC 7517].
|
Package jwkutil provides utilities for working with JSON Web Keys and JSON Web Key Sets as defined in [RFC 7517]. |
|
Package ordered implements an ordered map type, suitable for use when decoding yaml documents where mappings must be preserved, such as in certain parts of the buildkite pipeline yaml.
|
Package ordered implements an ordered map type, suitable for use when decoding yaml documents where mappings must be preserved, such as in certain parts of the buildkite pipeline yaml. |
|
Package signature implements signing and verification of pipeline steps.
|
Package signature implements signing and verification of pipeline steps. |