Documentation
¶
Index ¶
- Constants
- Variables
- func ListArchive(ctx context.Context, zipFile *os.File, zipFileLen int64) ([]string, error)
- func OverlappingPaths(paths []string) (i, j int, ok bool)
- func ResolveConfigPath(path string) (string, error)
- func Validate(archiveFile string, archiveSize int64) error
- type ArchiveInfo
- type ChecksumSHA256
- type Manifest
- type Mapping
Constants ¶
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 )
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 ¶
var ErrUnrecognizedFormat = errors.New("unrecognized cache archive format")
ErrUnrecognizedFormat is returned when an archive has no readable manifest
Functions ¶
func ListArchive ¶
func OverlappingPaths ¶
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 ¶
ResolveConfigPath normalises a configured target path to the absolute, cleaned path it refers to on this machine, using the same classification as PathsToMappings.
Types ¶
type ArchiveInfo ¶
type ArchiveInfo struct {
ArchivePath string
Sha256sum string
Size int64
WrittenBytes int64
WrittenEntries int64
Duration time.Duration
}
func BuildArchive ¶
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
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 ¶
PathsToMappings resolves each configured target path into a Mapping.
func (Mapping) ResolvedPath ¶
ResolvedPath is the absolute path on this machine the target resolves to.