guard

package
v1.31.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package guard provides admission control logic for ensuring resources are properly defaulted and validated before reconciliation, even when webhooks are not installed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admission

type Admission[T AdmittableObject] struct {
	Defaulter admission.Defaulter[T]
	Validator admission.Validator[T]
}

Admission provides admission control capabilities by wrapping defaulting and validation webhooks for use in controller reconciliation loops.

func (*Admission[T]) EnsureResourceIsAdmitted

func (g *Admission[T]) EnsureResourceIsAdmitted(ctx context.Context, params AdmissionParams[T]) (ctrl.Result, error)

EnsureResourceIsAdmitted ensures that a resource has been properly defaulted and validated according to the admission webhooks, applying changes if necessary when webhooks are not installed.

type AdmissionParams

type AdmissionParams[T AdmittableObject] struct {
	Object T
	Client client.Client

	// ApplyChanges must be true only in the reconciler that owns writes to the
	// object. When true, defaulting changes are persisted and validation
	// failures are recorded in the status. When false (for example the instance
	// manager reconciling a Cluster it does not own), the guard works in memory
	// only and waits for the owning reconciler to apply the changes.
	ApplyChanges bool
}

AdmissionParams contains the parameters needed to perform admission control on a resource during reconciliation.

type AdmittableObject

type AdmittableObject interface {
	client.Object

	// SetAdmissionError records the admission validation error on the status,
	// or clears it when msg is empty.
	SetAdmissionError(msg string)

	// GetAdmissionError returns the admission validation error currently
	// recorded on the status, when the guard is responsible for clearing it.
	// Types whose admission error is cleared by their own reconciler (for
	// example through the phase machinery) return an empty string, so the
	// guard does not race that logic by persisting the clear itself.
	GetAdmissionError() string
}

AdmittableObject represents a Kubernetes object that can be admitted through the guard admission control process, allowing admission errors to be set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL