Documentation
¶
Overview ¶
Package action provides implementations of discovering and running actions.
Index ¶
- Constants
- Variables
- func CastSliceAnyToTyped[T any](orig []any) []T
- func CastSliceTypedToAny(slice any) []any
- func GetLoggerAndTerminal(a *Action) (log *launchr.Logger, term *launchr.Terminal)
- func InputArgSlice[T any](input *Input, name string) []T
- func InputOptSlice[T any](input *Input, name string) []T
- type Action
- func (a *Action) ActionDef() *DefAction
- func (a *Action) Clone() *Action
- func (a *Action) DefinitionEncoded() ([]byte, error)
- func (a *Action) Dir() string
- func (a *Action) EnsureLoaded() (err error)
- func (a *Action) Execute(ctx context.Context) error
- func (a *Action) Filepath() string
- func (a *Action) ImageBuildInfo(image string) *driver.BuildDefinition
- func (a *Action) Input() *Input
- func (a *Action) JSONSchema() jsonschema.Schema
- func (a *Action) Raw() (*Definition, error)
- func (a *Action) Reset()
- func (a *Action) Runtime() Runtime
- func (a *Action) RuntimeDef() *DefRuntime
- func (a *Action) SetInput(input *Input) (err error)
- func (a *Action) SetRuntime(r Runtime)
- func (a *Action) SetServices(s *launchr.ServiceManager)
- func (a *Action) SetWorkDir(wd string)
- func (a *Action) WorkDir() string
- type ChainImageBuildResolver
- type ConfigImages
- type ContainerNameProvider
- type ContainerRuntime
- type DecorateWithFn
- type DefAction
- type DefArrayItems
- type DefParameter
- type DefRuntime
- type DefRuntimeContainer
- type DefRuntimeShell
- type DefRuntimeType
- type DefValueProcessor
- type DefaultIDProvider
- type Definition
- type DiscoverActionsFn
- type Discovery
- type DiscoveryFS
- type DiscoveryPlugin
- type DiscoveryStrategy
- type EnvSlice
- type ErrValueProcessorHandler
- type ErrValueProcessorNotApplicable
- type ErrValueProcessorNotExist
- type ErrValueProcessorOptionsFieldValidation
- type ErrValueProcessorOptionsValidation
- type FileLoadFn
- type FlagsGroup
- func (p *FlagsGroup) AddDefinitions(opts ParametersList)
- func (p *FlagsGroup) Get(name string) (any, bool)
- func (p *FlagsGroup) GetAll() InputParams
- func (p *FlagsGroup) GetDefinitions() ParametersList
- func (p *FlagsGroup) GetName() string
- func (p *FlagsGroup) JSONSchema() jsonschema.Schema
- func (p *FlagsGroup) Name() string
- func (p *FlagsGroup) Set(name string, value any)
- func (p *FlagsGroup) Unset(name string)
- func (p *FlagsGroup) ValidateFlags(params InputParams) error
- type FnRuntime
- type FnRuntimeCallback
- type GenericValueProcessor
- type GenericValueProcessorHandler
- type GenericValueProcessorOptions
- type IDProvider
- type ImageBuildCacheResolver
- func (r *ImageBuildCacheResolver) Destroy() error
- func (r *ImageBuildCacheResolver) DirHash(path string) (string, error)
- func (r *ImageBuildCacheResolver) EnsureLoaded() (err error)
- func (r *ImageBuildCacheResolver) GetSum(tag string) string
- func (r *ImageBuildCacheResolver) Save() error
- func (r *ImageBuildCacheResolver) SetSum(tag string, sum string)
- type ImageBuildResolver
- type Input
- func (input *Input) Arg(name string) any
- func (input *Input) Args() InputParams
- func (input *Input) ArgsChanged() InputParams
- func (input *Input) ArgsPositional() []string
- func (input *Input) GetFlagInGroup(group, name string) any
- func (input *Input) GroupFlags(group string) InputParams
- func (input *Input) IsArgChanged(name string) bool
- func (input *Input) IsOptChanged(name string) bool
- func (input *Input) IsValidated() bool
- func (input *Input) Opt(name string) any
- func (input *Input) Opts() InputParams
- func (input *Input) OptsChanged() InputParams
- func (input *Input) SetArg(name string, val any)
- func (input *Input) SetFlagInGroup(group, name string, val any)
- func (input *Input) SetOpt(name string, val any)
- func (input *Input) SetStreams(io launchr.Streams)
- func (input *Input) SetValidated(v bool)
- func (input *Input) Streams() launchr.Streams
- func (input *Input) UnsetArg(name string)
- func (input *Input) UnsetOpt(name string)
- type InputParams
- type LaunchrConfigImageBuildResolver
- type LoadContext
- type LoadProcessor
- type Loader
- type Manager
- type ParametersList
- type RunInfo
- type RunManager
- type Runtime
- type RuntimeFlags
- type RuntimeLoggerAware
- type RuntimeTermAware
- type StrSlice
- type StringID
- type TemplateFuncContext
- type TemplateProcessors
- func (m *TemplateProcessors) AddTemplateFunc(name string, fn any)
- func (m *TemplateProcessors) AddValueProcessor(name string, vp ValueProcessor)
- func (m *TemplateProcessors) GetTemplateFuncMap(ctx TemplateFuncContext) template.FuncMap
- func (m *TemplateProcessors) GetValueProcessors() map[string]ValueProcessor
- func (m *TemplateProcessors) ServiceCreate(_ *launchr.ServiceManager) launchr.Service
- func (m *TemplateProcessors) ServiceInfo() launchr.ServiceInfo
- type TestCaseValueProcessor
- type ValueProcessor
- type ValueProcessorContext
- type ValueProcessorHandler
- type ValueProcessorOptions
- type ValueProcessorOptionsEmpty
- type ValueProcessorOptionsFields
- type WithFlagsGroup
- type WithLogger
- type WithTerm
- type YamlDiscoveryStrategy
- type YamlFileLoader
- type YamlLoader
Constants ¶
const ConfigImagesKey = "images"
ConfigImagesKey is a field name in launchr.Config file.
Variables ¶
var EnvVarRuntimeShellBash = launchr.EnvVar("runtime_shell_bash")
EnvVarRuntimeShellBash defines path to bash shell.
Functions ¶
func CastSliceAnyToTyped ¶ added in v0.17.1
CastSliceAnyToTyped converts []any slice to a typed slice.
func CastSliceTypedToAny ¶ added in v0.17.1
CastSliceTypedToAny converts an unknown slice to []any slice.
func GetLoggerAndTerminal ¶ added in v0.22.0
GetLoggerAndTerminal returns action logger and terminal if any.
func InputArgSlice ¶ added in v0.17.1
InputArgSlice is a helper function to get an argument of specific type slice.
func InputOptSlice ¶ added in v0.17.1
InputOptSlice is a helper function to get an option of specific type slice.
Types ¶
type Action ¶
type Action struct {
ID string // ID is a unique action id provided by [IDProvider].
// contains filtered or unexported fields
}
Action is an action definition with a contextual id (name), working directory path and a runtime context such as input arguments and options.
func New ¶ added in v0.17.1
func New(idp IDProvider, l Loader, fsys DiscoveryFS, fpath string) *Action
New creates a new action.
func NewFromYAML ¶ added in v0.17.1
NewFromYAML creates a new action from yaml content.
func NewYAMLFromFS ¶ added in v0.18.0
NewYAMLFromFS creates an action from the given filesystem. The filesystem must have action.yaml in the root.
func (*Action) DefinitionEncoded ¶ added in v0.1.2
DefinitionEncoded returns encoded action file content.
func (*Action) EnsureLoaded ¶ added in v0.1.2
EnsureLoaded loads an action file with replaced arguments and options.
func (*Action) ImageBuildInfo ¶ added in v0.1.2
func (a *Action) ImageBuildInfo(image string) *driver.BuildDefinition
ImageBuildInfo implements ImageBuildResolver.
func (*Action) JSONSchema ¶ added in v0.1.2
func (a *Action) JSONSchema() jsonschema.Schema
JSONSchema returns json schema of an action.
func (*Action) Raw ¶ added in v0.14.0
func (a *Action) Raw() (*Definition, error)
Raw returns unprocessed action definition. It is faster and may produce fewer errors. It may be helpful if needed to peek inside the action file to read header.
func (*Action) Reset ¶ added in v0.1.2
func (a *Action) Reset()
Reset unsets loaded action to force reload.
func (*Action) RuntimeDef ¶ added in v0.17.1
func (a *Action) RuntimeDef() *DefRuntime
RuntimeDef returns runtime definition with replaced variables.
func (*Action) SetInput ¶ added in v0.1.2
SetInput saves arguments and options for later processing in run, templates, etc.
func (*Action) SetRuntime ¶ added in v0.17.1
SetRuntime sets environment to run the action.
func (*Action) SetServices ¶ added in v0.22.0
func (a *Action) SetServices(s *launchr.ServiceManager)
SetServices sets a launchr.ServiceManager for Dependency Injection.
func (*Action) SetWorkDir ¶ added in v0.17.1
SetWorkDir sets action working directory.
type ChainImageBuildResolver ¶ added in v0.1.2
type ChainImageBuildResolver []ImageBuildResolver
ChainImageBuildResolver is a image build resolver that takes first available image in the chain.
func (ChainImageBuildResolver) ImageBuildInfo ¶ added in v0.1.2
func (r ChainImageBuildResolver) ImageBuildInfo(image string) *driver.BuildDefinition
ImageBuildInfo implements ImageBuildResolver.
type ConfigImages ¶ added in v0.1.0
type ConfigImages map[string]*driver.BuildDefinition
ConfigImages is a container to parse launchr.Config in yaml format.
type ContainerNameProvider ¶ added in v0.3.0
ContainerNameProvider provides an ability to generate a random container name
func (ContainerNameProvider) Get ¶ added in v0.3.0
func (p ContainerNameProvider) Get(name string) string
Get generates a new container name
type ContainerRuntime ¶ added in v0.17.1
type ContainerRuntime interface {
Runtime
// SetContainerNameProvider sets container name provider.
SetContainerNameProvider(ContainerNameProvider)
// AddImageBuildResolver adds an image build resolver to a chain.
AddImageBuildResolver(ImageBuildResolver)
// SetImageBuildCacheResolver sets an image build cache resolver
// to check when image must be rebuilt.
SetImageBuildCacheResolver(*ImageBuildCacheResolver)
}
ContainerRuntime is an interface for container runtime.
func NewContainerRuntime ¶ added in v0.17.1
func NewContainerRuntime(t driver.Type) ContainerRuntime
NewContainerRuntime creates a new action container runtime.
func NewContainerRuntimeDocker ¶ added in v0.17.1
func NewContainerRuntimeDocker() ContainerRuntime
NewContainerRuntimeDocker creates a new action Docker runtime.
func NewContainerRuntimeKubernetes ¶ added in v0.18.0
func NewContainerRuntimeKubernetes() ContainerRuntime
NewContainerRuntimeKubernetes creates a new action Kubernetes runtime.
type DecorateWithFn ¶ added in v0.1.2
DecorateWithFn is a type alias for functions accepted in a [Manager.Decorate] interface method.
func WithContainerRuntimeConfig ¶ added in v0.17.1
func WithContainerRuntimeConfig(cfg launchr.Config, prefix string) DecorateWithFn
WithContainerRuntimeConfig configures a ContainerRuntime.
func WithDefaultRuntime ¶ added in v0.17.1
func WithDefaultRuntime(cfg launchr.Config) DecorateWithFn
WithDefaultRuntime adds a default Runtime for an action.
func WithServices ¶ added in v0.22.0
func WithServices(services *launchr.ServiceManager) DecorateWithFn
WithServices add global app to action. Helps with DI in actions.
type DefAction ¶ added in v0.1.2
type DefAction struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
Aliases []string `yaml:"alias"`
Arguments ParametersList `yaml:"arguments"`
Options ParametersList `yaml:"options"`
}
DefAction holds action configuration.
func (*DefAction) JSONSchema ¶ added in v0.1.2
func (a *DefAction) JSONSchema() jsonschema.Schema
JSONSchema returns jsonschema.Schema for the arguments and options of the action.
func (*DefAction) UnmarshalYAML ¶ added in v0.1.2
UnmarshalYAML implements yaml.Unmarshaler to parse action definition.
type DefArrayItems ¶ added in v0.17.1
type DefArrayItems struct {
Type jsonschema.Type `yaml:"type"`
}
DefArrayItems stores array type related information.
type DefParameter ¶ added in v0.17.1
type DefParameter struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
Type jsonschema.Type `yaml:"type"`
Default any `yaml:"default"`
Enum []any `yaml:"enum"`
Items *DefArrayItems `yaml:"items"`
// Action specific behavior for parameters.
// Name is an action unique parameter name used.
Name string `yaml:"name"`
// Shorthand is a short name 1 syllable name used in Console.
Shorthand string `yaml:"shorthand"`
// Required indicates if the parameter is mandatory.
// It's not correct json schema, and it's processed to a correct place later.
Required bool `yaml:"required"`
// Process is an array of [ValueProcessor] to a value.
Process []DefValueProcessor `yaml:"process"`
// contains filtered or unexported fields
}
DefParameter stores command argument or option declaration.
func (*DefParameter) InitProcessors ¶ added in v0.17.2
func (p *DefParameter) InitProcessors(list map[string]ValueProcessor) (err error)
InitProcessors creates ValueProcessor handlers according to the definition.
func (*DefParameter) JSONSchema ¶ added in v0.17.1
func (p *DefParameter) JSONSchema() map[string]any
JSONSchema returns json schema definition of an option.
func (*DefParameter) UnmarshalYAML ¶ added in v0.17.1
func (p *DefParameter) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse DefParameter.
type DefRuntime ¶ added in v0.17.1
type DefRuntime struct {
Type DefRuntimeType `yaml:"type"`
Container *DefRuntimeContainer
Shell *DefRuntimeShell
}
DefRuntime contains action runtime configuration.
func (*DefRuntime) UnmarshalYAML ¶ added in v0.17.1
func (r *DefRuntime) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse runtime definition.
type DefRuntimeContainer ¶ added in v0.17.1
type DefRuntimeContainer struct {
Command StrSlice `yaml:"command"`
Image string `yaml:"image"`
Build *driver.BuildDefinition `yaml:"build"`
ExtraHosts StrSlice `yaml:"extra_hosts"`
Env EnvSlice `yaml:"env"`
User string `yaml:"user"`
}
DefRuntimeContainer has container-specific runtime configuration.
func (*DefRuntimeContainer) UnmarshalYAML ¶ added in v0.17.1
func (r *DefRuntimeContainer) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse runtime container definition.
type DefRuntimeShell ¶ added in v0.19.0
DefRuntimeShell has shell-specific runtime configuration.
func (*DefRuntimeShell) UnmarshalYAML ¶ added in v0.19.0
func (r *DefRuntimeShell) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse runtime shell definition.
type DefRuntimeType ¶ added in v0.17.1
type DefRuntimeType string
DefRuntimeType is a runtime type.
func (*DefRuntimeType) UnmarshalYAML ¶ added in v0.17.1
func (r *DefRuntimeType) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse runtime type.
type DefValueProcessor ¶ added in v0.17.1
type DefValueProcessor struct {
ID string `yaml:"processor"`
// contains filtered or unexported fields
}
DefValueProcessor stores information about processor and options that should be applied to processor.
func (*DefValueProcessor) UnmarshalYAML ¶ added in v0.17.1
func (p *DefValueProcessor) UnmarshalYAML(n *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse DefValueProcessor.
type DefaultIDProvider ¶ added in v0.14.0
type DefaultIDProvider struct{}
DefaultIDProvider is a default action id provider. It generates action id by a filepath.
func (DefaultIDProvider) GetID ¶ added in v0.14.0
func (idp DefaultIDProvider) GetID(a *Action) string
GetID implements IDProvider interface. It parses action filename and returns CLI command name. Empty string if the command name can't be generated.
type Definition ¶ added in v0.1.2
type Definition struct {
Version string `yaml:"version"`
WD string `yaml:"working_directory"`
Action *DefAction `yaml:"action"`
Runtime *DefRuntime `yaml:"runtime"`
}
Definition is a representation of an action file.
func NewDefFromYaml ¶ added in v0.17.1
func NewDefFromYaml(b []byte) (*Definition, error)
NewDefFromYaml creates an action file definition from yaml configuration. It returns pointer to Definition or nil on error.
func (*Definition) Content ¶ added in v0.1.2
func (d *Definition) Content() ([]byte, error)
Content implements Loader interface.
func (*Definition) Load ¶ added in v0.1.2
func (d *Definition) Load(_ *LoadContext) (*Definition, error)
Load implements Loader interface.
func (*Definition) UnmarshalYAML ¶ added in v0.1.2
func (d *Definition) UnmarshalYAML(node *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse action definition.
type DiscoverActionsFn ¶ added in v0.19.0
DiscoverActionsFn defines a function to discover actions.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery defines a common functionality for discovering action files.
func NewDiscovery ¶ added in v0.5.4
func NewDiscovery(fs DiscoveryFS, ds DiscoveryStrategy) *Discovery
NewDiscovery creates an instance of action discovery.
func NewYamlDiscovery ¶
func NewYamlDiscovery(fs DiscoveryFS) *Discovery
NewYamlDiscovery is an implementation of discovery for searching yaml files.
func (*Discovery) Discover ¶
Discover traverses the file structure for a given discovery path. Returns array of Action. If an action is invalid, it's ignored.
func (*Discovery) SetActionIDProvider ¶ added in v0.14.0
func (ad *Discovery) SetActionIDProvider(idp IDProvider)
SetActionIDProvider sets discovery specific action id provider.
type DiscoveryFS ¶ added in v0.5.5
type DiscoveryFS struct {
// contains filtered or unexported fields
}
DiscoveryFS is a file system to discover actions.
func NewDiscoveryFS ¶ added in v0.5.5
func NewDiscoveryFS(fs fs.FS, wd string) DiscoveryFS
NewDiscoveryFS creates a DiscoveryFS given fs - a filesystem to discover and wd - working directory for an action, leave empty for current path.
func (DiscoveryFS) FS ¶ added in v0.5.5
func (f DiscoveryFS) FS() fs.FS
FS implements launchr.ManagedFS.
func (DiscoveryFS) IsDiscoverable ¶ added in v0.22.0
func (f DiscoveryFS) IsDiscoverable() bool
IsDiscoverable checks if the underlying filesystem path is available for discovery.
func (DiscoveryFS) Open ¶ added in v0.5.5
func (f DiscoveryFS) Open(name string) (fs.File, error)
Open implements fs.FS and decorates the launchr.ManagedFS.
func (DiscoveryFS) OpenCallback ¶ added in v0.17.1
func (f DiscoveryFS) OpenCallback(name string) FileLoadFn
OpenCallback returns callback to FileOpen a file.
func (DiscoveryFS) Realpath ¶ added in v0.18.0
func (f DiscoveryFS) Realpath() string
Realpath returns the real os path of the underlying FS.
type DiscoveryPlugin ¶ added in v0.5.4
type DiscoveryPlugin interface {
launchr.Plugin
DiscoverActions(ctx context.Context) ([]*Action, error)
}
DiscoveryPlugin is a launchr plugin to discover actions.
type DiscoveryStrategy ¶ added in v0.5.4
type DiscoveryStrategy interface {
IsValid(path string) bool
Loader(l FileLoadFn, p ...LoadProcessor) Loader
}
DiscoveryStrategy is a way files will be discovered and loaded.
type EnvSlice ¶
type EnvSlice []string
EnvSlice is an array of runtime vars or key-value.
func (*EnvSlice) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler to parse runtime []string or map[string]string.
type ErrValueProcessorHandler ¶ added in v0.18.0
ErrValueProcessorHandler error when ValueProcessorHandler processing has failed.
func (ErrValueProcessorHandler) Error ¶ added in v0.18.0
func (err ErrValueProcessorHandler) Error() string
type ErrValueProcessorNotApplicable ¶ added in v0.18.0
type ErrValueProcessorNotApplicable struct {
Processor string
Type jsonschema.Type
}
ErrValueProcessorNotApplicable error when the given parameter is not supported ValueProcessor.
func (ErrValueProcessorNotApplicable) Error ¶ added in v0.18.0
func (err ErrValueProcessorNotApplicable) Error() string
type ErrValueProcessorNotExist ¶ added in v0.18.0
type ErrValueProcessorNotExist string
ErrValueProcessorNotExist error when ValueProcessor is not registered in the app.
func (ErrValueProcessorNotExist) Error ¶ added in v0.18.0
func (err ErrValueProcessorNotExist) Error() string
type ErrValueProcessorOptionsFieldValidation ¶ added in v0.18.0
ErrValueProcessorOptionsFieldValidation error when ValueProcessorOptions field validation error
func (ErrValueProcessorOptionsFieldValidation) Error ¶ added in v0.18.0
func (err ErrValueProcessorOptionsFieldValidation) Error() string
type ErrValueProcessorOptionsValidation ¶ added in v0.18.0
ErrValueProcessorOptionsValidation error when ValueProcessorOptions fails to validate.
func (ErrValueProcessorOptionsValidation) Error ¶ added in v0.18.0
func (err ErrValueProcessorOptionsValidation) Error() string
type FileLoadFn ¶ added in v0.5.4
FileLoadFn is a type for loading a file.
type FlagsGroup ¶ added in v0.21.0
type FlagsGroup struct {
// contains filtered or unexported fields
}
FlagsGroup holds definitions, current state, and default values of flags. @todo think about moving it to new input validation service alongside. See notes in actionManagerMap.ValidateFlags.
func NewFlagsGroup ¶ added in v0.21.0
func NewFlagsGroup(name string) *FlagsGroup
NewFlagsGroup returns a new instance of FlagsGroup
func (*FlagsGroup) AddDefinitions ¶ added in v0.21.0
func (p *FlagsGroup) AddDefinitions(opts ParametersList)
AddDefinitions adds new flag definition.
func (*FlagsGroup) Get ¶ added in v0.21.0
func (p *FlagsGroup) Get(name string) (any, bool)
Get returns state of a named flag. Return false if a flag doesn't exist.
func (*FlagsGroup) GetAll ¶ added in v0.21.0
func (p *FlagsGroup) GetAll() InputParams
GetAll returns the latest state of flags.
func (*FlagsGroup) GetDefinitions ¶ added in v0.21.0
func (p *FlagsGroup) GetDefinitions() ParametersList
GetDefinitions returns ParametersList with flags definitions.
func (*FlagsGroup) GetName ¶ added in v0.21.0
func (p *FlagsGroup) GetName() string
GetName returns the name of the flags group. Deprecated: use Name().
func (*FlagsGroup) JSONSchema ¶ added in v0.21.0
func (p *FlagsGroup) JSONSchema() jsonschema.Schema
JSONSchema returns JSON schema of a flags group.
func (*FlagsGroup) Name ¶ added in v0.22.0
func (p *FlagsGroup) Name() string
Name returns the name of the flags group.
func (*FlagsGroup) Set ¶ added in v0.21.0
func (p *FlagsGroup) Set(name string, value any)
Set sets new state value for a flag. Does nothing if flag doesn't exist.
func (*FlagsGroup) Unset ¶ added in v0.21.0
func (p *FlagsGroup) Unset(name string)
Unset removes the flag value. The default value will be returned during FlagsGroup.GetAll if flag is not set.
func (*FlagsGroup) ValidateFlags ¶ added in v0.21.0
func (p *FlagsGroup) ValidateFlags(params InputParams) error
ValidateFlags validates input flags.
type FnRuntime ¶ added in v0.17.1
type FnRuntime struct {
WithLogger
WithTerm
// contains filtered or unexported fields
}
FnRuntime is a function type implementing Runtime.
type FnRuntimeCallback ¶ added in v0.21.0
FnRuntimeCallback is a function type used in FnRuntime.
type GenericValueProcessor ¶ added in v0.17.2
type GenericValueProcessor[T ValueProcessorOptions] struct { Types []jsonschema.Type Fn GenericValueProcessorHandler[T] }
GenericValueProcessor is a common ValueProcessor.
func (GenericValueProcessor[T]) Handler ¶ added in v0.17.2
func (p GenericValueProcessor[T]) Handler(opts ValueProcessorOptions) ValueProcessorHandler
Handler implements ValueProcessor interface.
func (GenericValueProcessor[T]) IsApplicable ¶ added in v0.17.2
func (p GenericValueProcessor[T]) IsApplicable(t jsonschema.Type) bool
IsApplicable implements ValueProcessor interface.
func (GenericValueProcessor[T]) OptionsType ¶ added in v0.17.2
func (p GenericValueProcessor[T]) OptionsType() ValueProcessorOptions
OptionsType implements ValueProcessor interface.
type GenericValueProcessorHandler ¶ added in v0.17.2
type GenericValueProcessorHandler[T ValueProcessorOptions] func(v any, opts T, ctx ValueProcessorContext) (any, error)
GenericValueProcessorHandler is an extension of ValueProcessorHandler to have typed ValueProcessorOptions.
type GenericValueProcessorOptions ¶ added in v0.18.0
type GenericValueProcessorOptions[T any] struct { Fields T }
GenericValueProcessorOptions is a common ValueProcessorOptions with validation.
func (*GenericValueProcessorOptions[T]) DecodeFields ¶ added in v0.18.0
func (o *GenericValueProcessorOptions[T]) DecodeFields() any
DecodeFields implements ValueProcessorOptionsFields interface.
func (*GenericValueProcessorOptions[T]) Validate ¶ added in v0.18.0
func (o *GenericValueProcessorOptions[T]) Validate() error
Validate implements ValueProcessorOptions interface.
type IDProvider ¶ added in v0.14.0
IDProvider provides an ID for an action. It is used to generate an ID from an action declaration. DefaultIDProvider is the default implementation based on action filepath.
type ImageBuildCacheResolver ¶ added in v0.6.0
type ImageBuildCacheResolver struct {
// contains filtered or unexported fields
}
ImageBuildCacheResolver is responsible for checking image build hash sums to rebuild images.
func NewImageBuildCacheResolver ¶ added in v0.6.0
func NewImageBuildCacheResolver(cfg launchr.Config) *ImageBuildCacheResolver
NewImageBuildCacheResolver creates ImageBuildCacheResolver from global configuration.
func (*ImageBuildCacheResolver) Destroy ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) Destroy() error
Destroy removes the sum file from the persistent storage.
func (*ImageBuildCacheResolver) DirHash ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) DirHash(path string) (string, error)
DirHash calculates the hash of a directory specified by the path parameter.
func (*ImageBuildCacheResolver) EnsureLoaded ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) EnsureLoaded() (err error)
EnsureLoaded makes sure the sum file is loaded.
func (*ImageBuildCacheResolver) GetSum ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) GetSum(tag string) string
GetSum returns a sum for an image tag.
func (*ImageBuildCacheResolver) Save ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) Save() error
Save saves the sum file to the persistent storage.
func (*ImageBuildCacheResolver) SetSum ¶ added in v0.6.0
func (r *ImageBuildCacheResolver) SetSum(tag string, sum string)
SetSum adds sum for a tag. Provide empty sum to remove it.
type ImageBuildResolver ¶ added in v0.1.2
type ImageBuildResolver interface {
// ImageBuildInfo takes image as name and provides build definition for that.
ImageBuildInfo(image string) *driver.BuildDefinition
}
ImageBuildResolver is an interface to resolve image build info from its source.
type Input ¶ added in v0.1.2
type Input struct {
// contains filtered or unexported fields
}
Input is a container for action input arguments and options.
func NewInput ¶ added in v0.17.1
func NewInput(a *Action, args InputParams, opts InputParams, io launchr.Streams) *Input
NewInput creates new input with named Arguments args and named Options opts. Options are filled with default values.
func (*Input) Args ¶ added in v0.1.2
func (input *Input) Args() InputParams
Args returns input named and processed arguments.
func (*Input) ArgsChanged ¶ added in v0.17.2
func (input *Input) ArgsChanged() InputParams
ArgsChanged returns arguments that were set manually by user (not processed).
func (*Input) ArgsPositional ¶ added in v0.17.1
ArgsPositional returns positional arguments set by user (not processed).
func (*Input) GetFlagInGroup ¶ added in v0.21.0
GetFlagInGroup returns a group flag by name.
func (*Input) GroupFlags ¶ added in v0.21.0
func (input *Input) GroupFlags(group string) InputParams
GroupFlags returns stored group flags values.
func (*Input) IsArgChanged ¶ added in v0.17.1
IsArgChanged checks if an argument was changed by user.
func (*Input) IsOptChanged ¶ added in v0.17.1
IsOptChanged checks if an option was changed by user.
func (*Input) IsValidated ¶ added in v0.17.1
IsValidated returns input status.
func (*Input) Opts ¶ added in v0.1.2
func (input *Input) Opts() InputParams
Opts returns options with default values and processed.
func (*Input) OptsChanged ¶ added in v0.17.1
func (input *Input) OptsChanged() InputParams
OptsChanged returns options that were set manually by user (not processed).
func (*Input) SetFlagInGroup ¶ added in v0.21.0
SetFlagInGroup sets group flag value.
func (*Input) SetStreams ¶ added in v0.22.0
SetStreams sets IO in input.
func (*Input) SetValidated ¶ added in v0.17.1
SetValidated marks input as validated.
type InputParams ¶ added in v0.17.1
InputParams is a type alias for action arguments/options.
func ArgsPosToNamed ¶ added in v0.17.1
func ArgsPosToNamed(a *Action, args []string) (InputParams, error)
ArgsPosToNamed creates named arguments input.
type LaunchrConfigImageBuildResolver ¶ added in v0.1.2
type LaunchrConfigImageBuildResolver struct {
// contains filtered or unexported fields
}
LaunchrConfigImageBuildResolver is a resolver of image build in launchr.Config file.
func (LaunchrConfigImageBuildResolver) ImageBuildInfo ¶ added in v0.1.2
func (r LaunchrConfigImageBuildResolver) ImageBuildInfo(image string) *driver.BuildDefinition
ImageBuildInfo implements ImageBuildResolver.
type LoadContext ¶ added in v0.2.1
type LoadContext struct {
// contains filtered or unexported fields
}
LoadContext stores relevant and isolated data needed for processors.
func (*LoadContext) Action ¶ added in v0.2.1
func (ctx *LoadContext) Action() *Action
Action returns context's action.
func (*LoadContext) Services ¶ added in v0.22.0
func (ctx *LoadContext) Services() *launchr.ServiceManager
Services returns a DI container.
type LoadProcessor ¶
type LoadProcessor interface {
// Process gets an input action file data and returns a processed result.
Process(*LoadContext, string) (string, error)
}
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 returns the raw file content.
Content() ([]byte, error)
// Load parses Content to a Definition with substituted values.
Load(*LoadContext) (*Definition, error)
}
Loader is an interface for loading an action file.
type Manager ¶ added in v0.0.9
type Manager = *actionManagerMap
Manager handles actions and its execution.
func NewManager ¶ added in v0.0.9
func NewManager(withFns ...DecorateWithFn) Manager
NewManager constructs a new action manager.
type ParametersList ¶ added in v0.17.1
type ParametersList []*DefParameter
ParametersList is used for custom yaml parsing of arguments list.
func (*ParametersList) JSONSchema ¶ added in v0.17.1
func (l *ParametersList) JSONSchema() (map[string]any, []string)
JSONSchema collects all arguments json schema definition and also returns fields that are required.
func (*ParametersList) UnmarshalYAML ¶ added in v0.17.1
func (l *ParametersList) UnmarshalYAML(nodeList *yaml.Node) (err error)
UnmarshalYAML implements yaml.Unmarshaler to parse for ParametersList.
type RunManager ¶ added in v0.19.0
type RunManager = *runManagerMap
RunManager runs actions and stores runtime information about them.
type Runtime ¶ added in v0.17.1
type Runtime interface {
// Init prepares the runtime.
Init(ctx context.Context, a *Action) error
// Execute runs action `a` in the environment and operates with io through streams.
Execute(ctx context.Context, a *Action) error
// Close does wrap up operations.
Close() error
// Clone creates the same runtime, but in initial state.
Clone() Runtime
}
Runtime is an interface for action execution environment.
func NewFnRuntime ¶ added in v0.17.1
func NewFnRuntime(fn FnRuntimeCallback) Runtime
NewFnRuntime creates runtime as a go function.
func NewShellRuntime ¶ added in v0.19.0
func NewShellRuntime() Runtime
NewShellRuntime creates a new action shell runtime.
type RuntimeFlags ¶ added in v0.17.1
type RuntimeFlags interface {
Runtime
// GetFlags returns flags group of runtime configuration.
GetFlags() *FlagsGroup
// SetFlags sets environment configuration.
SetFlags(input *Input) error
// ValidateInput validates input arguments in action definition.
ValidateInput(input *Input) error
}
RuntimeFlags is an interface to define environment specific runtime configuration.
type RuntimeLoggerAware ¶ added in v0.21.0
type RuntimeLoggerAware interface {
Runtime
// SetLogger adds runtime logger
SetLogger(l *launchr.Logger)
// Log returns runtime logger
Log() *launchr.Logger
// LogWith returns runtime logger with attributes
LogWith(attrs ...any) *launchr.Logger
}
RuntimeLoggerAware is an interface for logger runtime.
type RuntimeTermAware ¶ added in v0.21.0
type RuntimeTermAware interface {
Runtime
// SetTerm adds runtime terminal
SetTerm(t *launchr.Terminal)
// Term returns runtime terminal.
Term() *launchr.Terminal
}
RuntimeTermAware is an interface for term runtime.
type StrSlice ¶
type StrSlice []string
StrSlice is an array of strings.
func (*StrSlice) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler to parse a string or a list of strings.
type StringID ¶ added in v0.17.1
type StringID string
StringID is an IDProvider with constant string id.
type TemplateFuncContext ¶ added in v0.22.0
type TemplateFuncContext struct {
// contains filtered or unexported fields
}
TemplateFuncContext stores context used for processing.
func (TemplateFuncContext) Action ¶ added in v0.22.0
func (ctx TemplateFuncContext) Action() *Action
Action returns an Action related to the template.
func (TemplateFuncContext) Services ¶ added in v0.22.0
func (ctx TemplateFuncContext) Services() *launchr.ServiceManager
Services returns a launchr.ServiceManager for DI.
type TemplateProcessors ¶ added in v0.22.0
type TemplateProcessors struct {
// contains filtered or unexported fields
}
TemplateProcessors handles template processors used on an action load.
func NewTemplateProcessors ¶ added in v0.22.0
func NewTemplateProcessors() *TemplateProcessors
NewTemplateProcessors initializes TemplateProcessors with default functions.
func (*TemplateProcessors) AddTemplateFunc ¶ added in v0.22.0
func (m *TemplateProcessors) AddTemplateFunc(name string, fn any)
AddTemplateFunc registers a template function used on [inputProcessor].
func (*TemplateProcessors) AddValueProcessor ¶ added in v0.22.0
func (m *TemplateProcessors) AddValueProcessor(name string, vp ValueProcessor)
AddValueProcessor adds processor to list of available processors
func (*TemplateProcessors) GetTemplateFuncMap ¶ added in v0.22.0
func (m *TemplateProcessors) GetTemplateFuncMap(ctx TemplateFuncContext) template.FuncMap
GetTemplateFuncMap returns list of template functions used on [inputProcessor].
func (*TemplateProcessors) GetValueProcessors ¶ added in v0.22.0
func (m *TemplateProcessors) GetValueProcessors() map[string]ValueProcessor
GetValueProcessors returns list of available processors
func (*TemplateProcessors) ServiceCreate ¶ added in v0.22.0
func (m *TemplateProcessors) ServiceCreate(_ *launchr.ServiceManager) launchr.Service
ServiceCreate implements launchr.ServiceCreate interface.
func (*TemplateProcessors) ServiceInfo ¶ added in v0.22.0
func (m *TemplateProcessors) ServiceInfo() launchr.ServiceInfo
ServiceInfo implements launchr.Service interface.
type TestCaseValueProcessor ¶ added in v0.17.2
type TestCaseValueProcessor struct {
Name string
Yaml string
ErrInit error
ErrProc error
Args InputParams
Opts InputParams
ExpArgs InputParams
ExpOpts InputParams
}
TestCaseValueProcessor is a common test case behavior for ValueProcessor.
func (TestCaseValueProcessor) Test ¶ added in v0.17.2
func (tt TestCaseValueProcessor) Test(t *testing.T, am Manager, tp *TemplateProcessors)
Test runs the test for ValueProcessor.
type ValueProcessor ¶ added in v0.7.0
type ValueProcessor interface {
IsApplicable(valueType jsonschema.Type) bool
OptionsType() ValueProcessorOptions
Handler(opts ValueProcessorOptions) ValueProcessorHandler
}
ValueProcessor defines an interface for processing a value based on its type and some options.
type ValueProcessorContext ¶ added in v0.17.2
type ValueProcessorContext struct {
ValOrig any // ValOrig is the value before processing.
IsChanged bool // IsChanged indicates if the value was input by user.
Input *Input // Input represents the associated action input in the current context.
DefParam *DefParameter // DefParam is the definition of the currently processed parameter.
Action *Action // Action is the related action definition.
}
ValueProcessorContext is related context data for ValueProcessor.
type ValueProcessorHandler ¶ added in v0.17.2
type ValueProcessorHandler func(v any, ctx ValueProcessorContext) (any, error)
ValueProcessorHandler is an actual implementation of ValueProcessor that processes the incoming value.
type ValueProcessorOptions ¶ added in v0.17.2
type ValueProcessorOptions interface {
Validate() error
}
ValueProcessorOptions is a common type for value processor options
type ValueProcessorOptionsEmpty ¶ added in v0.17.2
type ValueProcessorOptionsEmpty = *GenericValueProcessorOptions[struct{}]
ValueProcessorOptionsEmpty when ValueProcessor doesn't have options.
type ValueProcessorOptionsFields ¶ added in v0.18.0
type ValueProcessorOptionsFields interface {
DecodeFields() any
}
ValueProcessorOptionsFields provides option fields that must be decoded.
type WithFlagsGroup ¶ added in v0.21.0
type WithFlagsGroup struct {
// contains filtered or unexported fields
}
WithFlagsGroup provides a composition with flags utilities.
func (*WithFlagsGroup) GetFlagsGroup ¶ added in v0.21.0
func (c *WithFlagsGroup) GetFlagsGroup() *FlagsGroup
GetFlagsGroup returns flags group
func (*WithFlagsGroup) SetFlagsGroup ¶ added in v0.21.0
func (c *WithFlagsGroup) SetFlagsGroup(group *FlagsGroup)
SetFlagsGroup sets flags group to work with
type WithLogger ¶ added in v0.21.0
type WithLogger struct {
// contains filtered or unexported fields
}
WithLogger provides a composition with log utilities.
func (*WithLogger) Log ¶ added in v0.21.0
func (c *WithLogger) Log() *launchr.Logger
Log implements RuntimeLoggerAware interface
func (*WithLogger) LogWith ¶ added in v0.21.0
func (c *WithLogger) LogWith(attrs ...any) *launchr.Logger
LogWith implements RuntimeLoggerAware interface
func (*WithLogger) SetLogger ¶ added in v0.21.0
func (c *WithLogger) SetLogger(l *launchr.Logger)
SetLogger implements RuntimeLoggerAware interface
type WithTerm ¶ added in v0.21.0
type WithTerm struct {
// contains filtered or unexported fields
}
WithTerm provides a composition with term utilities.
func (*WithTerm) SetTerm ¶ added in v0.21.0
SetTerm implements RuntimeTermAware interface
type YamlDiscoveryStrategy ¶ added in v0.5.4
YamlDiscoveryStrategy is a yaml discovery strategy.
func (YamlDiscoveryStrategy) IsValid ¶ added in v0.5.4
func (y YamlDiscoveryStrategy) IsValid(path string) bool
IsValid implements DiscoveryStrategy.
func (YamlDiscoveryStrategy) Loader ¶ added in v0.5.4
func (y YamlDiscoveryStrategy) Loader(l FileLoadFn, p ...LoadProcessor) Loader
Loader implements DiscoveryStrategy.
type YamlFileLoader ¶ added in v0.17.1
type YamlFileLoader struct {
YamlLoader
FileOpen FileLoadFn // FileOpen lazy loads the content of the file.
}
YamlFileLoader loads action yaml from a file.
func (*YamlFileLoader) Content ¶ added in v0.17.1
func (l *YamlFileLoader) Content() ([]byte, error)
Content implements Loader interface.
func (*YamlFileLoader) Load ¶ added in v0.17.1
func (l *YamlFileLoader) Load(ctx *LoadContext) (res *Definition, err error)
Load implements Loader interface.
type YamlLoader ¶ added in v0.17.1
type YamlLoader struct {
Bytes []byte // Bytes represents yaml content bytes.
Processor LoadProcessor // Processor processes variables inside the file.
// contains filtered or unexported fields
}
YamlLoader loads action yaml from a string.
func (*YamlLoader) Content ¶ added in v0.17.1
func (l *YamlLoader) Content() ([]byte, error)
Content implements Loader interface.
func (*YamlLoader) Load ¶ added in v0.17.1
func (l *YamlLoader) Load(ctx *LoadContext) (res *Definition, err error)
Load implements Loader interface.