localscan

package
v0.33.13 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func Scan(root string) (*Node, error)

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

func ScanVerified(root string) (*Node, error)

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

func (n *Node) VolumeCount() int

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

type ScanLimits struct {
	MaxDepth int
	MaxNodes int
}

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

type SkippedDirs struct {
	Paths []string
	Total int
}

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.

Jump to

Keyboard shortcuts

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