Documentation
¶
Overview ¶
Package action provides implementations of discovering and running actions.
Index ¶
- func ConvertInputToStruct(cmd *Command, conf *Config) map[string]interface{}
- func ForwardAllSignals(ctx context.Context, cli driver.ContainerRunner, cid string, ...)
- type Action
- type Argument
- type ArgumentsList
- type Command
- type Config
- type Discovery
- type EnvSlice
- type Executor
- type LoadProcessor
- type Loader
- type Option
- type OptionsList
- type StrSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertInputToStruct ¶
ConvertInputToStruct creates an arbitrary struct from input variables.
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 { 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 *cli.BuildDefinition `yaml:"build"` ExtraHosts []string `yaml:"extra_hosts"` Env EnvSlice `yaml:"env"` }
Action is a representation of an action structure of an action yaml
func (*Action) BuildDefinition ¶
func (a *Action) BuildDefinition(wd string) *cli.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 holds a definition of a discovered action file.
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 Config ¶
Config is a representation of an action yaml
func CreateFromYaml ¶
CreateFromYaml creates action definition from yaml configuration. It returns pointer to Config or nil on error.
func CreateFromYamlTpl ¶
CreateFromYamlTpl creates action definition from yaml configuration as CreateFromYaml but considers that it has unescaped template values.
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.Cli, 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() (*Config, error) LoadRaw() (*Config, error) }
Loader is an interface for loading a config file.
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.