resolver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(ast *rbast.RunbookAST, targetEnv string, cliVars map[string]string, envFilePath string, opts Options) error

Resolve resolves all template variables in the AST, filters blocks by target environment, stores both original and resolved commands on each node, and scans every resolved variable value for dangerous shell metacharacters.

Types

type DotEnvProvider

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

DotEnvProvider resolves secrets from a .env file.

func NewDotEnvProvider

func NewDotEnvProvider(path string) (*DotEnvProvider, error)

NewDotEnvProvider creates a DotEnvProvider by reading the given .env file.

func (*DotEnvProvider) Name

func (p *DotEnvProvider) Name() string

Name returns the provider name.

func (*DotEnvProvider) Resolve

func (p *DotEnvProvider) Resolve(key string) (string, error)

Resolve returns the value for the given key from the .env file.

type EnvProvider

type EnvProvider struct{}

EnvProvider resolves secrets from environment variables with a RUNBOOK_ prefix.

func (*EnvProvider) Name

func (p *EnvProvider) Name() string

Name returns the provider name.

func (*EnvProvider) Resolve

func (p *EnvProvider) Resolve(key string) (string, error)

Resolve returns the value of the RUNBOOK_<key> environment variable.

type MetacharError

type MetacharError struct {
	Warnings []MetacharWarning
}

MetacharError is returned by Resolve when --strict mode is enabled and dangerous metacharacters are detected in resolved variable values, or when the user declines to continue in interactive mode.

func (*MetacharError) Error

func (e *MetacharError) Error() string

type MetacharWarning

type MetacharWarning struct {
	VarName   string // template variable name, e.g. "version"
	Value     string // resolved value, e.g. "1.0.0; rm -rf /"
	Metachar  string // detected metacharacter display label, e.g. ";"
	BlockType string // "step", "check", "rollback", or "wait"
	BlockName string // block name attribute, e.g. "deploy"
	FilePath  string // source .runbook file path
	Line      int    // source line number
}

MetacharWarning describes a dangerous metacharacter found in a resolved variable value.

type Options

type Options struct {
	// NonInteractive skips interactive prompts; metacharacter warnings are
	// printed but execution continues.
	NonInteractive bool
	// DryRun shows metacharacter warnings but does not prompt.
	DryRun bool
	// Strict treats any metacharacter warning as a hard error and returns a
	// *MetacharError without prompting (intended for CI pipelines).
	Strict bool
	// Stderr is the writer for warning output. Defaults to os.Stderr.
	Stderr io.Writer
	// PromptInput is the reader for interactive prompts. Defaults to os.Stdin.
	PromptInput io.Reader
}

Options configures shell metacharacter scanning behaviour during resolution.

type SecretProvider

type SecretProvider interface {
	// Resolve returns the value for the given key.
	Resolve(key string) (string, error)
	// Name returns a human-readable name for this provider.
	Name() string
}

SecretProvider resolves secret values by key.

Jump to

Keyboard shortcuts

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