tree

package
v0.1.0-dev.20260129030150 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tree provides deployment tree building for writ.

Index

Constants

This section is empty.

Variables

View Source
var DelegateFiles = []string{
	"packages-manifest.yaml",
	"packages-manifest.json",
	"packages.manifest",
}

DelegateFiles are filenames that should be delegated to lore. packages-manifest.{yaml,json} is the canonical format. packages.manifest is supported for backward compatibility.

Functions

This section is empty.

Types

type BuildConfig

type BuildConfig struct {
	// SourceRoot is the source directory for single-source mode.
	// Deprecated: Use Sources for multi-layer support.
	SourceRoot string

	// TargetRoot is the target directory (e.g., $HOME).
	// Used as default when Sources is empty.
	TargetRoot string

	// Sources are the layer sources for multi-source mode.
	// If empty, falls back to single-source mode using SourceRoot/TargetRoot.
	Sources []LayerSource

	// Projects to include (e.g., ["all", "noblefactor"]).
	Projects []string

	// Segments for platform matching.
	Segments segment.Segments
}

BuildConfig holds configuration for building a deployment graph.

type BuildResult

type BuildResult struct {
	// Graph is the execution graph ready for the engine.
	Graph *engine.Graph

	// SourceRoot is the source root directory (for single-source mode).
	SourceRoot string

	// TargetRoot is the target root directory.
	TargetRoot string

	// Sources are the layer sources processed (for multi-source mode).
	Sources []LayerSource

	// Projects included in this build.
	Projects []string

	// MatchedDirs are the directories that matched the segments.
	MatchedDirs []segment.MatchResult

	// Collisions are files where a more specific source overrode a less specific one.
	Collisions []Collision

	// NodeLayers tracks which layer each node came from (node.ID → layer name).
	NodeLayers map[string]string
}

BuildResult contains the built execution graph and build-time metadata.

func Build

func Build(cfg BuildConfig) (*BuildResult, error)

Build creates an execution graph from the given configuration. Supports both single-source mode (SourceRoot) and multi-source mode (Sources).

func (*BuildResult) CompactString

func (r *BuildResult) CompactString() string

CompactString returns a compact summary of the build result.

func (*BuildResult) DelegateCount

func (r *BuildResult) DelegateCount() int

DelegateCount returns the number of delegate nodes.

func (*BuildResult) FileCount

func (r *BuildResult) FileCount() int

FileCount returns the number of files in the graph.

func (*BuildResult) HasCollisions

func (r *BuildResult) HasCollisions() bool

HasCollisions returns true if there were file collisions during build.

func (*BuildResult) LinkCount

func (r *BuildResult) LinkCount() int

LinkCount returns the number of simple symlink files.

func (*BuildResult) SecretCount

func (r *BuildResult) SecretCount() int

SecretCount returns the number of encrypted files.

func (*BuildResult) String

func (r *BuildResult) String() string

String returns a human-readable representation of the build result.

func (*BuildResult) TemplateCount

func (r *BuildResult) TemplateCount() int

TemplateCount returns the number of template files.

type Collision

type Collision struct {
	// Target is the relative target path that had a collision.
	Target string

	// Winner is the source that won (more specific or higher layer).
	Winner string

	// WinnerSpecificity is the number of suffixes on the winning directory.
	WinnerSpecificity int

	// WinnerLayer is the layer of the winner (empty for single-source mode).
	WinnerLayer string

	// Loser is the source that was overridden (less specific or lower layer).
	Loser string

	// LoserSpecificity is the number of suffixes on the losing directory.
	LoserSpecificity int

	// LoserLayer is the layer of the loser (empty for single-source mode).
	LoserLayer string
}

Collision records when a more specific file overrides a less specific one.

type LayerSource

type LayerSource struct {
	Layer      string // "base", "team", or "personal"
	Path       string // Repo root path
	Order      int    // 0=base, 1=team, 2=personal (for precedence sorting)
	SourceRoot string // Full path to source directory (e.g., /path/to/repo/Home)
	TargetRoot string // Target root (e.g., $HOME or /)
	TargetName string // "System" or "Home"
}

LayerSource represents a repository layer with its path and precedence order.

type Operation

type Operation int

Operation represents a file processing operation.

const (
	// OpLink creates a symlink from target to source.
	OpLink Operation = iota

	// OpExpand processes a .template file with Go text/template.
	OpExpand

	// OpCopy writes content to target (used after expand or decrypt).
	OpCopy

	// OpDecrypt decrypts a .age file using age encryption.
	OpDecrypt

	// OpDelegate passes the file to another tool (e.g., lore for packages.manifest).
	OpDelegate
)

func (Operation) String

func (o Operation) String() string

String returns the operation name.

type Operations

type Operations []Operation

Operations is a slice of operations for JSON marshaling.

func ProcessingPipeline

func ProcessingPipeline(filename string) (targetName string, ops Operations)

ProcessingPipeline determines operations from a filename. Extensions are processed outside-in (like .tar.gz).

Examples:

"foo"                → "foo",              [link]
"foo.template"       → "foo",              [expand, copy]
"foo.age"            → "foo",              [decrypt, copy]
"foo.template.age"   → "foo",              [decrypt, expand, copy]
"packages.manifest"  → "packages.manifest" [delegate]

func (Operations) HasCopy

func (ops Operations) HasCopy() bool

HasCopy returns true if the operations include a copy operation. Files with copy are written to disk (templates, secrets) rather than symlinked.

func (Operations) HasDelegate

func (ops Operations) HasDelegate() bool

HasDelegate returns true if the operations include a delegate operation.

func (Operations) Strings

func (ops Operations) Strings() []string

Strings returns the operation names.

Jump to

Keyboard shortcuts

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