Documentation
¶
Index ¶
- Variables
- func DefaultRegistryPath() string
- func ExtractByType(data []byte, distType, destDir, packageName string) error
- func ExtractGzip(data []byte, destDir string) error
- func ExtractTar(r io.Reader, destDir string) error
- func ExtractXz(data []byte, destDir string) error
- func ExtractZip(data []byte, destDir string) error
- func HashBytes(data []byte) string
- func HashFile(path string) (string, error)
- func RegisterProject(path string, entry ProjectEntry) error
- func ResolvePath(flagValue, envValue string) string
- func ShardPrefix(hash string) string
- func StripTopLevelDir(dir string) error
- func WriteFileAtomic(path string, data []byte, perm os.FileMode) error
- type FileEntry
- type GCResult
- type Manifest
- type ProjectEntry
- type ProjectRegistry
- type Store
- func (s *Store) EnsureDirectories() error
- func (s *Store) EnsureMetadata() error
- func (s *Store) FileExists(hash string) bool
- func (s *Store) FilePath(hash string) string
- func (s *Store) ManifestExists(name, version string) bool
- func (s *Store) ManifestPath(name, version string) string
- func (s *Store) MetadataPath() string
- func (s *Store) ReadManifest(name, version string) (*Manifest, error)
- func (s *Store) StoreFile(srcPath, hash string, executable bool) error
- func (s *Store) TmpDir() string
- func (s *Store) WriteManifest(m *Manifest) error
- type StoreMetadata
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyArchive = errors.New("empty archive (no files after extraction)")
ErrEmptyArchive is returned when an archive contains no files.
Functions ¶
func DefaultRegistryPath ¶
func DefaultRegistryPath() string
DefaultRegistryPath returns ~/.allegro/projects.json.
func ExtractByType ¶
ExtractByType extracts an archive based on dist.type.
func ExtractGzip ¶
ExtractGzip decompresses gzip then extracts tar.
func ExtractTar ¶
ExtractTar extracts a tar archive from a reader to destDir.
func ExtractZip ¶
ExtractZip extracts a zip archive to destDir.
func RegisterProject ¶
func RegisterProject(path string, entry ProjectEntry) error
RegisterProject adds or updates a project entry in the registry.
func ResolvePath ¶
ResolvePath returns the store directory path based on precedence: flagValue > envValue > default (~/.allegro/store).
func ShardPrefix ¶
ShardPrefix returns the first 2 hex characters of a hash.
func StripTopLevelDir ¶
StripTopLevelDir detects if all files share a common top-level directory and moves them up if so.
Types ¶
type FileEntry ¶
type FileEntry struct {
Path string `json:"path"`
Hash string `json:"hash"`
Size int64 `json:"size"`
Executable bool `json:"executable"`
}
FileEntry represents a single file in a package manifest.
type GCResult ¶
type GCResult struct {
ManifestsPruned int
FilesPruned int
BytesFreed int64
StaleWarned int
ProjectsRemoved int
}
GCResult holds the outcome of a garbage collection run.
func GarbageCollect ¶
GarbageCollect performs smart prune with project awareness (Unix: with flock).
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
DistHash string `json:"dist_hash"`
Files []FileEntry `json:"files"`
StoredAt time.Time `json:"stored_at"`
}
Manifest represents a package version's manifest in the CAS.
type ProjectEntry ¶
type ProjectEntry struct {
Path string `json:"path"`
LastInstall time.Time `json:"last_install"`
LockHash string `json:"lock_hash"`
Packages map[string]string `json:"packages"`
}
ProjectEntry represents a single project in the registry.
type ProjectRegistry ¶
type ProjectRegistry struct {
Projects []ProjectEntry `json:"projects"`
}
ProjectRegistry represents ~/.allegro/projects.json.
func ReadRegistry ¶
func ReadRegistry(path string) (*ProjectRegistry, error)
ReadRegistry reads ~/.allegro/projects.json. Returns empty registry if missing.
type Store ¶
type Store struct {
Root string // e.g. ~/.allegro/store
}
Store manages the content-addressable store.
func (*Store) EnsureDirectories ¶
EnsureDirectories creates the store directory tree if missing.
func (*Store) EnsureMetadata ¶
EnsureMetadata creates allegro.json if missing, validates store version.
func (*Store) FileExists ¶
FileExists checks if a CAS file exists.
func (*Store) ManifestExists ¶
ManifestExists checks if a manifest exists for a package version.
func (*Store) ManifestPath ¶
ManifestPath returns the path for a package manifest.
func (*Store) MetadataPath ¶
MetadataPath returns the path to allegro.json.
func (*Store) ReadManifest ¶
ReadManifest reads a package manifest from disk.
func (*Store) WriteManifest ¶
WriteManifest writes a package manifest atomically.
type StoreMetadata ¶
type StoreMetadata struct {
StoreVersion int `json:"store_version"`
CreatedAt time.Time `json:"created_at"`
}
StoreMetadata represents ~/.allegro/allegro.json.