Documentation ¶
Index ¶
- func ExecuteSingleStepAction(cxt *context.Context, action ExecutableAction) (*bytes.Buffer, error)
- func ExecuteStep(cxt *context.Context, step ExecutableStep) (*bytes.Buffer, error)
- func LoadAction(cxt *context.Context, commandFile string, ...) error
- func UnmarshalAction(unmarshal func(interface{}) error, steps interface{}) ([]interface{}, error)
- type ExecutableAction
- type ExecutableStep
- type Flag
- type Flags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteSingleStepAction ¶
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 ¶
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(cxt *context.Context, 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 UnmarshalAction ¶
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 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"} }