Documentation
¶
Overview ¶
Package executor provides secure script execution with Azure context and Key Vault integration. It supports multiple shells (bash, sh, zsh, pwsh, powershell, cmd) and handles environment variable resolution including Azure Key Vault secret references.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Shell specifies the shell to use for execution.
// If empty, shell is auto-detected from script extension or shebang.
// Valid values: bash, sh, zsh, pwsh, powershell, cmd
Shell string
// Interactive enables interactive mode, connecting stdin to the script.
Interactive bool
// StopOnKeyVaultError causes azd exec to fail-fast when any Key Vault reference fails to resolve.
// Default is false (continue resolving other references and run with unresolved values left as-is).
StopOnKeyVaultError bool
// Args are additional arguments to pass to the script.
Args []string
}
Config holds the configuration for script execution. All fields are optional and have sensible defaults.
type ExecutionError ¶
ExecutionError indicates that script execution failed with an exit code.
func (*ExecutionError) Error ¶
func (e *ExecutionError) Error() string
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes scripts with azd context.
func New ¶
New creates a new script executor with the given configuration. Returns a configured Executor ready to execute scripts, or an error if the configuration is invalid (e.g., unknown shell name).
func (*Executor) Execute ¶
Execute runs a script file with azd context. The script path is validated for existence and security. Returns an error if:
- scriptPath is empty
- scriptPath does not exist or is not a regular file
- scriptPath is a directory
- scriptPath contains path traversal attempts (..)
- script execution fails
func (*Executor) ExecuteInline ¶
ExecuteInline runs an inline script command with azd context. The shell is auto-detected based on OS if not specified in config. Returns an error if:
- scriptContent is empty or only whitespace
- shell detection fails
- script execution fails
type InvalidShellError ¶
type InvalidShellError struct {
Shell string
}
InvalidShellError indicates that an invalid shell was specified.
func (*InvalidShellError) Error ¶
func (e *InvalidShellError) Error() string
type ScriptNotFoundError ¶
type ScriptNotFoundError struct {
Path string
}
ScriptNotFoundError indicates that a script file could not be found.
func (*ScriptNotFoundError) Error ¶
func (e *ScriptNotFoundError) Error() string
type ValidationError ¶
ValidationError indicates that input validation failed.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string