lock

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package lock models pacto.lock: the committed, deterministic record of the resolved dependency + reference closure.

Index

Constants

View Source
const CurrentLockVersion = 1

CurrentLockVersion is the schema version this build writes.

View Source
const FileName = "pacto.lock"

FileName is the lockfile name, alongside pacto.yaml.

Variables

This section is empty.

Functions

func HashFS

func HashFS(fsys fs.FS) (string, error)

HashFS returns a deterministic "sha256:<hex>" digest over every regular file in fsys, independent of walk order. Used for local (non-OCI) dependencies.

Types

type ConflictError

type ConflictError struct{ Service string }

ConflictError: the closure requires a service at two incompatible versions.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type DriftError

type DriftError struct{ Name, Locked, Current string }

DriftError: a locked OCI digest no longer matches the current resolution.

func (*DriftError) Error

func (e *DriftError) Error() string

type Entry

type Entry struct {
	Name        string   `yaml:"name" json:"name"`
	Source      string   `yaml:"source" json:"source"` // "oci" or "local"
	Ref         string   `yaml:"ref,omitempty" json:"ref,omitempty"`
	Path        string   `yaml:"path,omitempty" json:"path,omitempty"`
	Constraint  string   `yaml:"constraint,omitempty" json:"constraint,omitempty"`
	Version     string   `yaml:"version,omitempty" json:"version,omitempty"`
	Digest      string   `yaml:"digest,omitempty" json:"digest,omitempty"`
	ContentHash string   `yaml:"contentHash,omitempty" json:"contentHash,omitempty"`
	DependsOn   []string `yaml:"dependsOn,omitempty" json:"dependsOn,omitempty"`
}

Entry is one resolved dependency in the closure.

type LocalDriftError

type LocalDriftError struct{ Name, Locked, Current string }

LocalDriftError: a local dependency's content hash changed.

func (*LocalDriftError) Error

func (e *LocalDriftError) Error() string

type Lock

type Lock struct {
	LockVersion  int         `yaml:"lockVersion" json:"lockVersion"`
	Pacto        PactoInfo   `yaml:"pacto" json:"pacto"`
	Root         RootInfo    `yaml:"root" json:"root"`
	Dependencies []Entry     `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
	References   []Reference `yaml:"references,omitempty" json:"references,omitempty"`
}

Lock is the root document of pacto.lock.

func Parse

func Parse(data []byte) (*Lock, error)

Parse decodes pacto.lock bytes and validates the schema version.

func (*Lock) Dependency

func (l *Lock) Dependency(name string) (*Entry, bool)

Dependency returns the entry with the given name.

func (*Lock) Marshal

func (l *Lock) Marshal() ([]byte, error)

Marshal serializes the lock deterministically (sorted entries, sorted edges).

func (*Lock) Reference

func (l *Lock) Reference(kind, name string) (*Reference, bool)

Reference returns the reference with the given kind and name.

type MissingError

type MissingError struct{ Path string }

MissingError: a lock was required (e.g. --check) but none exists.

func (*MissingError) Error

func (e *MissingError) Error() string

type PactoInfo

type PactoInfo struct {
	Version string `yaml:"version" json:"version"`
}

PactoInfo records the CLI version that produced the lock.

type Reference

type Reference struct {
	Kind        string `yaml:"kind" json:"kind"` // "config" or "policy"
	Name        string `yaml:"name" json:"name"`
	Source      string `yaml:"source" json:"source"`
	Ref         string `yaml:"ref,omitempty" json:"ref,omitempty"`
	Path        string `yaml:"path,omitempty" json:"path,omitempty"`
	Version     string `yaml:"version,omitempty" json:"version,omitempty"`
	Digest      string `yaml:"digest,omitempty" json:"digest,omitempty"`
	ContentHash string `yaml:"contentHash,omitempty" json:"contentHash,omitempty"`
}

Reference is one resolved config/policy reference. Config/policy sources carry no compatibility constraint (unlike dependencies), so a reference has no Constraint field.

type RootInfo

type RootInfo struct {
	Name    string `yaml:"name" json:"name"`
	Version string `yaml:"version" json:"version"`
}

RootInfo identifies the contract the lock belongs to.

type StaleError

type StaleError struct{ Detail string }

StaleError: pacto.yaml and pacto.lock disagree on which deps/refs exist.

func (*StaleError) Error

func (e *StaleError) Error() string

type UnresolvedError

type UnresolvedError struct {
	Ref    string
	Reason string
}

UnresolvedError: a ref could not be resolved while building the lock.

func (*UnresolvedError) Error

func (e *UnresolvedError) Error() string

Jump to

Keyboard shortcuts

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