manifests

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package manifests parses and validates the YAML manifest files shipped under manifests/ inside a consensus-node deployment package (consensus-node-components.yaml, infrastructure-versions.yaml, external-files.yaml, state-sources.yaml).

Each per-manifest parser (ParseConsensusNodeComponents, ParseInfrastructureVersions, ParseExternalFiles, ParseStateSources) runs the cross-cutting schemaVersion check (ValidateSchemaVersion) first, then strict-decodes the document against its typed root struct, then runs semantic validation. Typed errorx error classifications (ParseError, MissingSchemaVersionError, UnsupportedSchemaVersionError, UnknownKindError, ValidationError) let callers branch on failure mode without string matching.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorsNamespace = errorx.NewNamespace("manifests")

	ParseError                    = ErrorsNamespace.NewType("parse_error")
	MissingSchemaVersionError     = ErrorsNamespace.NewType("missing_schema_version")
	UnsupportedSchemaVersionError = ErrorsNamespace.NewType("unsupported_schema_version")
	UnknownKindError              = ErrorsNamespace.NewType("unknown_kind")
	ValidationError               = ErrorsNamespace.NewType("validation_error")
)
View Source
var SupportedImagePlatforms = []string{"linux/amd64", "linux/arm64"}

SupportedImagePlatforms is the set of platform identifiers accepted in any layerHashes map. The slice is kept sorted so it can appear directly in error messages without surprising readers.

Functions

func AllowedBucketSchemes

func AllowedBucketSchemes() []string

AllowedBucketSchemes returns a fresh copy of the closed set of cloud-storage URI schemes recognised on state-sources.yaml bucket fields. Each call returns a new slice so callers cannot affect enforcement by mutating the returned value.

func AllowedDestinationPrefixes

func AllowedDestinationPrefixes() []string

AllowedDestinationPrefixes returns a fresh copy of the closed set of marker prefixes recognised on external-files.yaml destination fields. Tooling that lints CN deployment packages outside of the daemon can reuse the same set without reimplementing the policy. Each call returns a new slice so callers cannot affect enforcement by mutating the returned value.

func NewMissingSchemaVersionError

func NewMissingSchemaVersionError(kind Kind) *errorx.Error

func NewParseError

func NewParseError(cause error, kind Kind) *errorx.Error

func NewUnknownKindError

func NewUnknownKindError(kind Kind) *errorx.Error

func NewUnsupportedSchemaVersionError

func NewUnsupportedSchemaVersionError(kind Kind, declared SchemaVersion, supported []SchemaVersion) *errorx.Error

func NewValidationError

func NewValidationError(kind Kind, field string, reason string) *errorx.Error

NewValidationError flags a semantic-validation failure on a parsed manifest: a field is present and structurally valid, but its value violates a rule that yaml.Unmarshal alone cannot enforce (e.g. layerHashes appearing in the wrong place for a deterministic build). The field path is the dotted Go field name, e.g. `images.backupUploader.registries[0].layerHashes`.

Types

type Binary

type Binary struct {
	Version   string `yaml:"version"`
	Algorithm string `yaml:"algorithm"`
	Checksum  string `yaml:"checksum"`
}

Binary is one solo-provisioner binary's release spec — the exact version to install and the checksum used to verify the downloaded artifact.

type ClusterChart

type ClusterChart struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

ClusterChart is one audit-record entry under cluster: — a Helm chart installed into the Kubernetes cluster (e.g. alloy, metallb, metrics-server) whose installed version the provisioner reconciles against its embedded catalog.

type ConsensusNodeComponents

type ConsensusNodeComponents struct {
	Header `yaml:",inline"`
	Images Images `yaml:"images"`
}

ConsensusNodeComponents is the parsed root of a consensus-node-components.yaml manifest. It declares the container images for the consensus node and its named sidecars, plus the layer-hash integrity records used to verify those images before they run.

Per the manifest contract ("absent = no change"), every entry under Images is optional. A nil entry signals "the deployment package does not change this component", not "disable this component" — that decision is encoded in the Image.Enabled pointer field instead.

func ParseConsensusNodeComponents

func ParseConsensusNodeComponents(data []byte) (*ConsensusNodeComponents, error)

ParseConsensusNodeComponents parses raw YAML bytes of a consensus-node-components.yaml manifest. It runs the cross-cutting schemaVersion check first (so a future-versioned manifest is rejected before any current-shape decode), then strict-decodes the (single) YAML document into ConsensusNodeComponents (unknown top-level fields or unknown component names under images: are errors; multi-document inputs are rejected), then runs semantic validation on every present component entry.

type Deterministic

type Deterministic struct {
	Supported   bool        `yaml:"supported"`
	LayerHashes LayerHashes `yaml:"layerHashes,omitempty"`
}

