webhook

package
v0.0.0-...-52cd4e6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package webhook validate the request

Package webhook validate the request

Package webhook validate the request

Package webhook validate the request

Package webhook validate/mutate the request

Package webhook provide configuration for volume provider

Index

Constants

View Source
const (
	// AdmissionWebHookValidating is for validate webhook
	AdmissionWebHookValidating AdmissionWebHookType = "validating"

	// ClaimBoundFinalizer used when storageBackendClaim bound to a storageBackendContent
	ClaimBoundFinalizer string = "storagebackend.xuanwu.huawei.io/storagebackendclaim-bound-protection"
)

Variables

AdmitFunc handles a v1 admission

View Source
var Codecs = serializer.NewCodecFactory(scheme)

Codecs means a code factory

Functions

func CreateCertSecrets

func CreateCertSecrets(ctx context.Context, webHookCfg WebHook, cert, key []byte, ns string) (*v1.Secret, error)

CreateCertSecrets creates k8s secret to store signed cert data

func CreateValidateWebhook

func CreateValidateWebhook(ctx context.Context, admissionWebhook AdmissionWebHookCFG,
	caBundle []byte, ns string) error

CreateValidateWebhook create new webhook config if not exist already

func GenerateCertificate

func GenerateCertificate(ctx context.Context, cn string, dnsName string) ([]byte, []byte, error)

GenerateCertificate Self Signed certificate using given CN, returns x509 cert and priv key in PEM format

func GetStorageWebHookCfg

func GetStorageWebHookCfg() (WebHook, []AdmissionWebHookCFG)

GetStorageWebHookCfg used to get storage webhook configuration

func GetTLSCertificate

func GetTLSCertificate(cert, priv []byte) (tls.Certificate, error)

GetTLSCertificate from pub and priv key

Types

type AdmissionRule

type AdmissionRule struct {
	APIGroups   []string
	APIVersions []string
	Resources   []string
}

AdmissionRule includes admission rules

type AdmissionWebHookCFG

type AdmissionWebHookCFG struct {
	WebhookName   string
	ServiceName   string
	WebhookPath   string
	WebhookPort   int32
	AdmissionOps  []admissionV1.OperationType
	AdmissionRule AdmissionRule
}

AdmissionWebHookCFG defines cfg of admission webhook

type AdmissionWebHookType

type AdmissionWebHookType string

AdmissionWebHookType is the type of the webhook

type Controller

type Controller struct {
	Recorder record.EventRecorder
	// contains filtered or unexported fields
}

Controller include webhook resources

func (*Controller) Start

func (c *Controller) Start(ctx context.Context, webHookCfg WebHook, admissionWebhooks []AdmissionWebHookCFG) error

Start uses to start the webhook server

func (*Controller) Stop

func (c *Controller) Stop(ctx context.Context, webHookCfg WebHook,
	admissionWebhooks []AdmissionWebHookCFG) error

Stop uses to stop the webhook server

type HandleFuncPair

type HandleFuncPair struct {
	WebhookPath string
	WebHookFunc func(admissionV1.AdmissionReview) *admissionV1.AdmissionResponse
}

HandleFuncPair uses for add handle func

type WebHook

type WebHook struct {
	NamespaceEnv     string
	DefaultNamespace string
	ServiceName      string
	SecretName       string

	WebHookPort int
	// address of webhook server
	WebHookAddress string
	WebHookType    AdmissionWebHookType

	PrivateKey     string
	PrivateCert    string
	HandleFuncPair []HandleFuncPair
}

WebHook uses to start the webhook server

Jump to

Keyboard shortcuts

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