Documentation
¶
Index ¶
- Constants
- Variables
- func GetShellArgs(shell, script string) (binary string, args []string, err error)
- func ModuleNameFromPath(modulePath string) string
- func SupportedShells() []string
- type EnvBuilder
- func (b *EnvBuilder) Build() []string
- func (b *EnvBuilder) WithBinary(binary string) *EnvBuilder
- func (b *EnvBuilder) WithConfigPath(configPath string) *EnvBuilder
- func (b *EnvBuilder) WithGitRoot(gitRoot string) *EnvBuilder
- func (b *EnvBuilder) WithModuleName(moduleName string) *EnvBuilder
- func (b *EnvBuilder) WithModulePath(modulePath string) *EnvBuilder
- type Runner
- type ShellConfig
- type TaskConfig
Constants ¶
const ( EnvGitRoot = "MOTF_GIT_ROOT" EnvModulePath = "MOTF_MODULE_PATH" EnvModuleName = "MOTF_MODULE_NAME" EnvConfigPath = "MOTF_CONFIG_PATH" EnvBinary = "MOTF_BINARY" )
Environment variable names for built-in variables
const ( ScopeModule = "module" ScopeRoot = "root" ScopeGit = "git" )
Task scope constants
const DefaultShell = "sh"
DefaultShell is the default shell when none is specified
Variables ¶
var Shells = map[string]ShellConfig{ "sh": {Binary: "sh", Args: []string{"-c"}}, "bash": {Binary: "bash", Args: []string{"-c"}}, "pwsh": {Binary: "pwsh", Args: []string{"-Command"}}, "cmd": {Binary: "cmd", Args: []string{"/C"}}, }
Shells is the registry of supported shells
Functions ¶
func GetShellArgs ¶
GetShellArgs returns the binary and arguments needed to execute a script with the given shell. Returns an error if the shell is not supported.
func ModuleNameFromPath ¶ added in v0.8.0
ModuleNameFromPath extracts the module name from an absolute module path. It returns the last component of the path (e.g., "/path/to/storage-account" -> "storage-account").
func SupportedShells ¶
func SupportedShells() []string
SupportedShells returns a sorted list of supported shell names
Types ¶
type EnvBuilder ¶ added in v0.8.0
type EnvBuilder struct {
// contains filtered or unexported fields
}
EnvBuilder constructs environment variables for task execution. It starts with the current process environment and adds MOTF_* built-in variables.
func NewEnvBuilder ¶ added in v0.8.0
func NewEnvBuilder() *EnvBuilder
NewEnvBuilder creates a new EnvBuilder with empty built-in variables.
func (*EnvBuilder) Build ¶ added in v0.8.0
func (b *EnvBuilder) Build() []string
Build returns the complete environment for task execution. It includes the current process environment plus all MOTF_* built-in variables.
func (*EnvBuilder) WithBinary ¶ added in v0.8.0
func (b *EnvBuilder) WithBinary(binary string) *EnvBuilder
WithBinary sets the MOTF_BINARY variable.
func (*EnvBuilder) WithConfigPath ¶ added in v0.8.0
func (b *EnvBuilder) WithConfigPath(configPath string) *EnvBuilder
WithConfigPath sets the MOTF_CONFIG_PATH variable.
func (*EnvBuilder) WithGitRoot ¶ added in v0.8.0
func (b *EnvBuilder) WithGitRoot(gitRoot string) *EnvBuilder
WithGitRoot sets the MOTF_GIT_ROOT variable.
func (*EnvBuilder) WithModuleName ¶ added in v0.8.0
func (b *EnvBuilder) WithModuleName(moduleName string) *EnvBuilder
WithModuleName sets the MOTF_MODULE_NAME variable. If empty, it will be derived from the module path if available.
func (*EnvBuilder) WithModulePath ¶ added in v0.8.0
func (b *EnvBuilder) WithModulePath(modulePath string) *EnvBuilder
WithModulePath sets the MOTF_MODULE_PATH variable.
type Runner ¶
type Runner struct {
Tasks map[string]*TaskConfig
Env []string // Environment variables for task execution (includes MOTF_* built-ins)
}
Runner executes custom tasks
func NewRunner ¶
func NewRunner(tasks map[string]*TaskConfig, env []string) *Runner
NewRunner creates a new task runner with the given task definitions
func (*Runner) GetTask ¶
func (r *Runner) GetTask(name string) *TaskConfig
GetTask returns the task config for the given name, or nil if not found
type ShellConfig ¶
ShellConfig defines how to invoke a shell
type TaskConfig ¶
type TaskConfig struct {
Description string `yaml:"description"`
Shell string `yaml:"shell"`
Command string `yaml:"command"`
Scope string `yaml:"scope"`
}
TaskConfig represents a custom task definition
func (*TaskConfig) EffectiveScope ¶ added in v0.9.0
func (tc *TaskConfig) EffectiveScope() string
EffectiveScope returns the task's scope, defaulting to "module" if unset.
func (*TaskConfig) ValidateScope ¶ added in v0.9.0
func (tc *TaskConfig) ValidateScope() error
ValidateScope returns an error if the scope value is not recognized.