engine

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecutableName = "blueprint"

ExecutableName is the name to use in user-facing command hints (e.g. "Run to fix"). Defaults to "blueprint"; set to "go run ./cmd/blueprint" when running via go run.

Functions

func Check

func Check(file, tmplPath, against string, preferSSH bool, cliVars map[string]string)

Check parses a blueprint, renders tmplPath (file or directory), and compares each rendered result against the corresponding committed file. against is a file path in single-file mode, or a directory root in directory mode. In directory mode with no --against, targets are resolved next to each template. Exits 0 when all are identical, 1 when any differ.

func DoctorCheck

func DoctorCheck(fix bool, verbose bool)

DoctorCheck reads ~/.blueprint/status.json, reports all issues found, and optionally rewrites the file with issues fixed when fix is true. When verbose is true, prints progress messages for each check as it runs. Exits with code 1 if issues are found and fix is false.

func EncryptFile

func EncryptFile(filePath string, passwordID string)

func Export

func Export(file string, format string, output string, preferSSH bool)

Export generates a shell script from a blueprint file. format is "bash" or "sh". output is "" for stdout or a file path.

func Get

func Get(file, action, key string, preferSSH bool, cliVars map[string]string)

Get extracts a single value from a blueprint and prints it to stdout.

func PrintDiff

func PrintDiff(blueprintFile string, preferSSH bool)

PrintDiff compares the desired state in the blueprint file against the installed state in status.json and prints what would be added or removed on the next apply.

func PrintHistory

func PrintHistory(runNumber int, stepNumber int, since, blueprintFilter string)

PrintHistory displays the history of a specific run If runNumber is 0, displays the latest run If stepNumber is >= 0, displays only that specific step since and blueprintFilter are optional filters applied to the run listing.

func PrintHistoryStats

func PrintHistoryStats(since, blueprintFilter string)

PrintHistoryStats prints aggregate stats from history, optionally filtered.

func PrintPS

func PrintPS()

PrintPS displays the current blueprint process state

func PrintSlow

func PrintSlow(topN int)

PrintSlow displays the slowest rule executions from history. topN limits the results (default 10). If lastOnly is true, only the latest run is shown.

func PrintStatus

func PrintStatus()

func Render

func Render(file, tmplPath, output string, preferSSH bool, cliVars map[string]string)

Render parses a blueprint and renders tmplPath (file or directory) against it. When tmplPath is a directory all *.tmpl files are rendered recursively; files whose basename starts with "_" are skipped. output is used only for single-file mode ("" → stdout, path → file).

func RenderWithRules

func RenderWithRules(rules []parser.Rule, tmplPath, output string, preferSSH bool, cliVars map[string]string) error

RenderWithRules renders tmplPath using pre-parsed rules. Used by the render blueprint action so the rules don't need to be re-parsed from a file.

func Run

func Run(file string, dry bool) int

func RunWithSkip

func RunWithSkip(file string, dry bool, skipGroup string, skipID string, onlyID string, skipDecrypt bool, preferSSH bool, noStatus bool, cliVars map[string]string) int

RunWithSkip executes the blueprint and returns an exit code: 0 = success (all rules applied or dry-run completed), 1 = one or more rules failed or a fatal error occurred.

func Validate

func Validate(file string, preferSSH bool)

Validate parses a blueprint file (or git URL) and runs semantic checks. It prints all issues found and exits with code 1 if any are found.

Types

type ExecutionRecord

type ExecutionRecord struct {
	Timestamp  string `json:"timestamp"`
	Blueprint  string `json:"blueprint"`
	OS         string `json:"os"`
	Command    string `json:"command"`
	Status     string `json:"status"`
	DurationMs int64  `json:"duration_ms,omitempty"`
	Output     string `json:"output,omitempty"`
	Error      string `json:"error,omitempty"`
}

type ProcessState

type ProcessState struct {
	PID           int               `json:"pid"`
	BlueprintFile string            `json:"blueprint_file"`
	OS            string            `json:"os"`
	TotalRules    int               `json:"total_rules"`
	CurrentRule   int               `json:"current_rule"`
	CurrentAction string            `json:"current_action"`
	HandlerState  map[string]string `json:"handler_state,omitempty"`
	StartedAt     string            `json:"started_at"`
	RuleStartedAt string            `json:"rule_started_at"`
}

ProcessState represents the current execution state written to ~/.blueprint/ps.json

type RealCommandExecutor

type RealCommandExecutor struct{}

RealCommandExecutor implements platform.CommandExecutor for production use

func (*RealCommandExecutor) Execute

func (r *RealCommandExecutor) Execute(cmd string) (string, error)

Execute runs a real command on the system

type TemplateData

type TemplateData = renderer.TemplateData

TemplateData is a type alias for renderer.TemplateData to preserve the engine package's public API for any callers that use engine.BuildTemplateData.

func BuildTemplateData

func BuildTemplateData(rules []parser.Rule, cliVars map[string]string) *TemplateData

BuildTemplateData constructs a TemplateData from a slice of rules. cliVars are values passed via --var KEY=VALUE and take precedence over defaults defined in the blueprint.

Jump to

Keyboard shortcuts

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