plan

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plan parses rendered AICR output into plan documents, computes desiredStateDigest and inputDigest, rebuilds plans from live engine objects, and constructs rollout steps.

Index

Constants

View Source
const (
	// DataKey holds the plan document in the ConfigMap.
	DataKey = "plan.json"
	// NamePrefix starts every plan ConfigMap name.
	NamePrefix = "aicr-plan-"
	// MaxConfigMapBytes is the ConfigMap size limit (1 MiB).
	MaxConfigMapBytes = 1 << 20
	// ReasonPlanUnreadable is the condition reason for a plan the operator
	// refuses to read (docs/operator/api.md#plan-configmap).
	ReasonPlanUnreadable = "PlanUnreadable"
)
View Source
const (
	RecipeDataKey     = "recipe.json"
	ValuesDataKey     = "values.json"
	SnapshotDataKey   = "snapshot.json"
	AssessmentDataKey = "assessment.json"
)

Data keys of the content ConfigMaps a plan references.

View Source
const (
	// MaxReleases bounds the releases in one plan.
	MaxReleases = 128
	// MaxReleaseIDLength is the Helm release-name limit.
	MaxReleaseIDLength = 53
	// MaxWarnings bounds recorded AICR bundle warnings.
	MaxWarnings = 64
)

Bounds from docs/operator/api.md#plan-configmap.

View Source
const ReasonContentTooLarge = "ContentTooLarge"

ReasonContentTooLarge marks a recipe or release values document that does not fit one ConfigMap.

View Source
const SchemaVersion = 1

SchemaVersion is the plan document schema this operator writes. It reads every version in SupportedSchemaVersions (N and N-1).

Variables

View Source
var SupportedSchemaVersions = map[int]bool{1: true}

SupportedSchemaVersions are the plan schemas this operator can read.

Functions

func ComputeDesiredStateDigest

func ComputeDesiredStateDigest(d *Document) (string, error)

ComputeDesiredStateDigest returns the desiredStateDigest of a document's identity fields. Release order is kept: AICR's order is normative.

func DigestOf

func DigestOf(data []byte) string

DigestOf returns the sha256 digest of data in "sha256:<hex>" form.

func Encode

func Encode(doc *Document) ([]byte, error)

Encode validates doc and renders it as the canonical JSON stored in the ConfigMap. Struct field order makes the encoding deterministic.

func Name

func Name(desiredStateDigest string) (string, error)

Name returns the ConfigMap name for a desiredStateDigest: the prefix plus the first 16 hex characters of the digest.

func ReadContent

func ReadContent(cm *corev1.ConfigMap, key string) ([]byte, error)

ReadContent returns a content ConfigMap's document after checking it is the content its name and annotation claim: the digest of the data must equal the annotation. A ConfigMap that fails is never trusted.

func ReleaseDigest

func ReleaseDigest(r *Release) (string, error)

ReleaseDigest digests one release's identity fields, the share of desiredStateDigest it contributes. Engine objects carry it, so a release edited out of band is named even when its plan is gone.

func ToConfigMap

func ToConfigMap(doc *Document, namespace, runtimeName string) (*corev1.ConfigMap, error)

ToConfigMap renders doc as the immutable plan ConfigMap.

Types

type Chart

type Chart struct {
	Source     ChartSource    `json:"source"`
	Repository string         `json:"repository"`
	Version    string         `json:"version,omitempty"`
	Digest     string         `json:"digest"`
	Upstream   *UpstreamChart `json:"upstream,omitempty"`
}

Chart is a chart served from the runtime registry, pinned by digest.

type ChartSource

type ChartSource string

ChartSource distinguishes mirrored upstream charts from wrapper charts.

const (
	ChartMirrored ChartSource = "Mirrored"
	ChartWrapper  ChartSource = "Wrapper"
)

Chart sources.

type Content

type Content struct {
	Role   string
	Name   string
	Key    string
	Data   []byte
	Digest string
}

Content is a content-addressed document a plan references: the recipe it was resolved from or one release's values. Its ConfigMap is immutable and named by the digest, so creating it twice is harmless.

func AssessmentContent

func AssessmentContent(reportJSON []byte) *Content

AssessmentContent returns the content of an AICR upgrade-check report, which a rollout references.

func RecipeContent

func RecipeContent(recipeJSON []byte) *Content

RecipeContent returns the recipe content for a RecipeResult document.

func RolloutSnapshotContent

func RolloutSnapshotContent(snapshotJSON []byte, input string) *Content

RolloutSnapshotContent is SnapshotContent for the snapshot one rollout validates against: its name carries the run input, so it never shares a ConfigMap with discovery's snapshot of the same data.

func SnapshotContent

func SnapshotContent(snapshotJSON []byte) *Content

SnapshotContent returns the content of an AICR Snapshot document, kept in the operator namespace so a resolution survives its Job.

func ValuesContent

func ValuesContent(releaseID string, valuesJSON []byte) *Content

ValuesContent returns a release's canonical values content.

func (*Content) ConfigMap

func (c *Content) ConfigMap(namespace, runtimeName, runtimeUID string, labels map[string]string) (*corev1.ConfigMap, error)

