lockfile

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLockFileName is the default name for lock files
	DefaultLockFileName = "Berksfile.go.lock"
	// RubyLockFileName is the Ruby Berkshelf compatible lock file name
	RubyLockFileName = "Berksfile.lock"
)

Variables

This section is empty.

Functions

func ExtractDirectDependencies

func ExtractDirectDependencies(berksfilePath string, groups []string) ([]string, error)

ExtractDirectDependencies extracts the direct dependencies from a Berksfile

Types

type CookbookLock

type CookbookLock struct {
	Version      string            `json:"version"`
	Dependencies map[string]string `json:"dependencies,omitempty"`
	Source       *SourceInfo       `json:"source,omitempty"`
}

CookbookLock represents a locked cookbook with its resolved dependencies

type LockFile

type LockFile struct {
	Revision    int                    `json:"revision"`
	GeneratedAt time.Time              `json:"generated_at"`
	Sources     map[string]*SourceLock `json:"sources"`
}

LockFile represents a Berksfile.lock file structure

func FromJSON

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

FromJSON deserializes a lock file from JSON

func NewLockFile

func NewLockFile() *LockFile

NewLockFile creates a new lock file with current revision

func (*LockFile) AddCookbook

func (lf *LockFile) AddCookbook(sourceKey string, cookbook *berkshelf.Cookbook, sourceInfo *SourceInfo)

AddCookbook adds a cookbook to the lock file under the specified source key

func (*LockFile) GetCookbook

func (lf *LockFile) GetCookbook(name string) (*CookbookLock, string, bool)

GetCookbook retrieves a cookbook from the lock file

func (*LockFile) GetRevision

func (lf *LockFile) GetRevision() int

GetRevision returns the lock file format revision

func (*LockFile) HasCookbook

func (lf *LockFile) HasCookbook(name string) bool

HasCookbook checks if a cookbook exists in the lock file

func (*LockFile) IsOutdated

func (lf *LockFile) IsOutdated(maxAge time.Duration) bool

IsOutdated checks if the lock file is older than the specified duration

func (*LockFile) ListCookbooks

func (lf *LockFile) ListCookbooks() map[string]*CookbookLock

ListCookbooks returns all cookbooks in the lock file

func (*LockFile) ToJSON

func (lf *LockFile) ToJSON() ([]byte, error)

ToJSON serializes the lock file to JSON

func (*LockFile) ToRubyFormat

func (lf *LockFile) ToRubyFormat(dependencies []string) ([]byte, error)

ToRubyFormat serializes the lock file to Ruby Berkshelf format

func (*LockFile) UpdateGeneratedAt

func (lf *LockFile) UpdateGeneratedAt()

UpdateGeneratedAt updates the generation timestamp

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles lock file operations for both JSON and Ruby formats

func NewManager

func NewManager(workDir string) *Manager

NewManager creates a new lock file manager

func NewManagerWithPath

func NewManagerWithPath(lockFilePath string) *Manager

NewManagerWithPath creates a new lock file manager with custom path

func (*Manager) Backup

func (m *Manager) Backup() error

Backup creates a backup of the lock file

func (*Manager) Exists

func (m *Manager) Exists() bool

Exists checks if the lock file exists

func (*Manager) Generate

func (m *Manager) Generate(resolution *resolver.Resolution) (*LockFile, error)

Generate creates a lock file from a resolution result

func (*Manager) GenerateBoth

func (m *Manager) GenerateBoth(resolution *resolver.Resolution, dependencies []string) error

GenerateBoth creates and saves both JSON and Ruby format lock files

func (*Manager) GetPath

func (m *Manager) GetPath() string

GetPath returns the JSON lock file path

func (*Manager) GetRubyPath

func (m *Manager) GetRubyPath() string

GetRubyPath returns the Ruby lock file path

func (*Manager) IsOutdated

func (m *Manager) IsOutdated() (bool, error)

IsOutdated checks if the lock file needs updating

func (*Manager) Load

func (m *Manager) Load() (*LockFile, error)

Load reads and parses the lock file

func (*Manager) Remove

func (m *Manager) Remove() error

Remove deletes the JSON lock file

func (*Manager) RemoveBoth

func (m *Manager) RemoveBoth() error

RemoveBoth deletes both lock files

func (*Manager) RemoveRuby

func (m *Manager) RemoveRuby() error

RemoveRuby deletes the Ruby lock file

func (*Manager) RubyExists

func (m *Manager) RubyExists() bool

RubyExists checks if the Ruby lock file exists

func (*Manager) Save

func (m *Manager) Save(lockFile *LockFile) error

Save writes the lock file to disk in JSON format

func (*Manager) SaveBoth

func (m *Manager) SaveBoth(lockFile *LockFile, dependencies []string) error

SaveBoth writes both JSON and Ruby format lock files

func (*Manager) SaveRuby

func (m *Manager) SaveRuby(lockFile *LockFile, dependencies []string) error

SaveRuby writes the lock file in Ruby format to disk

func (*Manager) Update

func (m *Manager) Update(resolution *resolver.Resolution) error

Update updates an existing lock file with new resolution data

func (*Manager) UpdateBoth

func (m *Manager) UpdateBoth(resolution *resolver.Resolution, dependencies []string) error

UpdateBoth updates both JSON and Ruby format lock files

func (*Manager) Validate

func (m *Manager) Validate() error

Validate checks if the lock file is valid and consistent

type SourceInfo

type SourceInfo struct {
	Type   string `json:"type"`
	URL    string `json:"url,omitempty"`
	Path   string `json:"path,omitempty"`
	Branch string `json:"branch,omitempty"`
	Tag    string `json:"tag,omitempty"`
	Ref    string `json:"ref,omitempty"`
}

SourceInfo contains additional source information for the cookbook

type SourceLock

type SourceLock struct {
	Type      string                   `json:"type,omitempty"`
	URL       string                   `json:"url,omitempty"`
	Cookbooks map[string]*CookbookLock `json:"cookbooks"`
}

SourceLock represents a cookbook source in the lock file

Jump to

Keyboard shortcuts

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