Documentation ¶
Index ¶
- Variables
- func ExecuteSingleStepAction(ctx context.Context, cfg runtime.RuntimeConfig, action ExecutableAction) (string, error)
- func ExecuteStep(ctx context.Context, cfg runtime.RuntimeConfig, step ExecutableStep) (string, error)
- func LoadAction(ctx context.Context, cfg runtime.RuntimeConfig, commandFile string, ...) error
- func ProcessFileOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs) error
- func ProcessJsonPathOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs, ...) error
- func ProcessRegexOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs, ...) error
- func UnmarshalAction(unmarshal func(interface{}) error, builder BuildableAction) (map[string][]interface{}, error)
- type BuildableAction
- type Dashes
- type ExecutableAction
- type ExecutableStep
- type ExitError
- type Flag
- type Flags
- type HasCustomDashes
- type HasEnvironmentVars
- type HasErrorHandling
- type HasOrderedArguments
- type IgnoreErrorHandler
- type IgnoreErrorWithOutput
- type Output
- type OutputFile
- type OutputJsonPath
- type OutputRegex
- type StepWithOutputs
- type SuppressesOutput
Constants ¶
This section is empty.
Variables ¶
var DefaultFlagDashes = Dashes{
Long: "--",
Short: "-",
}
Functions ¶
func ExecuteSingleStepAction ¶
func ExecuteSingleStepAction(ctx context.Context, cfg runtime.RuntimeConfig, action ExecutableAction) (string, error)
ExecuteSingleStepAction runs the command represented by an ExecutableAction, where only a single step is allowed to be defined in the Action (which is what happens when Porter executes steps one at a time).
func ExecuteStep ¶
func ExecuteStep(ctx context.Context, cfg runtime.RuntimeConfig, step ExecutableStep) (string, error)
ExecuteStep runs the command represented by an ExecutableStep, piping stdout/stderr back to the context and returns the buffered output for subsequent processing.
func LoadAction ¶
func LoadAction(ctx context.Context, cfg runtime.RuntimeConfig, commandFile string, unmarshal func([]byte) (interface{}, error)) error
LoadAction reads input from stdin or a command file and uses the specified unmarshal function to unmarshal it into a typed Action. The unmarshal function is responsible for calling yaml.Unmarshal and passing in a reference to an appropriate Action instance.
Example:
var action Action err := builder.LoadAction(m.Context, opts.File, func(contents []byte) (interface{}, error) { err := yaml.Unmarshal(contents, &action) return &action, err })
func ProcessFileOutputs ¶
func ProcessFileOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs) error
ProcessFileOutputs makes the contents of a file specified by any OutputFile interface available as an output.
func ProcessJsonPathOutputs ¶
func ProcessJsonPathOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs, stdout string) error
ProcessJsonPathOutputs evaluates the specified output buffer as JSON, looks through the outputs for any that implement the OutputJsonPath and extracts their output.
func ProcessRegexOutputs ¶
func ProcessRegexOutputs(ctx context.Context, cfg runtime.RuntimeConfig, step StepWithOutputs, stdout string) error
ProcessRegexOutputs looks through the outputs for any that implement the OutputRegex, applies the regular expression to the output buffer and extracts their output.
func UnmarshalAction ¶
func UnmarshalAction(unmarshal func(interface{}) error, builder BuildableAction) (map[string][]interface{}, error)
UnmarshalAction handles unmarshaling any action, given a pointer to a slice of Steps. Iterate over the results and cast back to the Steps to use the results.
var steps []Step results, err := UnmarshalAction(unmarshal, &steps) if err != nil { return err } for _, result := range results { step := result.(*[]Step) a.Steps = append(a.Steps, *step...) }
Types ¶
type BuildableAction ¶
type BuildableAction interface {
// MakeSteps returns a Steps struct to unmarshal into.
MakeSteps() interface{}
}
BuildableAction is an Action that can be marshaled and unmarshaled "generically"
type ExecutableAction ¶
type ExecutableAction interface {
GetSteps() []ExecutableStep
}
type ExecutableStep ¶
type Flag ¶
Flag represents a flag passed to a mixin command.
type Flags ¶
type Flags []Flag
func (Flags) MarshalYAML ¶
MarshalYAML writes out flags back into the proper format for mixin flags. Input: []Flags{ {"flag1", []string{"value"}}, {"flag2", []string{"value"}}, {"flag3", []string{"value1", "value2"} }
Is turned into ¶
flags:
flag1: value flag2: value flag3: - value1 - value2
func (*Flags) ToSlice ¶
ToSlice converts to a string array suitable of command arguments suitable for passing to exec.Command
func (*Flags) UnmarshalYAML ¶
UnmarshalYAML takes input like this flags:
flag1: value flag2: value flag3: - value1 - value2
and turns it into this:
[]Flags{ {"flag1", []string{"value"}}, {"flag2", []string{"value"}}, {"flag3", []string{"value1", "value2"} }
type HasCustomDashes ¶
type HasCustomDashes interface {
GetDashes() Dashes
}
type HasEnvironmentVars ¶ added in v1.0.1
type HasErrorHandling ¶ added in v1.0.1
type HasErrorHandling interface {
HandleError(ctx context.Context, err ExitError, stdout string, stderr string) error
}
HasErrorHandling is implemented by mixin commands that want to handle errors themselves, and possibly allow failed commands to either pass, or to improve the displayed error message
type HasOrderedArguments ¶ added in v0.27.2
type HasOrderedArguments interface {
GetSuffixArguments() []string
}
type IgnoreErrorHandler ¶ added in v1.0.1
type IgnoreErrorHandler struct { // All ignores any error that happens when the command is run. All bool `yaml:"all,omitempty"` // ExitCodes ignores any exit codes in the list. ExitCodes []int `yaml:"exitCodes,omitempty"` // Output determines if the error should be ignored based on the command // output. Output IgnoreErrorWithOutput `yaml:"output,omitempty"` }
IgnoreErrorHandler implements HasErrorHandling for the exec mixin and can be used by any other mixin to get the same error handling behavior.
func (IgnoreErrorHandler) HandleError ¶ added in v1.0.1
type IgnoreErrorWithOutput ¶ added in v1.0.1
type IgnoreErrorWithOutput struct { // Contains specifies that the error is ignored when stderr contains the // specified substring. Contains []string `yaml:"contains,omitempty"` // Regex specifies that the error is ignored when stderr matches the // specified regular expression. Regex []string `yaml:"regex,omitempty"` }
type OutputFile ¶
type OutputJsonPath ¶
type OutputRegex ¶
type StepWithOutputs ¶
type StepWithOutputs interface {
GetOutputs() []Output
}
type SuppressesOutput ¶
type SuppressesOutput interface {
SuppressesOutput() bool
}