webhook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

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

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 RecordAdmissionMetrics

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

RecordAdmissionMetrics records metrics for the given admission response

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 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.

Jump to

Keyboard shortcuts

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