Documentation
¶
Overview ¶
Package migratecheck classifies Ingress annotations and source-controller ConfigMap keys against the migration-coverage data the template libraries declare for the browser playground's migration report.
The package is a pure component: it never touches Kubernetes, Helm, or the template engine. Callers hand it the coverage data, the audited Ingresses (pre-extracted fields plus the per-Ingress real-render verdict), and get back a Report with per-source, per-Ingress findings.
Source-controller detection remains data-driven from the coverage entries; the package is private to the Ingress migration tool that consumes it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnnotationCoverage ¶
type ConfigMap ¶
type ConfigMap struct {
Namespace string
Name string
Labels map[string]string
Data map[string]string
// KeyProblems maps a data key to why its pasted value isn't a valid
// ConfigMap value; Data still holds the value in string form.
KeyProblems map[string]string
// Problem is set when data itself can't be read; Data is then empty.
Problem string
}
ConfigMap is one pasted ConfigMap, reduced to the fields detection and classification read.
func ConfigMapFromUnstructured ¶
func ConfigMapFromUnstructured(u *unstructured.Unstructured) ConfigMap
ConfigMapFromUnstructured reduces a ConfigMap object to the fields Classify needs. Pasted YAML often leaves values unquoted (keep-alive: 75), which the API server would reject; such keys are still classified, with the value in string form and a KeyProblems entry, rather than dropped.
type ConfigMapCoverage ¶
type ConfigMapCoverage struct {
Detect ConfigMapDetect `json:"detect"`
Settings []ConfigMapSetting `json:"settings"`
}
ConfigMapCoverage classifies the keys of a source controller's own ConfigMap, the fleet-wide settings that never appear on an Ingress.
type ConfigMapDetect ¶
type ConfigMapDetect struct {
Names []string `json:"names,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
ConfigMapDetect attributes a pasted ConfigMap to the source: by exact name, or by carrying every one of Labels plus at least one declared key. The key requirement keeps sibling ConfigMaps that share the controller's labels (TCP/UDP service maps) out of the report.
type ConfigMapFinding ¶
type ConfigMapFinding struct {
Key string `json:"key"`
Value string `json:"value"`
Status Status `json:"status"`
Setting string `json:"setting,omitempty"`
Note string `json:"note,omitempty"`
// Problem says why the pasted value isn't a valid ConfigMap value.
Problem string `json:"problem,omitempty"`
}
ConfigMapFinding is one classified key of one ConfigMap.
type ConfigMapKey ¶
ConfigMapKey is one source ConfigMap key. A Name ending in "*" matches every key with that prefix; an exact Name elsewhere in the table wins over it.
type ConfigMapReport ¶
type ConfigMapReport struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Findings []ConfigMapFinding `json:"findings,omitempty"`
// Problem says why data couldn't be read at all.
Problem string `json:"problem,omitempty"`
}
ConfigMapReport carries the findings for one ConfigMap under one source, sorted by key. Every data key is a finding: the whole ConfigMap belongs to the source controller.
type ConfigMapSetting ¶
type ConfigMapSetting struct {
Keys []ConfigMapKey `json:"keys"`
Setting string `json:"setting,omitempty"`
Status Status `json:"status"`
Note string `json:"note,omitempty"`
}
ConfigMapSetting is one row of the source's ConfigMap migration table: the keys it covers, the HAPTIC setting replacing them, and the verdict. Setting and Note are Markdown with links relative to the docs root.
type CoverageSource ¶
type CoverageSource struct {
Source string `json:"source"`
Detect Detect `json:"detect,omitempty"`
Annotations map[string]AnnotationCoverage `json:"annotations,omitempty"`
ConfigMap *ConfigMapCoverage `json:"configMap,omitempty"`
}
func ParseCoverage ¶
func ParseCoverage(data []byte) ([]CoverageSource, error)
func ParseLegacyConfigCoverage ¶
func ParseLegacyConfigCoverage(data []byte) ([]CoverageSource, bool)
type Finding ¶
type Finding struct {
// Annotation is the full annotation key.
Annotation string `json:"annotation"`
// Value is the annotation's value on this Ingress.
Value string `json:"value"`
// Status is the coverage classification.
Status Status `json:"status"`
// Note is the plain-language explanation from the coverage data.
Note string `json:"note,omitempty"`
// Doc is the documentation link/anchor from the coverage data.
Doc string `json:"doc,omitempty"`
}
Finding is one classified annotation on one Ingress.
type Ingress ¶
type Ingress struct {
// Namespace and Name identify the resource.
Namespace string `json:"namespace"`
Name string `json:"name"`
// Class is the effective ingress class: spec.ingressClassName when
// set, otherwise the legacy kubernetes.io/ingress.class annotation.
Class string `json:"class,omitempty"`
// Annotations is metadata.annotations.
Annotations map[string]string `json:"-"`
// RenderError is the (simplified) error from rendering this Ingress
// through the real template pipeline; empty when the render passed
// or was not performed.
RenderError string `json:"renderError,omitempty"`
}
Ingress is one audited Ingress resource, reduced to the fields the classification needs.
func FromUnstructured ¶
func FromUnstructured(u *unstructured.Unstructured) Ingress
FromUnstructured reduces an Ingress object to the fields Classify needs: its identity, effective class, and annotations. The effective class is spec.ingressClassName when set, otherwise the legacy kubernetes.io/ingress.class annotation.
type IngressReport ¶
type IngressReport struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Class string `json:"class,omitempty"`
// Findings lists the classified annotations, sorted by key. Fully
// supported annotations are included (status "supported") so the
// JSON output is complete; the text renderer summarizes them.
Findings []Finding `json:"findings,omitempty"`
// RenderError is the real-render verdict for this Ingress; empty
// when the render passed.
RenderError string `json:"renderError,omitempty"`
}
IngressReport carries the findings for one Ingress under one source.
type Report ¶
type Report struct {
// Sources lists per-source findings in coverage declaration order.
// Only sources with at least one attributed Ingress or ConfigMap appear.
Sources []SourceReport `json:"sources"`
// Unattributed lists Ingresses that no coverage entry's detect rules
// matched. They carry no findings, but their render verdict still
// counts: a render failure is a blocker wherever it happens.
Unattributed []IngressReport `json:"unattributed,omitempty"`
// TotalIngresses is the number of audited Ingresses.
TotalIngresses int `json:"totalIngresses"`
// CheckedAnnotations is the number of annotation keys classified
// across all sources.
CheckedAnnotations int `json:"checkedAnnotations"`
// TotalConfigMaps is the number of ConfigMaps at least one source
// claimed as its controller ConfigMap.
TotalConfigMaps int `json:"totalConfigMaps"`
// CheckedConfigMapKeys is the number of ConfigMap keys classified across
// all sources.
CheckedConfigMapKeys int `json:"checkedConfigMapKeys"`
// Counts tallies annotation and ConfigMap findings by status across all
// sources.
Counts map[Status]int `json:"counts"`
// RenderFailures is the number of Ingresses whose real render failed.
RenderFailures int `json:"renderFailures"`
// AggregateRenderError is the (simplified) error from rendering ALL
// audited Ingresses together, empty when the combined render succeeded.
// Per-Ingress renders are isolated so a failure attributes to one
// Ingress; this aggregate pass additionally catches conflicts that only
// arise from the combination (duplicate backend/frontend names,
// colliding hosts or paths, cross-resource map-key collisions) — which
// isolated renders cannot see. A non-empty value is a blocker.
AggregateRenderError string `json:"aggregateRenderError,omitempty"`
}
Report is the complete migrate-check result.
func Classify ¶
func Classify(coverage []CoverageSource, ingresses []Ingress, configMaps []ConfigMap) *Report
Classify groups the audited Ingresses by source controller (via each coverage entry's detect rules) and classifies every annotation whose key matches one of the source's declared prefixes against the source's coverage map. Keys matching a prefix but absent from the coverage map are reported honestly as StatusUnknown.
An Ingress is attributed to a source when its class matches one of the source's detect.ingressClasses OR any of its annotation keys carries one of the source's detect.annotationPrefixes. One Ingress can be attributed to several sources (each classifies only its own prefixes).
A ConfigMap is attributed to every source whose configMap.detect rules match it (see ConfigMapDetect), and each of its data keys is classified. ConfigMaps no source claims are left out of the report.
type SourceReport ¶
type SourceReport struct {
// Source is the coverage entry's source name.
Source string `json:"source"`
// Ingresses lists the attributed Ingresses, sorted by namespace/name.
Ingresses []IngressReport `json:"ingresses"`
// ConfigMaps lists the attributed controller ConfigMaps, sorted by
// namespace/name.
ConfigMaps []ConfigMapReport `json:"configMaps,omitempty"`
// Counts tallies annotation and ConfigMap findings by status.
Counts map[Status]int `json:"counts"`
}
SourceReport groups the audited Ingresses attributed to one source controller.