webhook

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 22 Imported by: 1 module, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webhook contains shared infrastructure for setting up webhook configs and certificates

Index

Constants

View Source
const ConfigDir = "/tmp"

ConfigDir contains the dir with the webhook SSL certs

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConfigName string
	// CertDir is not deleted automatically, so we can re-use the same SSL between operator restarts in production
	CertDir       string
	Certificate   []byte
	Key           []byte
	CaCertificate []byte
	CaKey         []byte
	// contains filtered or unexported fields
}

Config generates certificates and the configuration for the webhook server

func NewConfig

func NewConfig(c client.Client, config *config.Config, generator credsgen.Generator, configName string) *Config

NewConfig returns a new Config

func (*Config) CreateMutationWebhookServerConfig

func (f *Config) CreateMutationWebhookServerConfig(ctx context.Context, name string, webhooks []*OperatorWebhook) error

CreateMutationWebhookServerConfig creates a new config for an array of mutating webhoooks

func (*Config) CreateValidationWebhookServerConfig

func (f *Config) CreateValidationWebhookServerConfig(ctx context.Context, webhooks []*OperatorWebhook) error

CreateValidationWebhookServerConfig creates a new config for an array of validation webhoooks

func (*Config) SetupCertificate

func (f *Config) SetupCertificate(ctx context.Context, prefix string) error

SetupCertificate ensures that a CA and a certificate is available for the webhook server. It caches the certificate data in a secret and writes it as files to `CertDir`, for `webhook.Server` to use.

type OperatorWebhook

type OperatorWebhook struct {
	// Name is the name of the webhook
	Name string
	// Path is the path this webhook will serve.
	Path string
	// Rules maps to the Rules field in admissionregistration.Webhook
	Rules []admissionregistration.RuleWithOperations
	// FailurePolicy maps to the FailurePolicy field in admissionregistration.Webhook
	// This optional. If not set, will be defaulted to Ignore (fail-open) by the server.
	// More details: https://github.com/kubernetes/api/blob/f5c295feaba2cbc946f0bbb8b535fc5f6a0345ee/admissionregistration/v1/types.go#L144-L147
	FailurePolicy admissionregistration.FailurePolicyType
	// NamespaceSelector maps to the NamespaceSelector field in admissionregistration.Webhook
	// This optional.
	NamespaceSelector *metav1.LabelSelector
	// Handlers contains a list of handlers. Each handler may only contains the business logic for its own feature.
	// For example, feature foo and bar can be in the same webhook if all the other configurations are the same.
	// The handler will be invoked sequentially as the order in the list.
	// Note: if you are using mutating webhook with multiple handlers, it's your responsibility to
	// ensure the handlers are not generating conflicting JSON patches.
	Handler admission.Handler
	// Webhook contains the Admission webhook information that we register with the controller runtime.
	Webhook *webhook.Admission
}

OperatorWebhook represents an operator webhook

Jump to

Keyboard shortcuts

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