Deterministic describes whether a component's container images produce identical layer hashes across all registries for the same version. When Supported is true, LayerHashes is the single shared record used to verify every registry; when false, each Registry carries its own layerHashes override and LayerHashes here must be empty.

type DownloadPhase

type DownloadPhase string

DownloadPhase enumerates the legal values for phase.download. "prepare" downloads before the freeze window begins (low-risk, can spread network I/O over a long lead time); "freeze" delays the download until the freeze window itself (used for large state-bearing files that must reflect the exact freeze-time bytes).

const (
	DownloadPhasePrepare DownloadPhase = "prepare"
	DownloadPhaseFreeze  DownloadPhase = "freeze"
)

type ExternalFile

type ExternalFile struct {
	URL         string `yaml:"url"`
	Algorithm   string `yaml:"algorithm"`
	Checksum    string `yaml:"checksum"`
	ContentType string `yaml:"contentType,omitempty"`
	Destination string `yaml:"destination"`
	// Optional defaults to false. When true, a download failure for this entry
	// is logged but does not abort the wider apply. yaml.v3 zeroes the field
	// when absent from the YAML, which is the same as the documented default.
	Optional bool  `yaml:"optional,omitempty"`
	Phase    Phase `yaml:"phase"`
}

ExternalFile is one entry under files:. The destination is expressed using a directory-marker prefix (e.g. HAPIAPP_DIR/...) that the downloader resolves to a real filesystem path at apply time.

type ExternalFiles

type ExternalFiles struct {
	Header `yaml:",inline"`
	Files  []ExternalFile `yaml:"files,omitempty"`
}

ExternalFiles is the parsed root of an external-files.yaml manifest. It declares large remote files (over the ~1 MB ConfigurationFile-CR limit) that the upgrade-controller sidecar or the solo-provisioner-upgrade daemon must download and stage on the host before the consensus node restarts.

func ParseExternalFiles

func ParseExternalFiles(data []byte) (*ExternalFiles, error)

ParseExternalFiles parses raw YAML bytes of an external-files.yaml manifest. It runs the cross-cutting schemaVersion check first, then strict-decodes the single YAML document (unknown top-level fields fail; multi-document inputs are rejected), then runs per-entry semantic validation.

type Header struct {
	SchemaVersion SchemaVersion `yaml:"schemaVersion"`
}

Header captures the common schemaVersion field present on every manifest. Concrete parsers embed it in their root struct so a single strict-decode pass yields both the version and the rest of the document.

func ValidateSchemaVersion

func ValidateSchemaVersion(kind Kind, data []byte) (Header, error)

ValidateSchemaVersion decodes only the schemaVersion field from data and confirms the value is in the supported set for kind. It returns the parsed Header. Callers run this before full unmarshalling so that a manifest declaring an unsupported (e.g. future) schemaVersion is rejected with a clear error instead of producing surprising decode failures against the current shape.

Unknown fields in data are tolerated at this stage — the function inspects only schemaVersion. Per-kind parsers may apply stricter checks downstream.

type HostComponent

type HostComponent struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

HostComponent is one audit-record entry under host: — a host-level binary (e.g. cri-o, kubelet, kubeadm, kubectl, helm, cilium) whose installed version the provisioner reconciles against its embedded catalog.

type Image

type Image struct {
	Enabled       *bool          `yaml:"enabled,omitempty"`
	Version       string         `yaml:"version"`
	Deterministic *Deterministic `yaml:"deterministic,omitempty"`
	Registries    []Registry     `yaml:"registries"`
}

Image is the per-component spec. Enabled is a tri-state pointer so the manifest can carry an explicit on/off intent (true / false) distinct from "no opinion" (nil). Note that when an Image entry is present at all, the other required fields (Version, Registries) must still be set — validation enforces this. A nil entry under Images is the "absent = no change" signal at the section level.

type Images

type Images struct {
	ConsensusNode        *Image `yaml:"consensusNode,omitempty"`
	RecordStreamUploader *Image `yaml:"recordStreamUploader,omitempty"`
	EventStreamUploader  *Image `yaml:"eventStreamUploader,omitempty"`
	BlockStreamUploader  *Image `yaml:"blockStreamUploader,omitempty"`
	BackupUploader       *Image `yaml:"backupUploader,omitempty"`
	UC                   *Image `yaml:"uc,omitempty"`
}

Images groups the consensus node and its five named sidecars. Each field is a pointer so a parser can distinguish absent from explicitly-zero. Unknown component names in the YAML are rejected by strict decoding; if the set of supported sidecars grows, this struct grows with it.

type InfrastructureVersions

type InfrastructureVersions struct {
	Header      `yaml:",inline"`
	Provisioner *Provisioner    `yaml:"provisioner,omitempty"`
	Host        []HostComponent `yaml:"host,omitempty"`
	Cluster     []ClusterChart  `yaml:"cluster,omitempty"`
}

