Documentation
¶
Overview ¶
Package action provides implementations of discovering and running actions.
Index ¶
- Constants
- func CobraImpl(cmd *Command, appCli cli.Streams, cfg launchr.Config, group *cobra.Group) (*cobra.Command, error)
- func ConfigImage(cfg launchr.Config, image string) *types.BuildDefinition
- func ConvertInputToMap(cmd *Command, conf *Action) map[string]interface{}
- func ForwardAllSignals(ctx context.Context, cli driver.ContainerRunner, cid string, ...)
- type Action
- type ActionConfig
- type Argument
- type ArgumentsList
- type Command
- func (cmd *Command) Action() *ActionConfig
- func (cmd *Command) ActionRaw() ([]byte, error)
- func (cmd *Command) Compile() error
- func (cmd *Command) Dir() string
- func (cmd *Command) SetArgsInput(args []string)
- func (cmd *Command) SetOptsInput(options map[string]interface{})
- func (cmd *Command) ValidateInput() error
- type ConfigImages
- type Discovery
- type EnvSlice
- type Executor
- type LoadProcessor
- type Loader
- type Manager
- type Option
- type OptionsList
- type StrSlice
Constants ¶
const ConfigImagesKey = "images"
ConfigImagesKey is a field name in launchr config file.
Variables ¶
This section is empty.
Functions ¶
func CobraImpl ¶ added in v0.0.9
func CobraImpl(cmd *Command, appCli cli.Streams, cfg launchr.Config, group *cobra.Group) (*cobra.Command, error)
CobraImpl returns cobra command implementation for an action command.
func ConfigImage ¶ added in v0.1.0
func ConfigImage(cfg launchr.Config, image string) *types.BuildDefinition
ConfigImage extends launchr.Config functionality and parses images definition.
func ConvertInputToMap ¶ added in v0.0.9
ConvertInputToMap creates a map with input variables suitable for template engine.
func ForwardAllSignals ¶
func ForwardAllSignals(ctx context.Context, cli driver.ContainerRunner, cid string, sigc <-chan os.Signal)
ForwardAllSignals forwards signals to the container
The channel you pass in must already be setup to receive any signals you want to forward.
Types ¶
type Action ¶
type Action struct { Version string `yaml:"version"` Action *ActionConfig `yaml:"action"` }
Action is a representation of an action yaml file
func CreateFromYaml ¶
CreateFromYaml creates action definition from yaml configuration. It returns pointer to Action or nil on error.
func CreateFromYamlTpl ¶
CreateFromYamlTpl creates action definition from yaml configuration as CreateFromYaml but considers that it has unescaped template values.
type ActionConfig ¶ added in v0.0.9
type ActionConfig struct { Title string `yaml:"title"` Description string `yaml:"description"` Arguments ArgumentsList `yaml:"arguments"` Options OptionsList `yaml:"options"` Command StrSlice `yaml:"command"` Image string `yaml:"image"` Build *types.BuildDefinition `yaml:"build"` ExtraHosts []string `yaml:"extra_hosts"` Env EnvSlice `yaml:"env"` }
ActionConfig holds action configuration
func (*ActionConfig) BuildDefinition ¶ added in v0.0.9
func (a *ActionConfig) BuildDefinition(wd string) *types.BuildDefinition
BuildDefinition provides resolved image build info
type Argument ¶
type Argument struct { Name string `yaml:"name"` Title string `yaml:"title"` Description string `yaml:"description"` Type jsonschema.Type `yaml:"type"` RawMap map[string]interface{} }
Argument stores command arguments declaration.
type ArgumentsList ¶
type ArgumentsList []*Argument
ArgumentsList is used for custom yaml parsing of arguments list.
func (*ArgumentsList) UnmarshalYAML ¶
func (l *ArgumentsList) UnmarshalYAML(nodeList *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse for ArgumentsList.
type Command ¶
type Command struct { WorkingDir string Filepath string CommandName string Loader Loader InputArgs map[string]string InputOptions map[string]interface{} // contains filtered or unexported fields }
Command is an action with a contextual name, working directory path and a runtime context such as input arguments and options.
func (*Command) Action ¶
func (cmd *Command) Action() *ActionConfig
Action returns action with replaces variables.
func (*Command) SetArgsInput ¶
SetArgsInput saves passed cobra arguments for later processing in run, templates, etc.
func (*Command) SetOptsInput ¶
SetOptsInput saves passed cobra flags for later processing in run, templates, etc.
func (*Command) ValidateInput ¶
ValidateInput validates arguments and options according to a specified json schema in action definition.
type ConfigImages ¶ added in v0.1.0
type ConfigImages map[string]*types.BuildDefinition
ConfigImages is a container to parse launchr config with yaml.
type Discovery ¶
Discovery finds action files and parses them.
func NewYamlDiscovery ¶
NewYamlDiscovery creates an instance of action discovery.
type EnvSlice ¶
type EnvSlice []string
EnvSlice is an array of env vars or key-value.
func (*EnvSlice) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler to parse env []string or map[string]string.
type Executor ¶
type Executor interface { Exec(ctx context.Context, cli cli.Streams, cmd *Command) error Close() error }
Executor is a common interface for all container executors.
func NewContainerExecutor ¶
NewContainerExecutor creates a new action executor in container environment.
func NewDockerExecutor ¶
NewDockerExecutor creates a new action executor in Docker environment.
type LoadProcessor ¶
LoadProcessor is an interface for processing input on load.
func NewPipeProcessor ¶
func NewPipeProcessor(p ...LoadProcessor) LoadProcessor
NewPipeProcessor creates a new processor containing several processors that handles input consequentially.
type Loader ¶
type Loader interface { Content() ([]byte, error) Load() (*Action, error) LoadRaw() (*Action, error) }
Loader is an interface for loading an action file.
type Manager ¶ added in v0.0.9
Manager handles actions.
func NewManager ¶ added in v0.0.9
func NewManager() Manager
NewManager constructs a new action manager.
type Option ¶
type Option struct { Name string `yaml:"name"` Title string `yaml:"title"` Description string `yaml:"description"` Type jsonschema.Type `yaml:"type"` Default interface{} `yaml:"default"` Required bool `yaml:"required"` RawMap map[string]interface{} }
Option stores command options declaration.
type OptionsList ¶
type OptionsList []*Option
OptionsList is used for custom yaml parsing of options list.
func (*OptionsList) UnmarshalYAML ¶
func (l *OptionsList) UnmarshalYAML(nodeList *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse for OptionsList.