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
- Variables
- func ComputeDesiredStateDigest(d *Document) (string, error)
- func DigestOf(data []byte) string
- func Encode(doc *Document) ([]byte, error)
- func Name(desiredStateDigest string) (string, error)
- func ReadContent(cm *corev1.ConfigMap, key string) ([]byte, error)
- func ReleaseDigest(r *Release) (string, error)
- func ToConfigMap(doc *Document, namespace, runtimeName string) (*corev1.ConfigMap, error)
- type Chart
- type ChartSource
- type Content
- type DigestedRef
- type Document
- type Engine
- type Phase
- type Provenance
- type Recipe
- type Release
- type Source
- type UpstreamChart
Constants ¶
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" )
const ( RecipeDataKey = "recipe.json" ValuesDataKey = "values.json" SnapshotDataKey = "snapshot.json" AssessmentDataKey = "assessment.json" )
Data keys of the content ConfigMaps a plan references.
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.
const ReasonContentTooLarge = "ContentTooLarge"
ReasonContentTooLarge marks a recipe or release values document that does not fit one ConfigMap.
const SchemaVersion = 1
SchemaVersion is the plan document schema this operator writes. It reads every version in SupportedSchemaVersions (N and N-1).
Variables ¶
var SupportedSchemaVersions = map[int]bool{1: true}
SupportedSchemaVersions are the plan schemas this operator can read.
Functions ¶
func ComputeDesiredStateDigest ¶
ComputeDesiredStateDigest returns the desiredStateDigest of a document's identity fields. Release order is kept: AICR's order is normative.
func Encode ¶
Encode validates doc and renders it as the canonical JSON stored in the ConfigMap. Struct field order makes the encoding deterministic.
func Name ¶
Name returns the ConfigMap name for a desiredStateDigest: the prefix plus the first 16 hex characters of the digest.
func ReadContent ¶
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 ¶
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.
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 ¶
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 ¶
AssessmentContent returns the content of an AICR upgrade-check report, which a rollout references.
func RecipeContent ¶
RecipeContent returns the recipe content for a RecipeResult document.
func RolloutSnapshotContent ¶
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 ¶
SnapshotContent returns the content of an AICR Snapshot document, kept in the operator namespace so a resolution survives its Job.
func ValuesContent ¶
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 ¶
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 ¶
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.
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 UpstreamChart ¶
type UpstreamChart struct {
Repository string `json:"repository"`
ArchiveDigest string `json:"archiveDigest"`
}
UpstreamChart records the verified upstream archive of a mirrored chart.