Documentation
¶
Overview ¶
Package localscan discovers and parses an offline snapshot archive directory written by d8 snapshot download. It reads each node's snapshot.yaml and returns an in-memory Node tree with identity and volume metadata populated. The package is fully offline: it never contacts a cluster.
Index ¶
- Variables
- func ScanVerifiedWithOptionsReportingSkips(root string, options archive.SnapshotYAMLReadOptions) (*Node, SkippedDirs, error)
- type Node
- func Scan(root string) (*Node, error)
- func ScanVerified(root string) (*Node, error)
- func ScanVerifiedWithLimitsAndOptions(root string, limits ScanLimits, options archive.SnapshotYAMLReadOptions) (*Node, error)
- func ScanVerifiedWithOptions(root string, options archive.SnapshotYAMLReadOptions) (*Node, error)
- func ScanWithLimits(root string, limits ScanLimits) (*Node, error)
- func ScanWithLimitsAndOptions(root string, limits ScanLimits, options archive.SnapshotYAMLReadOptions) (*Node, error)
- func ScanWithOptions(root string, options archive.SnapshotYAMLReadOptions) (*Node, error)
- type ScanLimits
- type SkippedDirs
Constants ¶
This section is empty.
Variables ¶
var ErrScanBudget = errors.New("local snapshot scan budget exceeded")
ErrScanBudget is returned when an archive tree exceeds a configured scan limit.
Functions ¶
func ScanVerifiedWithOptionsReportingSkips ¶
func ScanVerifiedWithOptionsReportingSkips( root string, options archive.SnapshotYAMLReadOptions, ) (*Node, SkippedDirs, error)
ScanVerifiedWithOptionsReportingSkips verifies every node under an explicit snapshot.yaml compatibility policy exactly like ScanVerifiedWithOptions, additionally reporting archive child directories skipped for carrying no snapshot.yaml (see treeScanner.recordSkippedDir).
Types ¶
type Node ¶
type Node struct {
// Kind is the kind of the snapshot CR recorded in snapshot.yaml
// (e.g. "Snapshot", "DemoVirtualDiskSnapshot", "VolumeSnapshot").
Kind string
// Name is the metadata.name of the snapshot CR.
Name string
// Namespace is the namespace of the snapshot CR.
// Empty for cluster-scoped resources.
Namespace string
// Path is the directory path relative to the scanned root directory.
// The root node has Path == ".".
Path string
// Volumes lists the captured PVC volumes owned by this node, as recorded
// in snapshot.yaml. Empty for aggregator or manifest-only nodes.
Volumes []archive.VolumeInfo
// Children are the nested snapshot nodes discovered under this node's
// snapshots/ subdirectory. Nil when the subdirectory is absent.
Children []*Node
// YAML is the full parsed snapshot.yaml for this node.
YAML archive.SnapshotYAML
}
Node represents a single snapshot node discovered in an offline archive directory tree. Each node corresponds to one directory produced by d8 snapshot download, containing a snapshot.yaml and optional child nodes under a snapshots/ subdirectory.
func Scan ¶
Scan walks the archive directory rooted at root, reads each node's snapshot.yaml via archive.ReadSnapshotYAML, and returns the root Node with its nested children tree fully populated.
A missing snapshots/ subdirectory in any node yields zero children for that node and is not an error. A non-directory root, or a root whose snapshot.yaml cannot be read, yields a wrapped error.
func ScanVerified ¶
ScanVerified walks an archive with the default traversal limits and verifies every node's content checksum and structural metadata before returning the tree.
func ScanVerifiedWithLimitsAndOptions ¶
func ScanVerifiedWithLimitsAndOptions( root string, limits ScanLimits, options archive.SnapshotYAMLReadOptions, ) (*Node, error)
ScanVerifiedWithLimitsAndOptions verifies every node subject to explicit traversal limits and snapshot.yaml compatibility policy.
func ScanVerifiedWithOptions ¶
func ScanVerifiedWithOptions( root string, options archive.SnapshotYAMLReadOptions, ) (*Node, error)
ScanVerifiedWithOptions verifies every node under an explicit snapshot.yaml compatibility policy.
func ScanWithLimits ¶
func ScanWithLimits(root string, limits ScanLimits) (*Node, error)
ScanWithLimits scans an archive tree subject to explicit traversal limits.
func ScanWithLimitsAndOptions ¶
func ScanWithLimitsAndOptions( root string, limits ScanLimits, options archive.SnapshotYAMLReadOptions, ) (*Node, error)
ScanWithLimitsAndOptions scans with explicit traversal and snapshot.yaml compatibility policy.
func ScanWithOptions ¶
func ScanWithOptions( root string, options archive.SnapshotYAMLReadOptions, ) (*Node, error)
ScanWithOptions scans an archive under an explicit snapshot.yaml compatibility policy.
func (*Node) VolumeCount ¶
VolumeCount returns the total number of captured volumes owned by n and all of its descendants. Volume ownership lives in the node that actually captured the data (a domain disk/VM-snapshot node or an orphan-PVC leaf), never in an aggregator, so a plain len(n.Volumes) on the root undercounts any archive whose aggregator itself owns no data.
type ScanLimits ¶
ScanLimits bounds the number and depth of archive nodes visited by ScanWithLimits. The root is at depth zero and counts toward MaxNodes.
func DefaultScanLimits ¶
func DefaultScanLimits() ScanLimits
DefaultScanLimits returns the traversal limits used by Scan: at most 10,000 nodes and 64 child directories below the root.
type SkippedDirs ¶
SkippedDirs reports archive child directories a scan skipped because they carry no snapshot.yaml — leftovers of an interrupted-and-resumed download redirected to a collision path (see archive.CollisionNodeDir), not scannable nodes. Paths is truncated to maxReportedSkippedDirs; Total counts every skip regardless of truncation.