webhook

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Overview

Package webhook holds shared code related to routing for webhook admission.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Admit(resp *Response, req *Request) error
}

The Handler type is an adapter to allow admission checking on a given request. Handlers should update the response to control admission.

type HandlerFunc

type HandlerFunc func(resp *Response, req *Request) error

HandlerFunc type is used to add regular functions as Handler.

func (HandlerFunc) Admit

func (h HandlerFunc) Admit(resp *Response, req *Request) error

Admit calls the handler function so that the function conforms to the Handler interface.

type Request

type Request struct {
	v1.AdmissionRequest

	Context     context.Context
	ObjTemplate runtime.Object
}

Request wrapper for an AdmissionRequest.

func (*Request) DecodeObject

func (r *Request) DecodeObject() (runtime.Object, error)

DecodeObject decodes the Object in the request into a new runtime.Object of type specified by Type(). If Type() was not set the runtime.Object will be of type *unstructured.Unstructured.

func (*Request) DecodeOldObject

func (r *Request) DecodeOldObject() (runtime.Object, error)

DecodeOldObject decodes the OldObject in the request into a new runtime.Object of type specified by Type(). If Type() was not set the runtime.Object will be of type *unstructured.Unstructured.

type Response

type Response struct {
	v1.AdmissionResponse
}

Response a wrapper for AdmissionResponses object

func (*Response) CreatePatch

func (r *Response) CreatePatch(request *Request, newObj runtime.Object) error

CreatePatch will patch the Object in the request with the given object. An error will be returned if on subsequent calls to the same request.

type RouteMatch

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

RouteMatch type matching of admission Request to Handlers.

func (*RouteMatch) DryRun

func (r *RouteMatch) DryRun(dryRun bool) *RouteMatch

DryRun matches admission request with the matching DryRun value.

func (*RouteMatch) Group

func (r *RouteMatch) Group(group string) *RouteMatch

Group matches admission request with the matching Group value.

func (*RouteMatch) Handle

func (r *RouteMatch) Handle(handler Handler) *RouteMatch

Handle sets the Handler to be called for matching admission request.

func (*RouteMatch) HandleFunc

func (r *RouteMatch) HandleFunc(handler HandlerFunc) *RouteMatch

HandleFunc sets the handler to be called for matching admission request.

func (*RouteMatch) Kind

func (r *RouteMatch) Kind(kind string) *RouteMatch

Kind matches admission request with the matching Kind value.

func (*RouteMatch) Name

func (r *RouteMatch) Name(name string) *RouteMatch

Name matches admission request with the matching Name value.

func (*RouteMatch) Namespace

func (r *RouteMatch) Namespace(namespace string) *RouteMatch

Namespace matches admission request with the matching Namespace value.

func (*RouteMatch) Operation

func (r *RouteMatch) Operation(operation v1.Operation) *RouteMatch

Operation matches admission request with the matching Operation value.

func (*RouteMatch) Resource

func (r *RouteMatch) Resource(resource string) *RouteMatch

Resource matches admission request with the matching Resource value.

func (*RouteMatch) SubResource

func (r *RouteMatch) SubResource(sr string) *RouteMatch

SubResource matches admission request with the matching SubResource value.

func (*RouteMatch) Type

func (r *RouteMatch) Type(objType runtime.Object) *RouteMatch

Type specifies the runtime.Object to use for decoding.

func (*RouteMatch) Version

func (r *RouteMatch) Version(version string) *RouteMatch

Version matches admission request with the matching Version value.

type Router

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

Router manages request and the calling of matching handlers.

func NewRouter

func NewRouter() *Router

NewRouter returns a newly allocated Router.

func (*Router) DryRun

func (r *Router) DryRun(dryRun bool) *RouteMatch

DryRun matches admission request with the matching DryRun value.

func (*Router) Group

func (r *Router) Group(group string) *RouteMatch

Group matches admission request with the matching Group value.

func (*Router) Handle

func (r *Router) Handle(handler Handler) *RouteMatch

Handle sets the Handler to be called for matching admission request.

func (*Router) HandleFunc

func (r *Router) HandleFunc(hf HandlerFunc) *RouteMatch

HandleFunc sets the handler to be called for matching admission request.

func (*Router) Kind

func (r *Router) Kind(kind string) *RouteMatch

Kind matches admission request with the matching Kind value.

func (*Router) Name

func (r *Router) Name(name string) *RouteMatch

Name matches admission request with the matching Name value.

func (*Router) Namespace

func (r *Router) Namespace(namespace string) *RouteMatch

Namespace matches admission request with the matching Namespace value.

func (*Router) Operation

func (r *Router) Operation(operation v1.Operation) *RouteMatch

Operation matches admission request with the matching Operation value.

func (*Router) Resource

func (r *Router) Resource(resource string) *RouteMatch

Resource matches admission request with the matching Resource value.

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP inspects the http.Request and calls the Admit function on all matching handlers.

func (*Router) SubResource

func (r *Router) SubResource(subResource string) *RouteMatch

SubResource matches admission request with the matching SubResource value.

func (*Router) Type

func (r *Router) Type(objType runtime.Object) *RouteMatch

Type specifies the runtime.Object to use for decoding.

func (*Router) Version

func (r *Router) Version(version string) *RouteMatch

Version matches admission request with the matching Version value.

Jump to

Keyboard shortcuts

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