Documentation ¶
Overview ¶
Package webhook implements utility routines related to Kubernetes' admission webhook.
Index ¶
- Variables
- func AdmissionError(err error) *admissionv1.AdmissionResponse
- func GetAdmissionRequestBody(w http.ResponseWriter, req *http.Request) ([]byte, error)
- func GetListenerIfHasMatchingPort(port gwv1.PortNumber, listeners []gwv1.Listener) *gwv1.Listener
- func IsValidHostname(hostname string) error
- func IsValidIPOrCIDR(value string) []string
- func NewMutatingWebhookConfiguration(webhooks []admissionregv1.MutatingWebhook, meshName, fsmVersion string) *admissionregv1.MutatingWebhookConfiguration
- func NewValidatingWebhookConfiguration(webhooks []admissionregv1.ValidatingWebhook, meshName, fsmVersion string) *admissionregv1.ValidatingWebhookConfiguration
- func RecordAdmissionMetrics(req *admissionv1.AdmissionRequest, resp *admissionv1.AdmissionResponse)
- func ValidateParentRefs(refs []gwv1.ParentReference) field.ErrorList
- func ValidateRouteHostnames(hostnames []gwv1.Hostname) field.ErrorList
- type CertRotatedFunc
- type DefaultWebhook
- func (r *DefaultWebhook) Default(_ context.Context, _ runtime.Object) error
- func (r *DefaultWebhook) GetCategory() string
- func (r *DefaultWebhook) GetWebhookConfigurations() (mwebhooks []admissionregv1.MutatingWebhook, ...)
- func (r *DefaultWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error)
- func (r *DefaultWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error)
- func (r *DefaultWebhook) ValidateUpdate(_ context.Context, _, _ runtime.Object) (warnings admission.Warnings, err error)
- type Server
Constants ¶
This section is empty.
Variables ¶
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 ¶
GetAdmissionRequestBody returns the body of the admission request
func GetListenerIfHasMatchingPort ¶ added in v1.2.0
func IsValidHostname ¶ added in v1.1.0
IsValidHostname validates the hostname of gateway route resource
func IsValidIPOrCIDR ¶ added in v1.2.0
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
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
type DefaultWebhook struct { whtypes.Register *whtypes.RegisterConfig client.Client CfgBuilder *builder.WebhookConfigurationBuilder }
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 (*DefaultWebhook) ValidateDelete ¶ added in v1.4.0
func (*DefaultWebhook) ValidateUpdate ¶ added in v1.4.0
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.