admissionx

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package admissionx implements Kubernetes-style mutating and validating admission chains. It is intended for framework-level policy hooks, not ad-hoc handler logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(chain Chain) middleware.Middleware

Middleware runs the admission chain before the business handler.

Types

type Attributes

type Attributes struct {
	Request requestx.Info
	Object  any
}

Attributes are the normalized inputs passed to admission plugins.

type Chain

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

Chain is the ordered admission chain.

func New

func New(mutating []MutatingPlugin, validating []ValidatingPlugin) Chain

func (Chain) Admit

func (c Chain) Admit(ctx context.Context, obj any) (any, error)

Admit runs mutating plugins first, then validating plugins.

func (Chain) Empty

func (c Chain) Empty() bool

type MutatingPlugin

type MutatingPlugin interface {
	Name() string
	Admit(ctx context.Context, a Attributes) (any, error)
}

MutatingPlugin may modify or default the request object before validation/business logic.

type MutatingPluginFunc

type MutatingPluginFunc struct {
	PluginName string
	Fn         func(context.Context, Attributes) (any, error)
}

MutatingPluginFunc adapts a function to MutatingPlugin.

func (MutatingPluginFunc) Admit

func (MutatingPluginFunc) Name

func (f MutatingPluginFunc) Name() string

type ValidatingPlugin

type ValidatingPlugin interface {
	Name() string
	Validate(ctx context.Context, a Attributes) error
}

ValidatingPlugin may reject the request after mutation and before business logic.

type ValidatingPluginFunc

type ValidatingPluginFunc struct {
	PluginName string
	Fn         func(context.Context, Attributes) error
}

ValidatingPluginFunc adapts a function to ValidatingPlugin.

func (ValidatingPluginFunc) Name

func (f ValidatingPluginFunc) Name() string

func (ValidatingPluginFunc) Validate

Jump to

Keyboard shortcuts

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