Help us shape the future of Go! Take the 2026 Go Developer Survey

admission

package
v1.21.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceUnset = errors.New("internal error: admission request Resource field is unset")

ErrResourceUnset is returned by plugins that gate on AdmissionRequest.Resource when that field is the zero value.

A real kube-apiserver always populates Resource, so this should only trip for hand-crafted AdmissionReviews, e.g. one POSTed directly to the webhook endpoint, or generated by a non-conformant aggregated/virtual apiserver.

Plugins must check IsResourceUnset and return this error instead of falling through to their usual "this isn't the resource I care about, skip" gate: a zero-valued Resource never matches any plugin's gate, so silently skipping would let the request through Allowed rather than denying it.

Functions

func DecodeRawUnstructured added in v1.15.0

func DecodeRawUnstructured(rawObj runtime.RawExtension, rawKind schema.GroupVersionKind) (*unstructured.Unstructured, error)

DecodeRawUnstructured decodes a RawExtension object into an unstructured object.

func IsResourceUnset added in v1.21.2

func IsResourceUnset(gvr metav1.GroupVersionResource) bool

IsResourceUnset reports whether gvr is the zero value.

func NewCustomMutationWebhook added in v1.15.0

func NewCustomMutationWebhook(
	mutationWebhook MutationInterface,
) *admission.Webhook

func NewCustomValidationWebhook added in v1.15.0

func NewCustomValidationWebhook(
	scheme *runtime.Scheme,
	validationWebhook ValidationInterface,
) *admission.Webhook

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(ops ...admissionv1.Operation) *Handler

func (Handler) Handles

func (h Handler) Handles(operation admissionv1.Operation) bool

type Interface

type Interface interface {
	Handles(admissionv1.Operation) bool
}

Interface is the base admission interface

type MutationInterface

type MutationInterface interface {
	Interface

	Mutate(ctx context.Context, request admissionv1.AdmissionRequest, obj *unstructured.Unstructured) (err error)
}

MutationInterface defines an admission handler that validates requests. It may not perform any kind of mutation.

type PluginChain

type PluginChain []Interface

func (PluginChain) Handles

func (pc PluginChain) Handles(operation admissionv1.Operation) bool

func (PluginChain) Mutate

func (PluginChain) Validate

func (pc PluginChain) Validate(ctx context.Context, request admissionv1.AdmissionRequest, oldObj, obj runtime.Object) ([]string, error)

type ValidationInterface

type ValidationInterface interface {
	Interface

	Validate(ctx context.Context, request admissionv1.AdmissionRequest, oldObj, obj runtime.Object) (warnings []string, err error)
}

ValidationInterface defines an admission handler that validates requests. It may not perform any kind of mutation.

Jump to

Keyboard shortcuts

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