lockfile

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLockFile indicates the lock file is malformed or missing required fields.
	ErrInvalidLockFile = errors.New("invalid lock file")

	// ErrLockFileNil indicates the lock file is nil.
	ErrLockFileNil = errors.New("lock file is nil")

	// ErrToolMissingVersion indicates a tool entry is missing the version field.
	ErrToolMissingVersion = errors.New("tool missing version")

	// ErrToolNoPlatforms indicates a tool entry has no platform entries.
	ErrToolNoPlatforms = errors.New("tool has no platform entries")

	// ErrPlatformNoURL indicates a platform entry is missing the URL field.
	ErrPlatformNoURL = errors.New("platform entry missing URL")

	// ErrPlatformNoChecksum indicates a platform entry is missing the checksum field.
	ErrPlatformNoChecksum = errors.New("platform entry missing checksum")

	// ErrToolEntryNil indicates a tool entry in the lock file is nil.
	ErrToolEntryNil = errors.New("tool entry is nil")

	// ErrPlatformEntryNil indicates a platform entry in the lock file is nil.
	ErrPlatformEntryNil = errors.New("platform entry is nil")
)

Error definitions for the lockfile package.

Functions

func Save

func Save(filePath string, lockFile *LockFile) error

Save writes the lock file to disk, updating metadata fields and creating parent directories if needed. The function updates GeneratedAt, AtmosVersion, and Platform fields in the lockfile metadata to reflect the current environment. It creates the parent directory structure if it doesn't exist (with 0o755 permissions) and writes the lockfile with 0o644 permissions. Returns an error if the lockfile is nil, marshaling fails, directory creation fails, or file writing fails.

func Verify

func Verify(filePath string) error

Verify verifies the integrity and validity of the lock file at the specified path. It loads the lockfile from disk and performs comprehensive validation including: version field checks, metadata validation, and per-tool validation (version presence, platform entries existence, and platform-specific URL/checksum requirements). Returns nil if the lockfile is valid, or an error describing the validation failure (e.g., missing required fields, nil entries, empty values).

Types

type LockFile

type LockFile struct {
	Version  int              `yaml:"version"`
	Tools    map[string]*Tool `yaml:"tools"`
	Metadata LockFileMetadata `yaml:"metadata"`
}

LockFile represents the toolchain.lock.yaml structure.

func Load

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

Load loads a lock file from disk.

func New

func New() *LockFile

New creates a new empty lock file.

func (*LockFile) GetOrCreateTool

func (lf *LockFile) GetOrCreateTool(tool string) *Tool

GetOrCreateTool gets or creates a tool entry in the lock file.

func (*LockFile) RemoveTool

func (lf *LockFile) RemoveTool(tool string)

RemoveTool removes a tool from the lock file.

type LockFileMetadata

type LockFileMetadata struct {
	GeneratedAt     string `yaml:"generated_at"` // RFC3339
	AtmosVersion    string `yaml:"atmos_version"`
	Platform        string `yaml:"platform"` // GOOS_GOARCH
	LockFileVersion int    `yaml:"lock_file_version"`
}

LockFileMetadata contains metadata about the lock file.

type PlatformEntry

type PlatformEntry struct {
	URL      string `yaml:"url"`
	Checksum string `yaml:"checksum"`
	Size     int64  `yaml:"size"`
}

PlatformEntry represents platform-specific download information.

type Tool

type Tool struct {
	Version     string                    `yaml:"version"`
	Source      string                    `yaml:"source,omitempty"`
	Platforms   map[string]*PlatformEntry `yaml:"platforms"`
	BinaryName  string                    `yaml:"binary_name,omitempty"`
	InstalledAt string                    `yaml:"installed_at"` // RFC3339
}

Tool represents a locked tool entry.

Jump to

Keyboard shortcuts

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