scripting

package
v1.25.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package scripting provides secure script and command execution with Azure context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultShell

func DefaultShell() string

DefaultShell returns the platform-appropriate default shell.

func DetectShellFromFile

func DetectShellFromFile(filePath string) string

DetectShellFromFile returns the appropriate shell for executing a script file based on its extension.

func IsSupportedShell

func IsSupportedShell(shell string) bool

IsSupportedShell returns whether the given shell name is a supported shell.

func ValidateShell

func ValidateShell(shell string) error

ValidateShell checks whether shell is a known, supported shell name. An empty string is considered valid (auto-detect).

Types

type Config

type Config struct {
	Shell       string
	Interactive bool
	Args        []string
	// Env overrides the child process environment. When set, the child process
	// receives exactly these variables instead of inheriting os.Environ().
	// This prevents secrets from leaking into the parent process via os.Setenv.
	Env []string
}

Config holds the configuration for script execution.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the Config has valid values.

type ExecutionError

type ExecutionError struct {
	ExitCode int
	Shell    string
	IsInline bool
}

ExecutionError indicates that script execution failed with a specific exit code.

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor executes scripts and commands with azd context.

func New

func New(config Config) (*Executor, error)

New creates a new script executor with the given configuration.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, scriptPath string) error

Execute runs a script file.

func (*Executor) ExecuteDirect

func (e *Executor) ExecuteDirect(ctx context.Context, command string, args []string) error

ExecuteDirect runs a command directly without shell wrapping, preserving exact argv semantics. This is the preferred mode for "run a program with azd env".

func (*Executor) ExecuteInline

func (e *Executor) ExecuteInline(ctx context.Context, scriptContent string) error

ExecuteInline runs an inline script command.

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

type ValidationError struct {
	Field  string
	Reason string
}

ValidationError indicates that input validation failed.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL