admission

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package admission provides shared admission-webhook helpers: decode/dispatch/encode, allow/deny builders, and JSON patch utilities.

Index

Constants

View Source
const DefaultMaxBody int64 = 10 << 20

DefaultMaxBody is the request-body ceiling Serve applies when the caller passes 0.

Variables

This section is empty.

Functions

func Allow

Allow returns an AdmissionResponse that permits the request.

func Decode

func Decode(r *http.Request, maxBytes int64) (*admissionv1.AdmissionReview, error)

Decode parses an AdmissionReview from r, using DefaultMaxBody when maxBytes <= 0.

func Deny

Deny returns a forbidden AdmissionResponse with the given message.

func EscapeJSONPointer

func EscapeJSONPointer(s string) string

EscapeJSONPointer escapes ~ and / per RFC 6901 for use in patch paths.

func MarshalPatch

func MarshalPatch(ops []JSONPatchOp) ([]byte, error)

MarshalPatch encodes patch ops as JSON for AdmissionResponse.Patch.

func Serve

func Serve(w http.ResponseWriter, r *http.Request, maxBytes int64, handler Handler)

Serve decodes an AdmissionReview, dispatches to handler, and writes the response.

Types

type Handler

Handler is the admission callback. A nil return is treated as Allow().

type JSONPatchOp

type JSONPatchOp struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value any    `json:"value,omitempty"`
}

JSONPatchOp represents a single RFC 6902 JSON Patch operation.

Jump to

Keyboard shortcuts

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