InfrastructureVersions is the parsed root of an infrastructure-versions.yaml manifest. It declares the solo-provisioner binary versions (CLI + daemon) that must be installed at apply time, plus an audit record of every host- level binary and Helm chart whose version the provisioner will reconcile.

Per the manifest contract ("absent = no change"), every section is optional. Provisioner is a pointer so a partial manifest can omit the section entirely. Host and Cluster are slices: a missing section and an empty section both decode to len==0 — callers that need to differentiate them must inspect the raw YAML, not the slice length, but the parser treats both identically since they're equivalent under the "absent = no change" contract.

func ParseInfrastructureVersions

func ParseInfrastructureVersions(data []byte) (*InfrastructureVersions, error)

ParseInfrastructureVersions parses raw YAML bytes of an infrastructure-versions.yaml manifest. It runs the cross-cutting schemaVersion check first, then strict-decodes the single YAML document (unknown top-level fields fail; multi-document inputs are rejected), then runs semantic validation.

type InstallPhase

type InstallPhase string

InstallPhase enumerates the legal values for phase.install. Today only "freeze" is permitted — installing a large file outside the freeze window would require the CN to be live during a non-atomic move and is rejected by design.

const (
	InstallPhaseFreeze InstallPhase = "freeze"
)

type Kind

type Kind string

Kind identifies which of the four manifest files is being parsed. Its string value matches the basename (without ".yaml") of the file inside the deployment package's manifests/ directory.

const (
	KindConsensusNodeComponents Kind = "consensus-node-components"
	KindInfrastructureVersions  Kind = "infrastructure-versions"
	KindExternalFiles           Kind = "external-files"
	KindStateSources            Kind = "state-sources"
)

type LayerHashes

type LayerHashes map[string][]string

LayerHashes maps a container platform identifier (e.g. "linux/arm64") to an ordered list of layer digests for that platform.

type Phase

type Phase struct {
	Download DownloadPhase `yaml:"download"`
	Install  InstallPhase  `yaml:"install"`
}

Phase tells the downloader when each file is fetched and when it is moved into place. Download can happen either before the freeze window starts (prepare — concurrent with normal traffic) or during the freeze itself. Install always happens during the freeze, when the CN is stopped and the staged files can be moved into place atomically.

type Provisioner

type Provisioner struct {
	CLI    *Binary `yaml:"cli,omitempty"`
	Daemon *Binary `yaml:"daemon,omitempty"`
}

Provisioner holds the integrity records for the two solo-provisioner binaries. The split reflects the existing two-binary layout in this repo (CLI: solo-provisioner; daemon: solo-provisioner-daemon — independently released and tagged). Both sub-sections are pointer-typed for the same "absent = no change" reason as Image.Enabled in #531.

type Registry

type Registry struct {
	Image       string      `yaml:"image"`
	LayerHashes LayerHashes `yaml:"layerHashes,omitempty"`
}

Registry is one publication site for a component image. For non-deterministic components, LayerHashes is a per-registry override (because the same logical image produces different layer digests at each registry).

type SchemaVersion

type SchemaVersion int

SchemaVersion is the value of the schemaVersion field on a manifest. The HIP defines the field as an integer ("schemaVersion: 1") so the parser does not need to round-trip strings into version numbers.

const SchemaV1 SchemaVersion = 1

SchemaV1 is the only schemaVersion currently accepted on any manifest.

func SupportedVersions

func SupportedVersions(kind Kind) []SchemaVersion

SupportedVersions returns the sorted list of schemaVersion values this build accepts for kind, or nil if kind is not a recognised manifest. It exists for callers that need to render help text or diagnostics.

type StateSource

type StateSource struct {
	Bucket   string            `yaml:"bucket"`
	Location string            `yaml:"location"`
	Index    map[string]string `yaml:"index"`
	Paths    map[string]string `yaml:"paths"`
}

StateSource is one cloud-storage entry. Each source declares its location (region), the bucket URI (whose scheme encodes the provider — `gcs://`, `s3://`), and two parallel maps keyed by node ID: Index names the per-node index file containing the latest available round, and Paths names the per-node base directory where that round's state files live.

type StateSources

type StateSources struct {
	Header  `yaml:",inline"`
	Sources []StateSource `yaml:"stateSources,omitempty"`
}

StateSources is the parsed root of a state-sources.yaml manifest. It declares one or more cloud storage buckets from which a new or rejoining consensus node can fast-sync the latest saved-state snapshot rather than replaying the entire event stream from genesis. Multiple buckets are listed for redundancy and geographic locality.

func ParseStateSources

func ParseStateSources(data []byte) (*StateSources, error)

ParseStateSources parses raw YAML bytes of a state-sources.yaml manifest. It runs the cross-cutting schemaVersion check first, then strict-decodes the single YAML document (unknown top-level fields fail; multi-document inputs are rejected), then runs per-source semantic validation.

Jump to

Keyboard shortcuts

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