fslayer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fslayer provides filesystem layer storage and management for snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseKey

func BaseKey(imageRef string, arch string) string

BaseKey generates a cache key for a base image.

func CopyOpKey

func CopyOpKey(src, dst string, contentHash string) string

CopyOpKey generates an operation key for a Copy operation.

func DeleteManifest

func DeleteManifest(dir, cacheKey string) error

DeleteManifest removes a manifest and its associated layers if they're not referenced by other manifests.

func DeriveKey

func DeriveKey(parentKey string, opKey string) string

DeriveKey derives a cache key from a parent key and an operation key. The resulting key is deterministic and uniquely identifies the state after applying the operation to the parent state.

func ListManifests

func ListManifests(dir string) ([]string, error)

ListManifests returns all manifest cache keys in a directory.

func ManifestExists

func ManifestExists(dir, cacheKey string) bool

ManifestExists checks if a manifest exists for the given cache key.

func RunOpKey

func RunOpKey(cmd []string, env []string, workDir string, user string) string

RunOpKey generates an operation key for a Run operation.

func SaveManifest

func SaveManifest(manifest *FSManifest, dir string) error

SaveManifest saves a filesystem snapshot manifest to disk.

func SnapshotOpKey

func SnapshotOpKey(layerHash string) string

SnapshotOpKey generates an operation key for a snapshot with a layer hash.

Types

type FSManifest

type FSManifest struct {
	Version      int      `json:"version"`
	CacheKey     string   `json:"cacheKey"`
	Layers       []string `json:"layers"`       // Layer hashes in order (base first)
	BaseImageRef string   `json:"baseImageRef"` // Original OCI image reference
	Architecture string   `json:"architecture"`
}

FSManifest describes a persisted filesystem snapshot.

func LoadManifest

func LoadManifest(dir, cacheKey string) (*FSManifest, error)

LoadManifest loads a filesystem snapshot manifest from disk.

type Layer

type Layer struct {
	Hash         string // SHA256 hash of the layer contents
	IndexPath    string // Path to .idx file
	ContentsPath string // Path to .contents file
}

Layer represents a stored filesystem layer.

func ReadLayer

func ReadLayer(dir, hash string) (*Layer, error)

ReadLayer reads a layer from disk.

func WriteLayer

func WriteLayer(data *LayerData, dir string) (*Layer, error)

WriteLayer writes a LayerData to disk using the archive format. Returns the Layer metadata including the content hash.

type LayerData

type LayerData struct {
	Entries []LayerEntry
}

LayerData holds all modifications in a filesystem layer.

type LayerEntry

type LayerEntry struct {
	Path    string
	Kind    LayerEntryKind
	Mode    fs.FileMode
	UID     int
	GID     int
	ModTime time.Time
	Size    int64
	Data    []byte // For regular files, the content; for symlinks, the target
}

LayerEntry represents a single entry in a filesystem layer.

type LayerEntryKind

type LayerEntryKind uint8

LayerEntryKind describes the type of layer entry.

const (
	LayerEntryRegular LayerEntryKind = iota
	LayerEntryDirectory
	LayerEntrySymlink
	LayerEntryDeleted // Whiteout marker
)

Jump to

Keyboard shortcuts

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