Documentation
¶
Index ¶
Constants ¶
const ( // KindMissing marks an OpenAPI request parameter that appeared in the // metadata after the drift baseline was recorded and that the binding // request does not cover. A newly added API parameter shows up here until // the resource spec models it. KindMissing = "missing" // KindRemoved marks a request parameter the binding still maps although the // OpenAPI metadata no longer declares it after the baseline was recorded. // This can indicate a renamed or dropped parameter, or simply that the // embedded metadata snapshot is incomplete. It blocks the check until the // removal is investigated and intentionally recorded in a fresh baseline. KindRemoved = "removed" // KindUncovered marks a request parameter the binding covered when the // baseline was recorded but no longer maps. It catches coverage // regressions — a mapping deleted from an existing binding — that a purely // incremental metadata diff could not observe. KindUncovered = "uncovered" )
Item kinds.
Variables ¶
This section is empty.
Functions ¶
func WriteBaseline ¶
WriteBaseline persists a baseline file atomically: it writes a temporary file in the target directory and renames it over the destination, so an interrupted write never leaves a truncated baseline.
Types ¶
type Baseline ¶
type Baseline struct {
Language string `json:"language"`
Bindings []BaselineBinding `json:"bindings"`
}
Baseline is the checked-in snapshot of the OpenAPI metadata leaf sets and request coverage for every diffable binding.
func CollectBaseline ¶
CollectBaseline walks every resource spec under specDir and records the current OpenAPI metadata parameter leaves and request coverage for each diffable binding.
func LoadBaseline ¶
LoadBaseline reads a baseline file.
type BaselineBinding ¶
type BaselineBinding struct {
Product string `json:"product"`
Resource string `json:"resource"`
Binding string `json:"binding"`
API string `json:"api"`
Parameters []string `json:"parameters"`
Covered []string `json:"covered"`
}
BaselineBinding records both sides of a binding's state when the baseline was written: the OpenAPI metadata parameter leaves, and the related request keys the binding actually covered. Freezing both lets the detector observe coverage regressions (mapped before, not mapped now) in addition to metadata change without treating spec-only bookkeeping as OpenAPI coverage.
type Item ¶
type Item struct {
Product string `json:"product"`
Resource string `json:"resource"`
Binding string `json:"binding"`
API string `json:"api"`
Param string `json:"param"`
Kind string `json:"kind"`
Type string `json:"type,omitempty"`
Required bool `json:"required,omitempty"`
Position string `json:"position,omitempty"`
Description string `json:"description,omitempty"`
}
Item is one baseline-versus-current difference for a single binding.
type Options ¶
type Options struct {
// Language selects the OpenAPI metadata language used for parameter
// descriptions. Defaults to "en".
Language string
}
Options configures a detection run.
type Report ¶
type Report struct {
Language string `json:"language"`
Items []Item `json:"items"`
Skipped []Skipped `json:"skipped_bindings,omitempty"`
BindingsChecked int `json:"bindings_checked"`
// BaselineGaps counts bindings whose OpenAPI metadata resolves but whose
// baseline entry is missing, so they escaped the diff entirely.
BaselineGaps int `json:"baseline_gaps,omitempty"`
}
Report is the complete result of a drift detection run.
func Detect ¶
Detect loads every resource spec under specDir, compares each binding's request coverage and the recorded baseline against the current OpenAPI metadata, and returns the drift report.
func DetectResources ¶
func DetectResources(resources []spec.ResourceSpec, baseline Baseline, opts Options) (Report, error)
DetectResources diffs the given resource specs against the metadata, relative to the recorded baseline.
type Skipped ¶
type Skipped struct {
Product string `json:"product"`
Resource string `json:"resource"`
Binding string `json:"binding"`
API string `json:"api"`
Reason string `json:"reason"`
}
Skipped records a binding that could not be diffed because the OpenAPI metadata or the drift baseline does not cover it.