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
- Variables
- func EnsureCRD(ctx context.Context, apiext apiextensionsclient.Interface) error
- func EnsureObject(ctx context.Context, dyn dynamic.Interface, name string) error
- func GVR() schema.GroupVersionResource
- func WriteStatus(ctx context.Context, dyn dynamic.Interface, name string, st Status) error
- type Spec
- type Status
- type TargetStatus
- type TopFinding
Constants ¶
const ( Group = "upgradescope.dev" Version = "v1alpha1" Kind = "ClusterReadiness" Plural = "clusterreadinesses" Singular = "clusterreadiness" // DefaultName is the conventional singleton object name. DefaultName = "cluster" )
Variables ¶
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 ¶
EnsureObject creates the ClusterReadiness CR with an empty spec if absent. It never overwrites an existing object (user-set spec.targets survive).
func GVR ¶
func GVR() schema.GroupVersionResource
GVR is the dynamic-client resource identifier for ClusterReadiness.
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"`
}
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).