Documentation
¶
Overview ¶
Package dryrunvalidator implements the DryRunValidator that performs dry-run reconciliation for webhook validation.
The validator is called synchronously by pkg/controller/webhook via ValidateDirect. It creates an overlay store simulating the admission request's hypothetical state and delegates to ProposalValidator.ValidateSync for rendering and validation.
Index ¶
Constants ¶
const ComponentName = "dryrun-validator"
ComponentName identifies this validator in log records.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements the dry-run validator.
It creates store overlays from admission requests and delegates validation to ProposalValidator. After a successful dry-run, it dispatches the rendered file set to any configured pluggable validators (e.g. the SPOA hub running in --validate-socket mode); their errors deny admission with line/col-precise diagnostics, their warnings flow up to the webhook handler unchanged.
func (*Component) ValidateDirect ¶
func (c *Component) ValidateDirect(ctx context.Context, gvk, namespace, name string, object any, operation string) (allowed bool, reason string, warnings []string)
ValidateDirect performs synchronous dry-run validation.
Parameters:
- ctx: Context for cancellation and timeout
- gvk: GroupVersionKind string (e.g., "networking.k8s.io/v1.Ingress")
- namespace: Resource namespace
- name: Resource name
- object: The Kubernetes resource object
- operation: Admission operation (CREATE, UPDATE, DELETE)
Returns:
- allowed: Whether the resource passed validation
- reason: Denial reason if not allowed, empty otherwise
- warnings: Soft warnings from pluggable validators, surfaced via AdmissionResponse.Warnings on both allow and deny paths
type ComponentConfig ¶
type ComponentConfig struct {
// ProposalValidator is the component that performs render-validate pipeline.
ProposalValidator *proposalvalidator.Component
// RESTMapper resolves an admission request's GVK to the watched
// resource's plural (the overlay store key) using the cluster's
// discovery data. This keeps the validator resource-agnostic: any
// watched CRD — including one with an irregular or custom plural —
// resolves correctly, with no hardcoded pluralization table (RULE #1).
RESTMapper meta.RESTMapper
// Logger is the structured logger.
Logger *slog.Logger
// PluggableValidator is the optional pluggable-validator manager that
// dispatches the rendered file set to external validator sidecars
// (e.g. the SPOA hub running in --validate-socket mode). Nil disables
// the dispatch entirely. When non-nil but Configured() returns false
// (no validators in the CRD), the manager's ValidateAll is a no-op,
// so callers don't need to pre-check before wiring this in.
PluggableValidator *pluggablevalidator.Manager
}
ComponentConfig contains configuration for creating a DryRunValidator.