Snapshot
Package-level helpers for snapshot artifacts. Access them through the exportedSnapshot value, e.g. m.Snapshot.Create(ctx, ...).
Snapshot.Create()
SnapshotCreateOptions.Name (resolved under the default snapshots directory) and SnapshotCreateOptions.FromSandbox (the sandbox to capture) are both required.
Parameters
ctxcontext.ContextCancellation and deadline.
Name, source sandbox, labels, and integrity options.
Returns
The created artifact on disk.
Example
Example
Snapshot.Open()
Example
Example
s.Verify() for content checks.
Parameters
ctxcontext.ContextCancellation and deadline.
pathOrNamestringBare name (resolved under the default snapshots directory) or artifact directory path.
Returns
The artifact on disk.
Snapshot.Get()
Example
Example
Parameters
ctxcontext.ContextCancellation and deadline.
nameOrDigeststringBare name, manifest digest, or artifact path.
Returns
Index-backed handle.
Snapshot.List()
Example
Example
Returns
All indexed handles.
Snapshot.ListDir()
Parameters
ctxcontext.ContextCancellation and deadline.
dirstringDirectory holding snapshot artifact subdirectories.
Returns
One artifact per parsed subdirectory.
Snapshot.Remove()
Example
Example
force is true.
Parameters
ctxcontext.ContextCancellation and deadline.
pathOrNamestringBare name or artifact path.
forceboolDelete even if the snapshot has indexed children.
Snapshot.Reindex()
Example
Example
dir and rebuild the local index from the artifacts it finds.
Parameters
ctxcontext.ContextCancellation and deadline.
dirstringDirectory to scan for snapshot artifacts.
Returns
uint32
Number of artifacts indexed.
Snapshot.Save()
.tar.zst archive at outPath. Set SnapshotSaveOptions.PlainTar to skip compression.
Parameters
ctxcontext.ContextCancellation and deadline.
nameOrPathstringBare name or artifact path to save.
outPathstringDestination archive path.
Whether to include parents, the base image, and compression.
Example
Example
Snapshot.Load()
dest directory. Pass "" for the default destination.
Parameters
ctxcontext.ContextCancellation and deadline.
archivestringPath to the snapshot archive.
deststringDestination directory, or
"" for the default snapshots directory.Returns
Handle to the loaded snapshot.
Example
Example
SandboxHandle
Snapshots are taken from a metadata handle, so stop the sandbox first and then callGetSandbox.
h.Snapshot()
Snapshot.Save / Snapshot.Load or move the self-contained artifact directory.
Parameters
ctxcontext.ContextCancellation and deadline.
namestringBare name for the artifact.
Returns
The created artifact.
Example
Example
SnapshotArtifact
Returned by Snapshot.Create() · Snapshot.Open() · Snapshot.ListDir() · h.Snapshot() · h.Open()
A snapshot artifact on disk.s.Verify()
Upper.Kind is "not_recorded" when the artifact was created without RecordIntegrity, and "verified" when the recorded value matched.
Returns
Recomputed digest and upper-layer status.
Example
Example
s.Path()
s.Digest()
sha256:...).
s.SizeBytes()
s.ImageRef()
s.ImageManifestDigest()
s.Format()
"raw" or "qcow2".
s.Scope()
SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today; SnapshotScopeResumable is reserved for resumable snapshots.
s.Fstype()
s.Parent()
nil if this snapshot has no parent. Returns a defensive copy.
s.CreatedAt()
s.Labels()
s.SourceSandbox()
nil. Returns a defensive copy.
SnapshotHandle
Returned by Snapshot.Get() · Snapshot.List() · Snapshot.Load()
A snapshot handle backed by the local index.h.Open()
Example
Example
Snapshot.Open on this handle’s path.
Returns
The opened artifact.
h.Remove()
Example
Example
Snapshot.Remove on this handle’s digest.
Parameters
ctxcontext.ContextCancellation and deadline.
forceboolDelete even if the snapshot has indexed children.
h.Digest()
h.Name()
nil. Returns a defensive copy.
h.ParentDigest()
nil. Returns a defensive copy.
h.ImageRef()
h.Format()
"raw" or "qcow2".
h.Scope()
SnapshotScopeDisk ("disk") or SnapshotScopeResumable ("resumable"). Always SnapshotScopeDisk today.
h.SizeBytes()
nil if unknown. Returns a defensive copy.
h.Path()
h.CreatedAt()
Constants
Snapshot scopes
Returned by s.Scope() · h.Scope()
Scope of what a snapshot captures. Every snapshot today is disk-only; the resumable scope (disk plus VM state) is reserved for resumable snapshots.Types
SnapshotCreateOptionsstruct
Accepted by Snapshot.Create()
ConfiguresSnapshot.Create. Name and FromSandbox are both required.
SnapshotSaveOptionsstruct
Accepted by Snapshot.Save()
ConfiguresSnapshot.Save.
SnapshotVerifyReportstruct
Returned by s.Verify()
Result ofVerify.
SnapshotUpperVerifyStatusstruct
Field of SnapshotVerifyReport
Upper-layer integrity details inside aSnapshotVerifyReport.