Documentation
¶
Overview ¶
Package deps downloads, verifies, and reports status for local VM dependencies.
Index ¶
- Constants
- Variables
- func PopulateComponentsZotStore(ctx context.Context, destDir string, manifest *ComponentsManifest, ...) error
- type BootArtifact
- type BootInfo
- type ComponentImage
- type ComponentImageFilter
- type Components
- type ComponentsManifest
- type Dependency
- type DownloadEvent
- type DownloadEventType
- type DownloadOptions
- type Item
- type ItemFilter
- type Manager
- func (m *Manager) CachedSeedSnapshotPath(name, version string) (string, error)
- func (m *Manager) CachedSeedsVersion() (string, error)
- func (m *Manager) CachedTemplateChart(name string) (TemplateChart, string, error)
- func (m *Manager) CachedTemplateChartPath(name string) (string, error)
- func (m *Manager) CheckUpdateNudge(ctx context.Context, kind, arch string) string
- func (m *Manager) ComponentsCacheDir() string
- func (m *Manager) ComponentsHistoricalManifestCachePath(raw []byte) string
- func (m *Manager) ComponentsImagesCacheDir() string
- func (m *Manager) ComponentsManifestCacheDir() string
- func (m *Manager) ComponentsManifestCachePath() string
- func (m *Manager) Download(kind, arch string, opts DownloadOptions) error
- func (m *Manager) EnsureSeedSnapshot(ctx context.Context, name, version string, client *http.Client) (string, error)
- func (m *Manager) EnsureVMConfigManifestCached(kind, arch string) (*Manifest, error)
- func (m *Manager) IsStale(kind, arch string, threshold time.Duration) bool
- func (m *Manager) ReadCachedManifest(kind, arch string) (*Manifest, []byte, error)
- func (m *Manager) ReadCachedSeedsManifest() (*SeedsManifest, []byte, error)
- func (m *Manager) ReadCachedTemplatesManifest() (*TemplatesManifest, []byte, error)
- func (m *Manager) SeedSnapshotCachePath(name, version, filename string) string
- func (m *Manager) SeedsCacheDir() string
- func (m *Manager) SeedsManifestCacheDir() string
- func (m *Manager) SeedsManifestCachePath() string
- func (m *Manager) SeedsSnapshotsCacheDir() string
- func (m *Manager) Status(kind, arch string) (bool, *Manifest, error)
- func (m *Manager) TemplatesCacheDir() string
- func (m *Manager) TemplatesChartsCacheDir() string
- func (m *Manager) TemplatesManifestCacheDir() string
- func (m *Manager) TemplatesManifestCachePath() string
- func (m *Manager) VMConfigArtifactCachePath(name string, dep Dependency) string
- func (m *Manager) VMConfigArtifactsCacheDir() string
- func (m *Manager) VMConfigCacheDir() string
- func (m *Manager) VMConfigHistoricalManifestCachePath(kind, arch string, raw []byte) string
- func (m *Manager) VMConfigManifestCacheDir() string
- func (m *Manager) VMConfigManifestCachePath(kind, arch string) string
- func (m *Manager) Verify(kind, arch string) (*Manifest, error)
- func (m *Manager) WriteCachedComponentsManifest(raw []byte) error
- func (m *Manager) WriteCachedManifest(kind, arch string, raw []byte) error
- func (m *Manager) WriteCachedSeedsManifest(raw []byte) error
- func (m *Manager) WriteCachedTemplatesManifest(raw []byte) error
- type Manifest
- type OSInfo
- type SeedSnapshot
- type Seeds
- type SeedsManifest
- type TemplateChart
- type TemplateDependencies
- type Templates
- type TemplatesManifest
- type VMConfig
Constants ¶
const ( TemplateChartTypeOCI = "oci" TemplateChartTypeChart = "chart" )
const DefaultKind = "knc"
DefaultKind is the default instance kind used by the deps download command.
const ImageDepName = "os-image"
ImageDepName is the canonical name used for the OS image dependency. It is also used as the cache subdirectory for the image file (so the image lands at <depsCacheDir>/vmconfig/artifacts/os-image/<version>/<filename>).
const OS = "debian-13"
OS is the OS name encoded in the vmconfig manifest filename.
const VMConfigDepName = "vmconfig"
VMConfigDepName is the canonical dependency name for the vmconfig package tarball. Unreleased manifests generated in vmconfig/manifests contain a stub for this entry; release publishing fills in its URL and digest.
Variables ¶
var ( ErrNotCached = errors.New("manifest not cached") ErrIncomplete = errors.New("deps cache incomplete or corrupt") )
Sentinel errors returned by Verify so callers can distinguish "user just hasn't downloaded yet" from "the cache is corrupted" from real errors.
Functions ¶
func PopulateComponentsZotStore ¶
func PopulateComponentsZotStore(ctx context.Context, destDir string, manifest *ComponentsManifest, progress func(DownloadEvent)) error
PopulateComponentsZotStore downloads component images and writes zot's repository-local OCI layout directly under destDir.
Types ¶
type BootArtifact ¶
type BootArtifact struct {
Partition int `json:"partition"`
Path string `json:"path"`
Digest string `json:"digest"`
}
BootArtifact identifies a file inside the cached OS image.
func (BootArtifact) Valid ¶
func (b BootArtifact) Valid() bool
Valid reports whether this boot artifact points at a specific image file.
type BootInfo ¶
type BootInfo struct {
Cmdline string `json:"cmdline"`
Kernel BootArtifact `json:"kernel"`
Initrd BootArtifact `json:"initrd"`
}
BootInfo describes explicit boot artifacts and the raw kernel command line extracted from the default boot entry for the OS image.
type ComponentImage ¶
type ComponentImage struct {
Component string `json:"component"`
Image string `json:"image"`
Digest string `json:"digest"`
Size int64 `json:"size"`
Platform string `json:"platform,omitempty"`
Index string `json:"index,omitempty"`
Providers []string `json:"providers,omitempty"`
Addon bool `json:"addon,omitempty"`
Cached bool `json:"cached,omitempty"`
}
ComponentImage describes one source image rendered by a component chart.
type ComponentImageFilter ¶
ComponentImageFilter selects component images for download while preserving the full manifest. An empty Providers list matches provider-neutral images only; "all" matches every provider-specific image. Addon images are included only when Addons names the component or contains "all".
type Components ¶
type Components struct {
Version string `json:"version"`
Images []ComponentImage `json:"images"`
}
Components lists rendered component chart images.
type ComponentsManifest ¶
type ComponentsManifest struct {
Components Components `json:"components"`
}
ComponentsManifest is the top-level structure of the manifest generated by podplane/components.
func (*ComponentsManifest) DownloadImageIndexes ¶
func (m *ComponentsManifest) DownloadImageIndexes(filter ComponentImageFilter) []int
DownloadImageIndexes returns the indexes of component images that should be downloaded for the given architecture, provider, and addon selection. Indexes are returned instead of image copies so callers can mark local cache state on the original full manifest.
func (*ComponentsManifest) MarkCached ¶
func (m *ComponentsManifest) MarkCached(index int)
MarkCached marks one component image entry as present in the local cache.
func (*ComponentsManifest) ResetCached ¶
func (m *ComponentsManifest) ResetCached()
ResetCached clears local cache-state markers from all component images.
type Dependency ¶
type Dependency struct {
Version string `json:"version"`
URL string `json:"url"`
Type string `json:"type"`
Digest string `json:"digest"`
Size int64 `json:"size"`
Providers []string `json:"providers,omitempty"`
Cached bool `json:"cached,omitempty"`
}
Dependency describes a single downloadable artifact (binary, archive, deb, or qcow2 image) referenced by the manifest.
func (Dependency) DigestHex ¶
func (d Dependency) DigestHex() string
DigestHex returns just the hex portion of the digest (strips the algo: prefix). Panics if digest is malformed — callers must validate first.
func (Dependency) Filename ¶
func (d Dependency) Filename() string
Filename returns the base filename from the dependency URL (the last path segment), e.g. "runc" from "https://example.com/runc/v1.2.3/runc".
func (Dependency) ParseDigest ¶
func (d Dependency) ParseDigest() (algo string, hex string, err error)
ParseDigest returns the algorithm name and hex checksum from the Digest field. It returns an error if the digest is missing, malformed, or uses an unsupported algorithm. Supported algorithms: sha256, sha512.
func (Dependency) SHA256 ¶
func (d Dependency) SHA256() (string, error)
SHA256 returns the hex sha256 portion of the Digest. It returns an error if the digest is missing or uses any algorithm other than sha256. Deprecated: prefer ParseDigest which supports multiple algorithms.
type DownloadEvent ¶
type DownloadEvent struct {
Type DownloadEventType
Name string
Path string
Message string
Current int64
Total int64
Err error
}
DownloadEvent reports progress for a single dependency artifact, or a top-level status message when Name is empty.
type DownloadEventType ¶
type DownloadEventType string
DownloadEventType describes a dependency download progress event.
const ( DownloadEventStatus DownloadEventType = "status" DownloadEventChecking DownloadEventType = "checking" DownloadEventCached DownloadEventType = "cached" DownloadEventQueued DownloadEventType = "queued" DownloadEventStarted DownloadEventType = "started" DownloadEventProgress DownloadEventType = "progress" DownloadEventDone DownloadEventType = "done" DownloadEventFailed DownloadEventType = "failed" )
type DownloadOptions ¶
type DownloadOptions struct {
DryRun bool
Concurrency int
Client *http.Client
Progress func(DownloadEvent)
Output io.Writer
Archs []string
Providers []string
Addons []string
// SkipCrossArchDependencies skips dependency cache population shared across
// VMConfig architectures, such as component images, template charts, and seed
// snapshots. It is used by callers downloading multiple archs after the first
// arch has already populated those shared caches.
SkipCrossArchDependencies bool
// SkipSeeds skips loading and caching seed manifests and snapshots.
SkipSeeds bool
// VMConfigManifestPath, when set, reads the vmconfig manifest from this
// local JSON file instead of fetching it from the configured deps base URL.
VMConfigManifestPath string
// ComponentsManifestPath, when set, reads the components manifest from this
// local JSON file instead of fetching it from the configured deps base URL.
ComponentsManifestPath string
// TemplatesManifestPath, when set, reads the templates manifest from this
// local JSON file instead of fetching it from the configured deps base URL.
TemplatesManifestPath string
// SeedsManifestPath, when set, reads the seeds manifest from this local JSON
// file instead of fetching it from the configured deps base URL.
SeedsManifestPath string
}
DownloadOptions controls dependency download behavior.
type Item ¶
type Item struct {
Name string
Dep Dependency
}
Item pairs a dependency with its name (the OS image uses ImageDepName). It is the unit returned by Manifest.Items.
func (Item) IsUnreleasedVMConfigStub ¶
IsUnreleasedVMConfigStub reports whether item is the placeholder vmconfig dependency found in checked-in vmconfig/manifests manifests before the release workflow substitutes the real tarball URL and digest.
func (Item) LocalFilename ¶
LocalFilename returns the filename used when the dependency is placed in /opt/podplane/artifacts/ on the VM. The naming convention is <name>.<ext> where ext is derived from Type: binary has no extension, deb → .deb, tar.gz → .tar.gz.
func (Item) Matches ¶
func (it Item) Matches(filter ItemFilter) bool
Matches reports whether the item applies to the selected providers and cache state.
func (Item) ResolveURL ¶
ResolveURL returns the download URL for this item. When baseURL is non-empty (local dev, air-gapped mirrors) URLs are constructed as baseURL/vmconfig/artifacts/<name>/<version>/<filename>. Otherwise the original upstream URL from the manifest is used.
type ItemFilter ¶
ItemFilter selects manifest items by provider and cache state. An empty Providers list matches provider-neutral items only; "all" matches every provider-specific item.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles fetching and caching manifests and the artifacts/images they reference.
func NewManager ¶
NewManager creates a new deps manager.
baseURL is the base URL used to fetch manifest files, e.g. "https://cli.podplane.dev/deps". depsCacheDir is the local deps cache root.
func (*Manager) CachedSeedSnapshotPath ¶
CachedSeedSnapshotPath returns the cached .netsy path for name.
func (*Manager) CachedSeedsVersion ¶
CachedSeedsVersion returns the version in the latest cached seeds manifest.
func (*Manager) CachedTemplateChart ¶
func (m *Manager) CachedTemplateChart(name string) (TemplateChart, string, error)
CachedTemplateChart returns the cached template chart metadata and local Helm chart archive path for name.
func (*Manager) CachedTemplateChartPath ¶
CachedTemplateChartPath returns the cached Helm chart archive path for name.
func (*Manager) CheckUpdateNudge ¶
CheckUpdateNudge attempts to determine whether a newer manifest is available, returning a one-line nudge message for the user. It is designed to be called from a background goroutine and never returns an error: any network/parse failure is folded into a friendly message.
Behaviour:
- Fetches the latest manifest (subject to ctx).
- On success with a different version: returns an "update available" note and refreshes the cached manifest's mtime so we don't re-nag every start.
- On success with the same version: refreshes mtime; returns "".
- On failure (timeout, network error, parse error): returns a "couldn't check, manifest is N days old" note.
func (*Manager) ComponentsCacheDir ¶
ComponentsCacheDir returns the component dependency-domain cache directory.
func (*Manager) ComponentsHistoricalManifestCachePath ¶
ComponentsHistoricalManifestCachePath returns an immutable historical component manifest path.
func (*Manager) ComponentsImagesCacheDir ¶
ComponentsImagesCacheDir returns the component OCI image cache directory.
func (*Manager) ComponentsManifestCacheDir ¶
ComponentsManifestCacheDir returns the component manifest cache directory.
func (*Manager) ComponentsManifestCachePath ¶
ComponentsManifestCachePath returns the path to the cached components manifest.
func (*Manager) Download ¶
func (m *Manager) Download(kind, arch string, opts DownloadOptions) error
Download fetches the latest manifests and downloads any referenced vmconfig artifacts and component images into the local deps cache. The manifests are cached on success so they can be reused later.
If dryRun is true, no network downloads are performed and the manifest is not written to the cache; instead, a summary of what would be downloaded is printed. Items that are already cached (with matching sha256) are skipped in both modes — dry-run only lists files that would actually be downloaded.
func (*Manager) EnsureSeedSnapshot ¶
func (m *Manager) EnsureSeedSnapshot(ctx context.Context, name, version string, client *http.Client) (string, error)
EnsureSeedSnapshot returns a cached seed snapshot, downloading the seeds manifest and snapshot first when needed.
func (*Manager) EnsureVMConfigManifestCached ¶ added in v0.1.2
EnsureVMConfigManifestCached returns the cached vmconfig manifest, fetching and caching it first when the manifest is not already present locally.
func (*Manager) IsStale ¶
IsStale reports whether the cached manifest is older than threshold (or missing entirely). It is a cheap, synchronous check used to gate whether CheckUpdateNudge is worth running.
func (*Manager) ReadCachedManifest ¶
ReadCachedManifest reads and parses the cached manifest JSON. It returns (nil, nil, nil) if the cache file does not exist.
func (*Manager) ReadCachedSeedsManifest ¶
func (m *Manager) ReadCachedSeedsManifest() (*SeedsManifest, []byte, error)
ReadCachedSeedsManifest reads the latest cached seeds manifest.
func (*Manager) ReadCachedTemplatesManifest ¶
func (m *Manager) ReadCachedTemplatesManifest() (*TemplatesManifest, []byte, error)
ReadCachedTemplatesManifest reads the latest cached templates manifest.
func (*Manager) SeedSnapshotCachePath ¶
SeedSnapshotCachePath returns the cache path for a named seed snapshot.
func (*Manager) SeedsCacheDir ¶
SeedsCacheDir returns the seeds dependency-domain cache directory.
func (*Manager) SeedsManifestCacheDir ¶
SeedsManifestCacheDir returns the seeds manifest cache directory.
func (*Manager) SeedsManifestCachePath ¶
SeedsManifestCachePath returns the latest cached seeds manifest path.
func (*Manager) SeedsSnapshotsCacheDir ¶
SeedsSnapshotsCacheDir returns the cached seed snapshot directory.
func (*Manager) Status ¶
Status fetches the latest manifest and compares it byte-for-byte against the cached copy. It returns true if the cached copy is missing or differs from the latest, and also returns the parsed latest manifest.
func (*Manager) TemplatesCacheDir ¶
TemplatesCacheDir returns the templates dependency-domain cache directory.
func (*Manager) TemplatesChartsCacheDir ¶
TemplatesChartsCacheDir returns the cached template chart data directory.
func (*Manager) TemplatesManifestCacheDir ¶
TemplatesManifestCacheDir returns the templates manifest cache directory.
func (*Manager) TemplatesManifestCachePath ¶
TemplatesManifestCachePath returns the latest cached templates manifest path.
func (*Manager) VMConfigArtifactCachePath ¶
func (m *Manager) VMConfigArtifactCachePath(name string, dep Dependency) string
VMConfigArtifactCachePath returns the cache path for a single named vmconfig dependency artifact, e.g. "<depsCacheDir>/vmconfig/artifacts/<name>/<version>/<basename(url)>". This is the single source of truth for where downloaded vmconfig artifacts live; both Download and Verify use it.
func (*Manager) VMConfigArtifactsCacheDir ¶
VMConfigArtifactsCacheDir returns the vmconfig artifact cache directory.
func (*Manager) VMConfigCacheDir ¶
VMConfigCacheDir returns the vmconfig dependency-domain cache directory.
func (*Manager) VMConfigHistoricalManifestCachePath ¶
VMConfigHistoricalManifestCachePath returns an immutable historical manifest path.
func (*Manager) VMConfigManifestCacheDir ¶
VMConfigManifestCacheDir returns the vmconfig manifest cache directory.
func (*Manager) VMConfigManifestCachePath ¶
VMConfigManifestCachePath returns the path to the cached vmconfig manifest JSON file, e.g. ~/.podplane/cache/deps/vmconfig/manifests/vmconfig_knc_debian-13_arm64.json.
func (*Manager) Verify ¶
Verify checks that the cached manifest exists and that every dependency (including the OS image) referenced by it is present in the cache and has the expected sha256. On success it returns the parsed manifest so callers can use it without re-reading from disk.
Returns ErrNotCached if no cached manifest exists. Returns ErrIncomplete (wrapped) if any artifact is missing or has the wrong digest.
func (*Manager) WriteCachedComponentsManifest ¶
WriteCachedComponentsManifest writes historical and latest components manifest JSON bytes.
func (*Manager) WriteCachedManifest ¶
WriteCachedManifest writes historical and latest manifest JSON bytes to the cache.
func (*Manager) WriteCachedSeedsManifest ¶
WriteCachedSeedsManifest writes historical and latest seeds manifests.
func (*Manager) WriteCachedTemplatesManifest ¶
WriteCachedTemplatesManifest writes historical and latest templates manifests.
type Manifest ¶
type Manifest struct {
VMConfig VMConfig `json:"vmconfig"`
}
Manifest is the top-level structure of the vmconfig manifest JSON file as published at <DepsBaseURL>/vmconfig/manifests/vmconfig_<kind>_<os>_<arch>.json.
func (*Manifest) DownloadItems ¶
func (m *Manifest) DownloadItems(filters ...ItemFilter) []Item
DownloadItems returns only the artifacts the CLI can fetch and verify from the manifest. Local vmconfig/manifests manifests intentionally contain an unreleased vmconfig stub with no URL or digest; the release pipeline fills those fields for published manifests. The stub is not downloadable, so local development manifests skip it while still validating every real artifact.
func (*Manifest) HasVMConfigDep ¶
func (m *Manifest) HasVMConfigDep(filters ...ItemFilter) bool
HasVMConfigDep reports whether the manifest includes a downloadable vmconfig package (i.e. it is present in the Dependencies map and is not an unreleased stub).
func (*Manifest) InstallItems ¶
func (m *Manifest) InstallItems(filters ...ItemFilter) []Item
InstallItems returns the dependencies that a running VM needs to install at boot time in deterministic order. This excludes the OS image (the VM is already running on it) and any unreleased vmconfig stubs. Stable ordering prevents semantically identical userdata from changing Nstance infra hashes.
func (*Manifest) Items ¶
Items returns the OS image plus every named dependency as a flat list, in no guaranteed order other than the OS image first.
func (*Manifest) MarkCached ¶
MarkCached marks one vmconfig artifact entry as present in the local cache.
func (*Manifest) ResetCached ¶
func (m *Manifest) ResetCached()
ResetCached clears local cache-state markers from the OS image and all vmconfig dependencies.
type OSInfo ¶
type OSInfo struct {
Name string `json:"name"`
Arch string `json:"arch"`
Image Dependency `json:"image"`
Boot BootInfo `json:"boot"`
}
OSInfo describes the base OS, including the qcow2 image to download.
type SeedSnapshot ¶
type Seeds ¶
type Seeds struct {
Version string `json:"version"`
Components string `json:"components"`
Snapshots map[string]SeedSnapshot `json:"snapshots"`
}
type SeedsManifest ¶
type SeedsManifest struct {
Seeds Seeds `json:"seeds"`
}
SeedsManifest is the top-level seed snapshot dependency manifest.
func (*SeedsManifest) MarkCached ¶
func (m *SeedsManifest) MarkCached(name string)
MarkCached marks one seed snapshot as present in the local cache.
func (*SeedsManifest) ResetCached ¶
func (m *SeedsManifest) ResetCached()
ResetCached clears local cache-state markers from seed snapshots.
type TemplateChart ¶
type TemplateChart struct {
Name string `json:"name"`
Version string `json:"version"`
Type string `json:"type"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
Digest string `json:"digest,omitempty"`
Dependencies TemplateDependencies `json:"dependencies,omitempty"`
Cached bool `json:"cached,omitempty"`
ChartLayerDigest string `json:"chartLayerDigest,omitempty"`
}
type TemplateDependencies ¶
type TemplateDependencies struct {
Components []string `json:"components,omitempty"`
}
type Templates ¶
type Templates struct {
Version string `json:"version"`
Charts []TemplateChart `json:"charts"`
}
type TemplatesManifest ¶
type TemplatesManifest struct {
Templates Templates `json:"templates"`
}
TemplatesManifest is the top-level templates dependency manifest.
func (*TemplatesManifest) MarkCached ¶
func (m *TemplatesManifest) MarkCached(index int, chartLayerDigest string)
MarkCached marks a template chart as cached with its chart layer digest.
func (*TemplatesManifest) ResetCached ¶
func (m *TemplatesManifest) ResetCached()
ResetCached clears local cache-state markers from template charts.
type VMConfig ¶
type VMConfig struct {
Version string `json:"version"`
Kind string `json:"kind"`
OS OSInfo `json:"os"`
Dependencies map[string]Dependency `json:"dependencies"`
}
VMConfig is the inner manifest payload listing the OS image and all dependencies required to build a VM of the given kind.
Source Files
¶
- components_cache.go
- components_fetch.go
- components_manifest.go
- components_zot.go
- doc.go
- download.go
- http.go
- manager.go
- nudge.go
- seeds_cache.go
- seeds_fetch.go
- seeds_manifest.go
- status.go
- templates_cache.go
- templates_fetch.go
- templates_manifest.go
- templates_oci.go
- verify.go
- vmconfig_cache.go
- vmconfig_fetch.go
- vmconfig_manifest.go