admission

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultConfigurationId = "hooks"

DefaultConfigurationId is a ConfigurationId for ValidatingWebhookConfiguration/MutatingWebhookConfiguration without suffix.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmissionEventHandlerFn

type AdmissionEventHandlerFn func(event AdmissionEvent) (*AdmissionResponse, error)

type IWebhookConfig

type IWebhookConfig interface {
	GetMeta() Metadata
	SetMeta(Metadata)
	SetClientConfig(v1.WebhookClientConfig)
	UpdateIds(string, string)
}

type Metadata

type Metadata struct {
	Name            string
	WebhookId       string
	ConfigurationId string // A suffix to create different ValidatingWebhookConfiguration/MutatingWebhookConfiguration resources.
	DebugName       string
	LogLabels       map[string]string
	MetricLabels    map[string]string
}

type MutatingWebhookConfig

type MutatingWebhookConfig struct {
	*v1.MutatingWebhook
	Metadata
}

func (*MutatingWebhookConfig) GetMeta

func (c *MutatingWebhookConfig) GetMeta() Metadata

func (*MutatingWebhookConfig) SetClientConfig

func (c *MutatingWebhookConfig) SetClientConfig(cc v1.WebhookClientConfig)

func (*MutatingWebhookConfig) SetMeta

func (c *MutatingWebhookConfig) SetMeta(m Metadata)

func (*MutatingWebhookConfig) UpdateIds

func (c *MutatingWebhookConfig) UpdateIds(confID, webhookID string)

type MutatingWebhookResource

type MutatingWebhookResource struct {
	// contains filtered or unexported fields
}

func NewMutatingWebhookResource

func NewMutatingWebhookResource(opts WebhookResourceOptions) *MutatingWebhookResource

func (*MutatingWebhookResource) Get

func (*MutatingWebhookResource) Register

func (w *MutatingWebhookResource) Register() error

func (*MutatingWebhookResource) Set

func (*MutatingWebhookResource) Unregister

func (w *MutatingWebhookResource) Unregister() error

type ValidatingWebhookConfig

type ValidatingWebhookConfig struct {
	*v1.ValidatingWebhook
	Metadata
}

func (*ValidatingWebhookConfig) GetMeta

func (c *ValidatingWebhookConfig) GetMeta() Metadata

func (*ValidatingWebhookConfig) SetClientConfig

func (c *ValidatingWebhookConfig) SetClientConfig(cc v1.WebhookClientConfig)

func (*ValidatingWebhookConfig) SetMeta

func (c *ValidatingWebhookConfig) SetMeta(m Metadata)

func (*ValidatingWebhookConfig) UpdateIds

func (c *ValidatingWebhookConfig) UpdateIds(confID, webhookID string)

UpdateIds use confId and webhookId to set a ConfigurationId prefix and a WebhookId.

type ValidatingWebhookResource

type ValidatingWebhookResource struct {
	// contains filtered or unexported fields
}

func (*ValidatingWebhookResource) Get

func (*ValidatingWebhookResource) Register

func (w *ValidatingWebhookResource) Register() error

func (*ValidatingWebhookResource) Set

func (*ValidatingWebhookResource) Unregister

func (w *ValidatingWebhookResource) Unregister() error

type WebhookHandler

type WebhookHandler struct {
	Router  chi.Router
	Handler AdmissionEventHandlerFn
}

func NewWebhookHandler

func NewWebhookHandler() *WebhookHandler

type WebhookManager

type WebhookManager struct {
	KubeClient *klient.Client

	Settings  *WebhookSettings
	Namespace string

	DefaultConfigurationId string

	Server              *server.WebhookServer
	ValidatingResources map[string]*ValidatingWebhookResource
	MutatingResources   map[string]*MutatingWebhookResource
	Handler             *WebhookHandler
}

WebhookManager is a public interface to be used from operator.go.

No dynamic configuration for now. The steps are:

  • Init manager
  • Call AddWebhook for every binding in hooks
  • Start() to run server and create ValidatingWebhookConfiguration/MutatingWebhookConfiguration

func NewWebhookManager

func NewWebhookManager(kubeClient *klient.Client) *WebhookManager

func (*WebhookManager) AddMutatingWebhook

func (m *WebhookManager) AddMutatingWebhook(config *MutatingWebhookConfig)

func (*WebhookManager) AddValidatingWebhook

func (m *WebhookManager) AddValidatingWebhook(config *ValidatingWebhookConfig)

func (*WebhookManager) Init

func (m *WebhookManager) Init() error

Init creates dependencies

func (*WebhookManager) Start

func (m *WebhookManager) Start() error

func (*WebhookManager) WithAdmissionEventHandler

func (m *WebhookManager) WithAdmissionEventHandler(handler AdmissionEventHandlerFn)

type WebhookResourceOptions

type WebhookResourceOptions struct {
	KubeClient        *klient.Client
	Namespace         string
	ConfigurationName string
	ServiceName       string
	CABundle          []byte
}

type WebhookSettings

type WebhookSettings struct {
	server.Settings
	CAPath               string
	CABundle             []byte
	ConfigurationName    string
	DefaultFailurePolicy string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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