archive

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ManifestPath is the reserved archive entry.
	// Extraction reads it but never writes it to disk.
	ManifestPath = ".buildkite/cache-manifest.json"
	// ManifestVersion is the archive format version this agent reads and writes.
	ManifestVersion = 2
)
View Source
const (
	// AnchorHome marks paths configured with a leading "~" (or "~/"). Restore
	// re-expands them against the restoring environment's home directory.
	AnchorHome = "~"
	// AnchorCWD marks relative paths. Restore resolves them against the job's
	// working directory.
	AnchorCWD = "."
)

Anchor identifies where a mapping's stored paths are re-resolved at restore time. It is deliberately a symbol rather than a resolved path so caches stay portable.

Variables

View Source
var ErrUnrecognizedFormat = errors.New("unrecognized cache archive format")

ErrUnrecognizedFormat is returned when an archive has no readable manifest

Functions

func ListArchive

func ListArchive(ctx context.Context, zipFile *os.File, zipFileLen int64) ([]string, error)

func OverlappingPaths

func OverlappingPaths(paths []string) (i, j int, ok bool)

OverlappingPaths returns the indices of the first pair of resolved paths that are nested or equal — by lexical and canonical spelling, case-folded on case-insensitive filesystems — or ok=false if none overlap.

func ResolveConfigPath

func ResolveConfigPath(path string) (string, error)

ResolveConfigPath normalises a configured target path to the absolute, cleaned path it refers to on this machine, using the same classification as PathsToMappings.

func Validate

func Validate(archiveFile string, archiveSize int64) error

Validate reports whether a downloaded archive is a readable v2 archive, returning ErrUnrecognizedFormat otherwise. It checks that the manifest is present and readable — not that the entry bodies are intact. Content-digest verification is out of scope here.

Types

type ArchiveInfo

type ArchiveInfo struct {
	ArchivePath    string
	Sha256sum      string
	Size           int64
	WrittenBytes   int64
	WrittenEntries int64
	Duration       time.Duration
}

func BuildArchive

func BuildArchive(ctx context.Context, paths []string, key string) (*ArchiveInfo, error)

BuildArchive builds a cache archive for the given target paths.

func ExtractFiles

func ExtractFiles(ctx context.Context, zipFile *os.File, zipFileLen int64, paths []string) (*ArchiveInfo, error)

ExtractFiles extracts a cache archive to the given target paths.

type ChecksumSHA256

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

func NewChecksumSHA256

func NewChecksumSHA256(f io.Writer) *ChecksumSHA256

func (*ChecksumSHA256) Sum

func (c *ChecksumSHA256) Sum() string

func (*ChecksumSHA256) Write

func (c *ChecksumSHA256) Write(p []byte) (n int, err error)

implement the io.WriteCloser interface

type Manifest

type Manifest struct {
	Version  int               `json:"version"`
	Mappings map[string]string `json:"mappings"`
}

Manifest maps each namespace in an archive to its anchor.

type Mapping

type Mapping struct {
	// Path is the target path exactly as configured.
	Path string
	// Namespace is the archive prefix that isolates this mapping's entries ("_0").
	Namespace string
	// Anchor is the portable symbol stored in the manifest (see consts above).
	Anchor string
	// contains filtered or unexported fields
}

Mapping describes how one configured target path maps into an archive: a numbered namespace ("_0", "_1", ...) whose entries are relative to the anchor.

func PathsToMappings

func PathsToMappings(paths []string) ([]Mapping, error)

PathsToMappings resolves each configured target path into a Mapping.

func (Mapping) ResolvedPath

func (m Mapping) ResolvedPath() string

ResolvedPath is the absolute path on this machine the target resolves to.

Jump to

Keyboard shortcuts

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