webhook

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 15

Documentation

Index

Constants

View Source
const NoopMetricsRecorder = noopMetricsRecorder(0)

NoopMetricsRecorder is a no-op metrics recorder.

Variables

This section is empty.

Functions

This section is empty.

Types

type MeasureMutatingOpData

type MeasureMutatingOpData struct {
	MeasureOpCommonData
	Mutated bool
}

MeasureMutatingOpData is the data to measure webhook mutating operation data.

type MeasureOpCommonData

type MeasureOpCommonData struct {
	WebhookID              string
	WebhookType            string
	AdmissionReviewVersion string
	Duration               time.Duration
	Success                bool
	ResourceName           string
	ResourceNamespace      string
	Operation              string
	ResourceKind           string
	DryRun                 bool
	WarningsNumber         int
}

MeasureOpCommonData is the measuring data used to measure a webhook operation.

type MeasureValidatingOpData

type MeasureValidatingOpData struct {
	MeasureOpCommonData
	Allowed bool
}

MeasureValidatingOpData is the data to measure webhook validating operation data.

type MetricsRecorder

type MetricsRecorder interface {
	MeasureValidatingWebhookReviewOp(ctx context.Context, data MeasureValidatingOpData)
	MeasureMutatingWebhookReviewOp(ctx context.Context, data MeasureMutatingOpData)
}

MetricsRecorder knows how to record webhook recorder metrics.

type Webhook

type Webhook interface {
	// The id of the webhook.
	ID() string
	// The kind of the webhook.
	Kind() model.WebhookKind
	// Review will handle the admission review and return the AdmissionResponse with the result of the admission
	// error, mutation...
	Review(ctx context.Context, ar model.AdmissionReview) (model.AdmissionResponse, error)
}

Webhook knows how to handle the admission reviews, in other words Webhook is a dynamic admission webhook for Kubernetes.

func NewMeasuredWebhook

func NewMeasuredWebhook(rec MetricsRecorder, next Webhook) Webhook

NewMeasuredWebhook returns a wrapped webhook that will measure the webhook operations.

func NewTracedWebhook added in v2.2.0

func NewTracedWebhook(tracer tracing.Tracer, next Webhook) Webhook

NewTracedWebhook returns a wrapped webhook that will trace the webhook operations.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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