crd

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 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 crd owns the ClusterReadiness custom resource: its embedded CRD manifest, plain JSON-tagged Go types (no codegen), and apply/status logic via the dynamic client.

Index

Constants

View Source
const (
	Group    = "upgradescope.dev"
	Version  = "v1alpha1"
	Kind     = "ClusterReadiness"
	Plural   = "clusterreadinesses"
	Singular = "clusterreadiness"
	// DefaultName is the conventional singleton object name.
	DefaultName = "cluster"
)

Variables

View Source
var Manifest []byte

Manifest is the embedded ClusterReadiness CRD manifest. It is the single source of truth: EnsureCRD converges the cluster to it, and the Helm chart ships a copy in crds/.

Functions

func EnsureCRD

func EnsureCRD(ctx context.Context, apiext apiextensionsclient.Interface) error

EnsureCRD installs or updates the ClusterReadiness CRD from the embedded manifest. Create-or-update semantics: existing CRDs are overwritten with the manifest's spec (conflicts retried). After a fresh create it waits for the Established condition so the first tick can write status immediately. Callers may treat failure as non-fatal when the CRD is pre-installed out of band (e.g. Helm crds/).

func EnsureObject

func EnsureObject(ctx context.Context, dyn dynamic.Interface, name string) error

EnsureObject creates the ClusterReadiness CR with an empty spec if absent. It never overwrites an existing object (user-set spec.targets survive).

func GVR

GVR is the dynamic-client resource identifier for ClusterReadiness.

func WriteStatus

func WriteStatus(ctx context.Context, dyn dynamic.Interface, name string, st Status) error

WriteStatus replaces the status subresource, retrying on conflict with a fresh read each attempt.

Types

type Spec

type Spec struct {
	// Targets are Kubernetes minor versions to evaluate against, e.g. ["1.36","1.37"].
	// Empty → agent defaults to next minor above the observed server version.
	Targets []string `json:"targets,omitempty"`
}

func ReadSpec

func ReadSpec(ctx context.Context, dyn dynamic.Interface, name string) (Spec, bool, error)

ReadSpec returns the ClusterReadiness spec. found=false (with nil error) means the object does not exist; callers typically EnsureObject then.

type Status

type Status struct {
	ObservedServerVersion string         `json:"observedServerVersion,omitempty"`
	KBVersion             string         `json:"kbVersion,omitempty"`
	LastEvaluated         metav1.Time    `json:"lastEvaluated,omitempty"`
	Targets               []TargetStatus `json:"targets,omitempty"`
	NotAssessed           []string       `json:"notAssessed,omitempty"` // "helm: secrets list forbidden"
	AgentVersion          string         `json:"agentVersion,omitempty"`
}

func StatusFromReports

func StatusFromReports(reports []engine.Report, observedServerVersion, agentVersion string, now time.Time) Status

StatusFromReports builds the full CRD status from per-target reports. All reports come from the same inventory, so KBVersion and NotAssessed are taken from the first report. NotAssessed gaps render as "capability: reason".

type TargetStatus

type TargetStatus struct {
	Target      string         `json:"target"` // "1.36"
	Score       int            `json:"score"`
	Ready       bool           `json:"ready"`
	Blockers    int            `json:"blockers"`
	Warnings    int            `json:"warnings"`
	Infos       int            `json:"infos"`
	ByCategory  map[string]int `json:"byCategory,omitempty"`  // category → count
	TopFindings []TopFinding   `json:"topFindings,omitempty"` // ≤20, severity-sorted
}

func TargetStatusFromReport

func TargetStatusFromReport(r engine.Report) TargetStatus

TargetStatusFromReport summarizes one engine.Report for CRD status: severity/category counts over all findings, plus the first maxTopFindings findings (Report.Findings is already severity-sorted per engine contract).

type TopFinding

type TopFinding struct {
	Category    string `json:"category"`
	Severity    string `json:"severity"`
	Title       string `json:"title"`
	Remediation string `json:"remediation,omitempty"`
}

Jump to

Keyboard shortcuts

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