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 and returns the shared pipeline's diagnostics.
func New ¶
func New(cfg *ComponentConfig) (*Component, error)
New creates a new DryRunValidator component.
func (*Component) ValidateDirect ¶
func (c *Component) ValidateDirect(ctx context.Context, gvk, namespace, name string, object, oldObject 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 proposed Kubernetes resource object
- oldObject: The existing object for UPDATE and DELETE
- operation: Admission operation (CREATE, UPDATE, DELETE)
Returns:
- allowed: Whether the resource passed validation
- reason: Denial reason if not allowed, empty otherwise
- warnings: Pipeline warnings surfaced through AdmissionResponse.Warnings
type ComponentConfig ¶
type ComponentConfig struct {
ProposalValidator *proposalvalidator.Service
// RESTMapper resolves an admission request's GVK to its GVR.
RESTMapper meta.RESTMapper
// WatchedResources defines the configured store aliases for each GVR.
WatchedResources map[string]config.WatchedResource
// Logger is the structured logger.
Logger *slog.Logger
}
ComponentConfig contains configuration for creating a DryRunValidator.