Documentation ¶
Index ¶
- func GenerateCombinations(kvs KeyValues) []set.Set[string]
- func GivingUp(attempts *multierror.Error) error
- func UnmarshalJSONToNamedMap[T any](m map[string]T, newFn func(name string) T, data []byte) error
- func UnmarshalJSONTryAsString[T any](data []byte, fromFn fromString[T]) (T, error)
- type CallInfoOption
- type CallInfoOptions
- type CheckSumAlgorithm
- type DeferSpec
- type DiscardResponseWriter
- type Do
- type Duration
- type Dynamic
- type Features
- type FileCondition
- type FileGlobs
- type Fn
- type FnCondition
- type FnContext
- type FnDef
- type FnDefs
- type FnFile
- type Fns
- type Gen
- type GivenUp
- type IfSpec
- type Include
- type Includes
- type Input
- type Inputs
- type KeyValues
- type Matrix
- type Parallel
- type Param
- type Params
- type PullPolicy
- type ResponseWriter
- type ReturnSpec
- type RunOption
- type SerialGroups
- type Sh
- type Src
- type StdResponseWriter
- type Step
- func UnmarshalDeferStep(data []byte) (Step, error)
- func UnmarshalDoStep(data []byte) (Step, error)
- func UnmarshalDynamicStep(data []byte) (Step, error)
- func UnmarshalFnStep(data []byte) (Step, error)
- func UnmarshalFromStepName(stepName StepName, data []byte) (Step, error)
- func UnmarshalKeyedStep(data []byte) (Step, error)
- func UnmarshalMatrixStep(data []byte) (Step, error)
- func UnmarshalParallelStep(data []byte) (Step, error)
- func UnmarshalReturnStep(data []byte) (Step, error)
- func UnmarshalShStep(data []byte) (Step, error)
- func UnmarshalStep(data []byte) (Step, error)
- type StepHandler
- type StepHandlerFunc
- type StepMeta
- type StepName
- type StepOutcomeCondition
- type StepUnmarshaller
- type StepVisitor
- type Steps
- type ThreadSafeMultiError
- type Variable
- type Vars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCombinations ¶
fruit: [apple, pear, orange] animal: [cat, dog]
should generate
apple, cat apple, dog pear, cat pear, dog orange, cat orange, dog
func UnmarshalJSONToNamedMap ¶
Types ¶
type CallInfoOption ¶
type CallInfoOption func(options *CallInfoOptions)
type CallInfoOptions ¶
type CheckSumAlgorithm ¶
type CheckSumAlgorithm string
const ( SHA1 CheckSumAlgorithm = "SHA1" SHA256 CheckSumAlgorithm = "SHA256" SHA512 CheckSumAlgorithm = "SHA512" )
type DeferSpec ¶
func UnmarshalDefer ¶
func (DeferSpec) Handle ¶
func (spec DeferSpec) Handle(w ResponseWriter, _ *FnContext)
func (*DeferSpec) UnmarshalJSON ¶
type DiscardResponseWriter ¶
type DiscardResponseWriter struct {
ResponseWriter
}
func (DiscardResponseWriter) Defer ¶
func (w DiscardResponseWriter) Defer(StepHandler)
func (DiscardResponseWriter) ErrOutWriter ¶
func (w DiscardResponseWriter) ErrOutWriter() io.Writer
func (DiscardResponseWriter) Error ¶
func (w DiscardResponseWriter) Error(_ error)
func (DiscardResponseWriter) ErrorOrNil ¶
func (w DiscardResponseWriter) ErrorOrNil() error
func (DiscardResponseWriter) OutWriter ¶
func (w DiscardResponseWriter) OutWriter() io.Writer
type Do ¶
func UnmarshalDo ¶
func (Do) Handle ¶
func (do Do) Handle(w ResponseWriter, c *FnContext)
func (*Do) UnmarshalJSON ¶
type Duration ¶
Duration uses time.ParseDuration (see https://pkg.go.dev/time#ParseDuration) for unmarshalling.
func (Duration) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Dynamic ¶
func UnmarshalDynamic ¶
func (Dynamic) Handle ¶
func (dynamic Dynamic) Handle(w ResponseWriter, c *FnContext)
func (*Dynamic) UnmarshalJSON ¶
type FileCondition ¶
type FileCondition struct { IfSpec // Sources matched files have their contents hashed. // If the content hashes change between runs, this fn will be marked as "out-of-date". Sources FileGlobs `json:"from,omitempty"` // Generates matched files are checked to exist. // If these files do not exist, this fn will be marked as "out-of-date". // When providing a glob, only 1 match is required to keep this fn "up-to-date". Generates FileGlobs `json:"makes,omitempty"` }
func (*FileCondition) Exec ¶
func (f *FileCondition) Exec(w ResponseWriter, c *FnContext)
type Fn ¶
func UnmarshalFn ¶
func (Fn) Handle ¶
func (fn Fn) Handle(w ResponseWriter, c *FnContext)
func (*Fn) UnmarshalJSON ¶
type FnCondition ¶
type FnContext ¶
type FnContext struct {
// contains filtered or unexported fields
}
func NewCallInfo ¶
func NewCallInfo(ctx context.Context, options ...CallInfoOption) *FnContext
type FnDef ¶
type FnDef struct { Name string `json:"-"` Run RunOption `json:"run,omitempty"` // Inputs are parameters for this FnDef, used when called by another FnDef. Inputs Inputs `json:"inputs,omitempty"` // Locals are values only available inside this fn via contexts.Locals Locals Vars `json:"locals,omitempty"` // Outputs are values that are available via contexts.Fn Outputs Vars `json:"outputs,omitempty"` // Short is the short description shown in the 'help' output. Short string `json:"short,omitempty"` // Long is the long message shown in the 'help <this-fn>' output. Long string `json:"long,omitempty"` // Example is examples of how to use the fn. Example string `json:"example,omitempty"` // Do are steps that run serially Do Do `json:"do,omitempty"` // Dir is the directory in which steps will be executed from (default: fnfile.yml directory) // This dir is available as a context to sub steps, and thus, those steps can use it to make decisions, // if specifying their own directory as relative, it will be relative to this. Dir string `json:"dir,omitempty"` // Env is a map of environment variables that are available to all steps in the fn. // You can also set environment variables for the entire fnfile or an individual step. // // When more than one environment variable is defined with the same name (in different locations), // FnDef uses the most specific environment variable. // // For example, an environment variable defined in a step will override fn and global (fnfile) variables // with the same name, while the step executes. // An environment variable defined for a fn will override a global (fnfile) variable // with the same name, while the fn executes. Env Vars `json:"env,omitempty"` // SerialGroups is an array of arbitrary label-like strings. Executions of this fn // and other fns referencing the same tags will be serialized. SerialGroups SerialGroups `json:"serialGroups,omitempty"` // Matrix is a step/fn hook to define a matrix of step/fn configurations. // // A matrix allows you to create multiple steps/fns by performing variable substitution // in a single step/fn definition. // // When defined on a fn, it dynamically creates several fns, suffixing the fn name with the matrix values. // // Each individual fn can be called. The original fn becomes a "virtual fn" that "needs" the matrix of fns. // Allowing you to call all matrix fns from the single "parent" virtual fn. // // For example, you can use a matrix to create fns for more than one supported version of a programming language, // variable values, or tool, etc. A matrix reuses the step/fn's configuration // and creates a step/fn for each matrix you configure. // // Example // // fns: // echo: // matrix: // - env: ["dev", "staging", "prod"] // steps: // - run: "echo {{.Matrix.env}}" // // fns defined are: // echo // echo:dev // echo:staging // echo:prod Matrix Matrix `json:"matrix,omitempty"` // Timeout is the bounding time limit (duration) for the fn before signaling for termination via SIGINT. Timeout Duration `json:"Timeout,omitempty"` }
type FnFile ¶
type FnFile struct { // Version is the version of the Fn schema // It is the first thing that is parsed by Task in order to inform how the rest of the file should be parsed. Version string `json:"version,omitempty"` // Features are flags for fn // It enables users to change the behavior of fn by enabling/disabling features of the engine Features Features `json:"features,omitempty"` // Globals are variables that are available from any fn Globals Vars `json:"globals,omitempty"` // Includes allows other Fnfiles to be included in this one. Each other include is becomes "namespaced". // More on namespacing later... Includes Includes `json:"includes,omitempty"` // Def is a set of function definitions Fns FnDefs `json:"fns,omitempty"` }
type Matrix ¶
type Matrix struct { StepMeta KVs KeyValues `json:"kvs,omitempty"` // Include enables different matrix "shapes" aside from the expected NxM table produced from KVs. // Each key:value pair will be added to each of the matrix combinations, but only if the keys are unique (not part of the original matrix). // For any unoriginal keys, new matrix combinations will be created. Include KeyValues `json:"include,omitempty"` }
Matrix is a step/fn hook to define a matrix of step/fn configurations.
A matrix allows you to create multiple steps/tasks by performing variable substitution in a single step/fn definition.
When defined on a StepMeta, it dynamically creates several steps. Each step is inlined, and are run serially. StepMeta ordering is based on the order of each provided matrix. Example
task: echo: matrix: - env: ["dev", "staging", "prod"] - ham: ["bacon", "eggs"] steps: - run: "echo {{.Matrix.env}} {{.Matrix.ham}}"
Steps created defined are:
- echo "dev bacon"
- echo "dev eggs"
- echo "staging bacon"
- echo "staging eggs"
- echo "prod bacon"
- echo "prod eggs"
func UnmarshalMatrix ¶
func (Matrix) Handle ¶
func (m Matrix) Handle(w ResponseWriter, c *FnContext)
func (*Matrix) UnmarshalJSON ¶
type Parallel ¶
type Parallel struct { StepMeta Steps Steps `json:"steps"` FailFast bool `json:"failFast,omitempty"` Limit int `json:"limit,omitempty"` }
func UnmarshalParallel ¶
func (Parallel) Handle ¶
func (p Parallel) Handle(w ResponseWriter, c *FnContext)
func (*Parallel) UnmarshalJSON ¶
type Params ¶
func (*Params) UnmarshalJSON ¶
type PullPolicy ¶
type PullPolicy string
const ( Always PullPolicy = "Always" IfNotPresent PullPolicy = "IfNotPresent" Never PullPolicy = "Never" )
type ResponseWriter ¶
type ResponseWriter interface { Defer(StepHandler) OutWriter() io.Writer ErrOutWriter() io.Writer Error(error) ErrorOrNil() error }
func WithNewDeferrals ¶
func WithNewDeferrals(parent ResponseWriter) (ResponseWriter, *[]StepHandler)
type ReturnSpec ¶
type ReturnSpec struct {
StepMeta
}
ReturnSpec is a step hook which allows a fn to return early (skipping subsequent steps) just like a `return` statement in Go.
func UnmarshalReturn ¶
func UnmarshalReturn(data []byte) (ReturnSpec, error)
func (ReturnSpec) Handle ¶
func (r ReturnSpec) Handle(_ ResponseWriter, c *FnContext)
func (*ReturnSpec) UnmarshalJSON ¶
func (r *ReturnSpec) UnmarshalJSON(data []byte) (err error)
type SerialGroups ¶
type SerialGroups []string
func (*SerialGroups) UnmarshalJSON ¶
func (t *SerialGroups) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Sh ¶
type Sh struct { StepMeta // Run defines a shell command. Run string `json:"run,omitempty"` // Dir is the desired working directory in which this command should execute in. Dir string `json:"dir,omitempty"` }
func UnmarshalSh ¶
UnmarshalSh attempts to unmarshal to a string to generate a simple Sh step (only the run field) otherwise attempts a full unmarshal to Sh step returns an error if neither is possible
func (Sh) Handle ¶
func (sh Sh) Handle(w ResponseWriter, c *FnContext)
func (*Sh) UnmarshalJSON ¶
type StdResponseWriter ¶
type StdResponseWriter struct {
// contains filtered or unexported fields
}
func NewStdResponseWriter ¶
func NewStdResponseWriter(out, errOut io.Writer) *StdResponseWriter
func (*StdResponseWriter) Defer ¶
func (w *StdResponseWriter) Defer(h StepHandler)
func (*StdResponseWriter) ErrOutWriter ¶
func (w *StdResponseWriter) ErrOutWriter() io.Writer
func (*StdResponseWriter) Error ¶
func (w *StdResponseWriter) Error(err error)
func (*StdResponseWriter) ErrorOrNil ¶
func (w *StdResponseWriter) ErrorOrNil() error
func (*StdResponseWriter) OutWriter ¶
func (w *StdResponseWriter) OutWriter() io.Writer
type Step ¶
type Step interface {
Handle(w ResponseWriter, c *FnContext)
}
func UnmarshalDeferStep ¶
func UnmarshalDoStep ¶
func UnmarshalDynamicStep ¶
func UnmarshalFnStep ¶
func UnmarshalFromStepName ¶
func UnmarshalKeyedStep ¶
func UnmarshalMatrixStep ¶
func UnmarshalParallelStep ¶
func UnmarshalReturnStep ¶
func UnmarshalShStep ¶
func UnmarshalStep ¶
type StepHandler ¶
type StepHandler interface {
Handle(w ResponseWriter, c *FnContext)
}
type StepHandlerFunc ¶
type StepHandlerFunc func(w ResponseWriter, c *FnContext)
func (StepHandlerFunc) Handle ¶
func (f StepHandlerFunc) Handle(w ResponseWriter, c *FnContext)
type StepMeta ¶
type StepMeta struct { // Name is the user defined name of the step. Defaults to "anonymous" Name string `json:"-"` // Locals are variables available to this step and all child steps (like a closure) Locals Vars `json:"vars,omitempty"` // Timeout is the bounding time limit (duration) for before signaling for termination Timeout Duration `json:"timeout,omitempty"` }
type StepOutcomeCondition ¶
type StepOutcomeCondition struct {
IfSpec
}
type StepUnmarshaller ¶
type StepVisitor ¶
type ThreadSafeMultiError ¶
type ThreadSafeMultiError struct { *multierror.Error // contains filtered or unexported fields }
func (*ThreadSafeMultiError) Append ¶
func (m *ThreadSafeMultiError) Append(errs ...error)
type Variable ¶
type Variable struct { Name string `json:"-"` Static string `json:"static,omitempty"` Tpl string `json:"tpl,omitempty"` Sh Sh `json:"sh,omitempty"` }