parser

package
v0.56.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Git is the git seam used by the parser for git includes. Package var (not injected) — the parser is function-organized; reassign in tests.

This is the seam replacement for the engine call that previously hid behind the `git` import alias (git.CloneOrUpdateRepository): parser must have zero git ENGINE dependencies; the remaining gitpkg calls are URL semantics only (IsGitURL, ExpandShorthand, ParseGitURL), which move to internal/giturl in phase 5.

Functions

This section is empty.

Types

type Package

type Package struct {
	Name           string
	Version        string
	PackageManager string // e.g., "apt", "snap", defaults to system default
	Stage          string // e.g., "build", "runtime" — used by container templates
}

type Rule

type Rule struct {
	ID       string // Unique identifier for this rule
	Action   string // "install", "uninstall", "clone", "mkdir", "decrypt", "asdf", "mise", "homebrew", "ollama", "known_hosts", "gpg_key", "sudoers", "schedule", "shell", or "authorized_keys"
	Packages []Package
	OSList   []string
	After    []string // List of IDs or package names this rule depends on
	Group    string

	// Clone-specific fields
	CloneURL     string // Git repository URL
	ClonePath    string // Destination path for cloned repository
	Branch       string // Branch to clone (optional, defaults to repo default)
	CloneWorkdir bool   // If true, clone with .git intact (for active development repos)
	CloneBare    bool   // If true, clone bare into <path>/.git with branches as worktrees (git worktree / worktrunk layout)

	// ASDF-specific fields
	AsdfPackages []string // List of "plugin@version" for asdf (e.g., "nodejs@21.4.0")

	// Mise-specific fields
	MisePackages []string // List of "tool@version" for mise (e.g., "node@20", "python@3.11")
	MisePath     string   // Optional project directory for local (non-global) install

	// Sudoers-specific fields
	SudoersUser string // User to grant passwordless sudo (resolved at runtime if empty)

	// Schedule-specific fields
	SchedulePreset string // "daily", "weekly", "hourly", or ""
	ScheduleCron   string // raw cron expression (overrides preset)
	ScheduleSource string // file path, directory, or repo passed to blueprint apply

	// Decrypt-specific fields
	DecryptFile       string // Source encrypted file
	DecryptPath       string // Destination path for decrypted file
	DecryptPasswordID string // Password ID to use for decryption

	// KnownHosts-specific fields
	KnownHosts    string // SSH host to add to known_hosts (hostname or IP)
	KnownHostsKey string // Key type for ssh-keyscan (ed25519, ecdsa, rsa, etc.) - optional

	// Mkdir-specific fields
	Mkdir      string // Directory path to create
	MkdirPerms string // Octal permissions (e.g., "755", "700") - optional

	// GPG Key-specific fields
	GPGKeyURL  string // URL to the GPG key file
	GPGKeyring string // Name of the keyring (without path or .gpg extension)
	GPGDebURL  string // Debian repository URL

	// Homebrew-specific fields
	HomebrewPackages []string // List of "formula[@version]" for homebrew (e.g., "node@20", "git")
	HomebrewCasks    []string // List of cask names for brew install --cask (e.g., "visual-studio-code")

	// Dotfiles-specific fields
	DotfilesURL    string   // Git repository URL for dotfiles
	DotfilesBranch string   // Optional branch to checkout
	DotfilesPath   string   // Local clone path (auto-derived: ~/.blueprint/dotfiles/<repo-name>)
	DotfilesSkip   []string // Top-level entries to skip (in addition to built-ins)

	// Ollama-specific fields
	OllamaModels []string // List of model names for ollama (e.g., "llama3", "codellama")

	// Download-specific fields
	DownloadURL       string // Source URL
	DownloadPath      string // Destination path
	DownloadOverwrite bool   // If true, always re-download
	DownloadPerms     string // Optional octal permissions (e.g. "0755")

	// Run-specific fields
	RunCommand string // Shell command to execute
	RunUnless  string // Skip if this command exits 0 (idempotency check)
	RunUndo    string // Execute when rule is removed from blueprint
	RunSudo    bool   // If true, prepend sudo to the command

	// Run-sh-specific fields
	RunShURL string // URL to the script to download and execute

	// Shell-specific fields
	ShellName string // Shell name or path to set as default login shell

	// AuthorizedKeys-specific fields
	AuthorizedKeysFile       string // Plain file path containing public key(s)
	AuthorizedKeysEncrypted  string // Encrypted file containing public key(s)
	AuthorizedKeysPasswordID string // Password ID for decryption

	// Var-specific fields
	VarName     string // Variable name
	VarDefault  string // Default value (empty string means required)
	VarRequired bool   // True when no default was provided

	// Render-specific fields
	RenderTemplate string   // Template file or directory (local path or @github: shorthand)
	RenderOutput   string   // Output destination (defaults to ".")
	RenderVars     []string // KEY=VALUE variable overrides
}

func Parse

func Parse(content string) ([]Rule, error)

Parse parses content without include support

func ParseAsdfRule

func ParseAsdfRule(line string) (*Rule, error)

func ParseAuthorizedKeysRule

func ParseAuthorizedKeysRule(line string) (*Rule, error)

func ParseCloneRule

func ParseCloneRule(line string) (*Rule, error)

func ParseDecryptRule

func ParseDecryptRule(line string) (*Rule, error)

func ParseDotfilesRule

func ParseDotfilesRule(line string) (*Rule, error)

func ParseDownloadRule

func ParseDownloadRule(line string) (*Rule, error)

func ParseFile

func ParseFile(filePath string) ([]Rule, error)

ParseFile parses a file with include support

func ParseGPGKeyRule

func ParseGPGKeyRule(line string) (*Rule, error)

func ParseHomebrewRule

func ParseHomebrewRule(line string) (*Rule, error)

func ParseInstallRule

func ParseInstallRule(line string) (*Rule, error)

func ParseKnownHostsRule

func ParseKnownHostsRule(line string) (*Rule, error)

func ParseMiseRule

func ParseMiseRule(line string) (*Rule, error)

func ParseMkdirRule

func ParseMkdirRule(line string) (*Rule, error)

func ParseOllamaRule

func ParseOllamaRule(line string) (*Rule, error)

func ParseRenderRule

func ParseRenderRule(line string) (*Rule, error)

ParseVarRule parses "var NAME [default]" lines. If no default is provided the variable is required at render time. ParseRenderRule parses a render action line. Syntax: render <template> [output: <path>] [var: KEY=VALUE ...] template may be a local path or @github: shorthand. output defaults to "." (current directory).

func ParseRunRule

func ParseRunRule(line string) (*Rule, error)

func ParseRunShRule

func ParseRunShRule(line string) (*Rule, error)

func ParseScheduleRule

func ParseScheduleRule(line string) (*Rule, error)

func ParseShellRule

func ParseShellRule(line string) (*Rule, error)

func ParseSudoersRule

func ParseSudoersRule(line string) (*Rule, error)

func ParseVarRule

func ParseVarRule(line string) (*Rule, error)

Jump to

Keyboard shortcuts

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