Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 (*LockFile) GetOrCreateTool ¶
GetOrCreateTool gets or creates a tool entry in the lock file.
func (*LockFile) RemoveTool ¶
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.