ConfigMap renders the immutable ConfigMap holding the content. labels are added to the operator's own (for example the resolution input).

func (*Content) Ref

func (c *Content) Ref() DigestedRef

Ref returns the plan reference to the content.

type DigestedRef

type DigestedRef struct {
	ConfigMap string `json:"configMap"`
	Digest    string `json:"digest"`
}

DigestedRef names a ConfigMap and the digest of its content.

type Document

type Document struct {
	SchemaVersion int    `json:"schemaVersion"`
	RuntimeUID    string `json:"runtimeUID"`
	Engine        Engine `json:"engine"`
	// EnginePolicy names the version of the policy fields the engine adapter
	// sets on every engine object; it is part of plan identity.
	EnginePolicy       string     `json:"enginePolicy"`
	DesiredStateDigest string     `json:"desiredStateDigest"`
	InputDigest        string     `json:"inputDigest,omitempty"`
	Provenance         Provenance `json:"provenance"`
	Recipe             *Recipe    `json:"recipe,omitempty"`
	Releases           []Release  `json:"releases"`
}

Document is the plan: rendered desired state for one desiredStateDigest. It is operator-internal and stored in an immutable ConfigMap, never as an API kind.

func FromConfigMap

func FromConfigMap(cm *corev1.ConfigMap) (*Document, error)

FromConfigMap reads a plan, refusing anything it cannot trust: a schema version it does not support, a label that disagrees with the payload, a payload digest that disagrees with the annotation, an invalid document, a recorded digest its content does not reproduce, or a ConfigMap not named for its digest. Every refusal is INVALID_REQUEST with reason PlanUnreadable in its context; the operator never guesses.

func (*Document) Validate

func (d *Document) Validate() error

Validate checks a document's shape and bounds. It does not check graph semantics beyond references (the planner owns ordering).

type Engine

type Engine string

Engine names the deployment engine a plan targets.

const (
	EngineArgoCD Engine = "ArgoCD"
	EngineFlux   Engine = "Flux"
)

Engines.

type Phase

type Phase string

Phase is a release's place in AICR's normative release layout.

const (
	PhasePre       Phase = "Pre"
	PhasePrimary   Phase = "Primary"
	PhasePost      Phase = "Post"
	PhaseReadiness Phase = "Readiness"
)

Release phases.

type Provenance

type Provenance struct {
	Source            Source `json:"source"`
	OperatorVersion   string `json:"operatorVersion,omitempty"`
	AICRVersion       string `json:"aicrVersion,omitempty"`
	AICRImage         string `json:"aicrImage,omitempty"`
	SnapshotDigest    string `json:"snapshotDigest,omitempty"`
	Bundle            string `json:"bundle,omitempty"`
	RuntimeGeneration int64  `json:"runtimeGeneration,omitempty"`
	// RenderFlags are the `aicr bundle` flags the render ran with, besides
	// the recipe and the output: with the recipe ConfigMap, the AICR CLI
	// renders the same bundle. Absent from a Rebuilt plan.
	RenderFlags []string `json:"renderFlags,omitempty"`
}

Provenance records where a plan came from. It is evidence, not identity.

type Recipe

type Recipe struct {
	Name                   string            `json:"name"`
	Criteria               map[string]string `json:"criteria,omitempty"`
	ConfigMapRef           DigestedRef       `json:"configMapRef"`
	ValidationConfigMapRef *DigestedRef      `json:"validationConfigMapRef,omitempty"`
	Warnings               []string          `json:"warnings,omitempty"`
}

Recipe identifies the AICR recipe a resolved plan was rendered from. Rebuilt plans have none. ConfigMapRef is the recipe Job's output, which upgrade-check and reproduce read; ValidationConfigMapRef is the recipe the bundle records after AICR filtered it by the render flags, which deployment validation reads. Plans written before it was recorded have no ValidationConfigMapRef. Neither ref is part of the plan's digest.

func (*Recipe) Validation

func (r *Recipe) Validation() DigestedRef

Validation is the recipe deployment validation runs against: the bundle's, or the render recipe for a plan that records none.

type Release

type Release struct {
	ID              string      `json:"id"`
	Component       string      `json:"component"`
	Phase           Phase       `json:"phase"`
	ReadinessFor    string      `json:"readinessFor,omitempty"`
	DependsOn       []string    `json:"dependsOn,omitempty"`
	TargetNamespace string      `json:"targetNamespace"`
	Chart           Chart       `json:"chart"`
	Values          DigestedRef `json:"values"`
	OwnsCRDs        bool        `json:"ownsCRDs"`
}

Release is one plan release.

type Source

type Source string

Source records how a plan was produced.

const (
	// SourceResolved plans come from AICR Jobs.
	SourceResolved Source = "Resolved"
	// SourceRebuilt plans are rebuilt from live engine objects.
	SourceRebuilt Source = "Rebuilt"
)

Plan sources.

type UpstreamChart

type UpstreamChart struct {
	Repository    string `json:"repository"`
	ArchiveDigest string `json:"archiveDigest"`
}

UpstreamChart records the verified upstream archive of a mirrored chart.

Jump to

Keyboard shortcuts

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