lockfile

package
v0.14.11 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOrUpdateAsset

func AddOrUpdateAsset(lockFilePath string, ast *Asset) error

AddOrUpdateAsset adds or updates an asset in the lock file Replaces any existing asset with the same name@version

func Marshal

func Marshal(lockFile *LockFile) ([]byte, error)

Marshal converts a lock file to TOML bytes

func RemoveAsset

func RemoveAsset(lockFilePath string, name, version string) error

RemoveAsset removes an asset and all its installations from a lock file

func RenameAsset added in v0.14.0

func RenameAsset(lockFilePath string, oldName, newName string) error

RenameAsset renames all entries of an asset in the lock file.

func Write

func Write(lockFile *LockFile, filePath string) error

Write writes a lock file to a file path

Types

type Asset

type Asset struct {
	Name         string       `toml:"name"`
	Version      string       `toml:"version"`
	Type         asset.Type   `toml:"type"`
	Clients      []string     `toml:"clients,omitempty"`
	Dependencies []Dependency `toml:"dependencies,omitempty"`

	// Source (one of these will be present)
	SourceHTTP *SourceHTTP `toml:"source-http,omitempty"`
	SourcePath *SourcePath `toml:"source-path,omitempty"`
	SourceGit  *SourceGit  `toml:"source-git,omitempty"`

	// Installation configurations - array of scope installations
	// If empty, asset is installed globally
	Scopes []Scope `toml:"scopes,omitempty"`
}

Asset represents an asset with its metadata, source, and installation configurations (formerly Artifact)

func FindAsset

func FindAsset(lockFilePath, name string) (*Asset, bool)

FindAsset finds an asset by name in a lock file Returns the asset and true if found, nil and false otherwise

func (*Asset) GetSourceConfig

func (a *Asset) GetSourceConfig() map[string]any

GetSourceConfig returns the source configuration as a map for generic handling

func (*Asset) GetSourceType

func (a *Asset) GetSourceType() string

GetSourceType returns the type of source for this asset

func (*Asset) IsGlobal

func (a *Asset) IsGlobal() bool

IsGlobal returns true if asset is installed globally (no scope restrictions)

func (*Asset) Key

func (a *Asset) Key() string

Key returns a unique key for the asset (name@version)

func (*Asset) MatchesClient

func (a *Asset) MatchesClient(clientName string) bool

MatchesClient returns true if the asset is compatible with the given client

func (*Asset) String

func (a *Asset) String() string

String returns a string representation of the asset

func (*Asset) Validate

func (a *Asset) Validate() error

Validate validates a single asset

type Dependency

type Dependency struct {
	Name    string `toml:"name"`
	Version string `toml:"version,omitempty"`
}

Dependency represents a dependency reference

type LockFile

type LockFile struct {
	LockVersion string  `toml:"lock-version"`
	Version     string  `toml:"version"`
	CreatedBy   string  `toml:"created-by"`
	Assets      []Asset `toml:"assets"`
}

LockFile represents the complete lock file structure

func Parse

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

Parse parses a lock file from bytes Supports both new "assets"/"scopes" and old "artifacts"/"repositories" field names

func ParseFile

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

ParseFile parses a lock file from a file path

func (*LockFile) GroupByScope

func (lf *LockFile) GroupByScope() map[string][]*Asset

GroupByScope returns all assets grouped by their scope An asset can appear in multiple scopes

func (*LockFile) Validate

func (lf *LockFile) Validate() error

Validate validates the entire lock file

func (*LockFile) ValidateDependencies

func (lf *LockFile) ValidateDependencies() error

ValidateDependencies checks for circular dependencies using DFS

type Scope

type Scope struct {
	Repo  string   `toml:"repo"`            // Repository URL
	Paths []string `toml:"paths,omitempty"` // Specific paths within repo (if empty, entire repo)
}

Scope represents where an asset is installed within a repository (formerly Repository)

func (*Scope) GetScopeType

func (s *Scope) GetScopeType() ScopeType

GetScopeType returns the scope type for this scope entry - If paths is empty/nil, it's repo-scoped (entire repository) - If paths has entries, it's path-scoped (specific paths within repository)

func (*Scope) Validate

func (s *Scope) Validate() error

Validate validates a Scope entry

type ScopeType

type ScopeType string

ScopeType represents the scope of an installation

const (
	ScopeGlobal ScopeType = "global"
	ScopeRepo   ScopeType = "repo"
	ScopePath   ScopeType = "path"
)

type ScopedAsset

type ScopedAsset struct {
	Asset     *Asset
	ScopeDesc string // "Global", repo URL, or "repo:path"
}

ScopedAsset represents an asset with its scope information (formerly ScopedArtifact)

type SourceGit

type SourceGit struct {
	URL          string `toml:"url"`
	Ref          string `toml:"ref"`
	Subdirectory string `toml:"subdirectory,omitempty"`
}

SourceGit represents a Git repository source for an asset

func (*SourceGit) Validate

func (s *SourceGit) Validate() error

Validate validates a Git source

type SourceHTTP

type SourceHTTP struct {
	URL        string            `toml:"url"`
	Hashes     map[string]string `toml:"hashes"`
	Size       int64             `toml:"size,omitempty"`
	UploadedAt *time.Time        `toml:"uploaded-at,omitempty"`
}

SourceHTTP represents an HTTP source for an asset

func (*SourceHTTP) Validate

func (s *SourceHTTP) Validate() error

Validate validates an HTTP source

type SourcePath

type SourcePath struct {
	Path string `toml:"path"`
}

SourcePath represents a local path source for an asset

func (*SourcePath) Validate

func (s *SourcePath) Validate() error

Validate validates a path source

Jump to

Keyboard shortcuts

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