webhook

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package webhook implements utility routines related to Kubernetes' admission webhook.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ContentTypeJSON is the supported content type for HTTP requests
	ContentTypeJSON = "application/json"

	// HTTPHeaderContentType is the Content-Type HTTP header key
	HTTPHeaderContentType = "Content-Type"

	// Deserializer is used to decode the admission request body
	Deserializer = codecs.UniversalDeserializer()
)

Functions

func AdmissionError

func AdmissionError(err error) *admissionv1.AdmissionResponse

AdmissionError wraps error as AdmissionResponse

func GetAdmissionRequestBody

func GetAdmissionRequestBody(w http.ResponseWriter, req *http.Request) ([]byte, error)

GetAdmissionRequestBody returns the body of the admission request

func GetListenerIfHasMatchingPort added in v1.2.0

func GetListenerIfHasMatchingPort(port gwv1.PortNumber, listeners []gwv1.Listener) *gwv1.Listener

func IsValidHostname added in v1.1.0

func IsValidHostname(hostname string) error

IsValidHostname validates the hostname of gateway route resource

func IsValidIPOrCIDR added in v1.2.0

func IsValidIPOrCIDR(value string) []string

IsValidIPOrCIDR tests that the argument is a valid IP address.

func NewMutatingWebhookConfiguration added in v1.4.0

func NewMutatingWebhookConfiguration(webhooks []admissionregv1.MutatingWebhook, meshName, fsmVersion string) *admissionregv1.MutatingWebhookConfiguration

NewMutatingWebhookConfiguration creates a new MutatingWebhookConfiguration

func NewValidatingWebhookConfiguration added in v1.4.0

func NewValidatingWebhookConfiguration(webhooks []admissionregv1.ValidatingWebhook, meshName, fsmVersion string) *admissionregv1.ValidatingWebhookConfiguration

NewValidatingWebhookConfiguration creates a new ValidatingWebhookConfiguration

func RecordAdmissionMetrics

func RecordAdmissionMetrics(req *admissionv1.AdmissionRequest, resp *admissionv1.AdmissionResponse)

RecordAdmissionMetrics records metrics for the given admission response

func ValidateParentRefs added in v1.1.0

func ValidateParentRefs(refs []gwv1.ParentReference) field.ErrorList

ValidateParentRefs validates the parent refs of gateway route resource

func ValidateRouteHostnames added in v1.1.0

func ValidateRouteHostnames(hostnames []gwv1.Hostname) field.ErrorList

ValidateRouteHostnames validates the hostnames of gateway route resource

Types

type CertRotatedFunc

type CertRotatedFunc func(cert *certificate.Certificate) error

CertRotatedFunc is a callback to perform other actions when the server's HTTPS cert gets rotated.

type DefaultWebhook added in v1.4.0

func (*DefaultWebhook) Default added in v1.4.0

func (r *DefaultWebhook) Default(_ context.Context, _ runtime.Object) error

func (*DefaultWebhook) GetCategory added in v1.4.0

func (r *DefaultWebhook) GetCategory() string

func (*DefaultWebhook) GetWebhookConfigurations added in v1.4.0

func (r *DefaultWebhook) GetWebhookConfigurations() (mwebhooks []admissionregv1.MutatingWebhook, vwebhooks []admissionregv1.ValidatingWebhook)

func (*DefaultWebhook) ValidateCreate added in v1.4.0

func (r *DefaultWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error)

func (*DefaultWebhook) ValidateDelete added in v1.4.0

func (r *DefaultWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error)

func (*DefaultWebhook) ValidateUpdate added in v1.4.0

func (r *DefaultWebhook) ValidateUpdate(_ context.Context, _, _ runtime.Object) (warnings admission.Warnings, err error)

type Server

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

Server is a construct to run generic HTTPS webhook servers.

func NewServer

func NewServer(name, namespace string, port int, cm *certificate.Manager, handlers map[string]http.HandlerFunc, onCertChange CertRotatedFunc) (*Server, error)

NewServer returns a new server based on the input. Run() must be called to start the server.

func (*Server) Run

func (s *Server) Run(ctx context.Context)

Run actually starts the server. It blocks until the passed in context is done.

Directories

Path Synopsis
extension
gatewayapi
v1
mcs
policyattachment
Package types is a generated GoMock package.
Package types is a generated GoMock package.

Jump to

Keyboard shortcuts

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