lock

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package lock reads and writes .fullsend/lock.yaml files that pin all resolved remote dependencies (URLs and integrity hashes) for reproducible harness execution. A lock file is produced by `fullsend lock <harness>` and consumed by the resolver to skip re-resolution when dependencies have not changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(path string, lf *LockFile) error

Save writes the lock file to path atomically (write to temp, then rename). Parent directories are created as needed. The file is written with 0o644 permissions (world-readable) because lock files are meant to be committed to version control, unlike cache files which use 0o600.

Save mutates lf.Version to currentVersion when it is zero.

Types

type DependencyEntry

type DependencyEntry struct {
	Field          string            `yaml:"field"`
	URL            string            `yaml:"url"`
	SHA256         string            `yaml:"sha256"`
	Type           string            `yaml:"type,omitempty"`  // "file" or "directory"; empty treated as "file"
	Files          []FileEntry       `yaml:"files,omitempty"` // manifest of files (directory deps only)
	FetchedAt      time.Time         `yaml:"fetched_at"`
	TransitiveDeps []DependencyEntry `yaml:"transitive_deps,omitempty"`
}

DependencyEntry records a single resolved remote resource.

type FileEntry added in v0.17.0

type FileEntry struct {
	Path   string `yaml:"path"`
	SHA256 string `yaml:"sha256"`
}

FileEntry records one file within a directory dependency.

type HarnessLock

type HarnessLock struct {
	Source       string            `yaml:"source"`
	SHA256       string            `yaml:"sha256"`
	ResolvedAt   time.Time         `yaml:"resolved_at"`
	Dependencies []DependencyEntry `yaml:"dependencies"`
}

HarnessLock records resolved dependencies for one harness.

func (*HarnessLock) IsStale

func (hl *HarnessLock) IsStale(sourceHash string) bool

IsStale returns true if the harness source file has changed since the lock entry was generated. It compares the harness file's SHA256 against the stored hash. sourceHash is the SHA256 of the current harness file content. Returns true for a nil receiver.

func (*HarnessLock) LookupDep

func (hl *HarnessLock) LookupDep(url string) *DependencyEntry

LookupDep searches the dependency list (including transitive deps, depth-first) for the given URL and returns the matching entry or nil. The returned pointer references the live slice — mutations update the underlying Dependencies. Returns nil for a nil receiver.

type LockFile

type LockFile struct {
	Version     int                    `yaml:"version"`
	GeneratedAt time.Time              `yaml:"generated_at"`
	Harnesses   map[string]HarnessLock `yaml:"harnesses"`
}

LockFile is the top-level structure of .fullsend/lock.yaml.

func Load

func Load(path string) (*LockFile, error)

Load reads a lock file from path. Returns nil (no error) if the file does not exist.

func (*LockFile) HarnessNames

func (lf *LockFile) HarnessNames() []string

HarnessNames returns the sorted list of harness names in the lock file.

func (*LockFile) Lookup

func (lf *LockFile) Lookup(harnessName string) *HarnessLock

Lookup returns the HarnessLock entry for the named harness, or nil if not found. Returns nil for a nil receiver. The returned pointer is a snapshot — mutations do not update the LockFile map. Use SetHarness to modify entries.

func (*LockFile) SetHarness

func (lf *LockFile) SetHarness(name string, hl HarnessLock)

SetHarness adds or replaces the lock entry for the named harness. Intended for use by the lock file generator (fullsend lock); callers should use Save to persist changes. No-op on a nil receiver.

Jump to

Keyboard shortcuts

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