validating

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigurationId = "hooks"

DefaultConfigurationId is a ConfigurationId for ValidatingWebhookConfiguration without suffix.

Variables

This section is empty.

Functions

func DetectConfigurationAndWebhook

func DetectConfigurationAndWebhook(path string) (configurationID string, webhookID string)

DetectConfigurationAndWebhook extracts configurationID and a webhookID from the url path.

Types

type ValidatingEventHandlerFn

type ValidatingEventHandlerFn func(event ValidatingEvent) (*ValidatingResponse, error)

type ValidatingWebhookConfig

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

ValidatingWebhookConfig

func (*ValidatingWebhookConfig) UpdateIds

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

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

type WebhookHandler

type WebhookHandler struct {
	Manager *WebhookManager
	Router  chi.Router
}

func NewWebhookHandler

func NewWebhookHandler() *WebhookHandler

func (*WebhookHandler) HandleReviewRequest

func (h *WebhookHandler) HandleReviewRequest(path string, body []byte) (*v1.AdmissionReview, error)

func (*WebhookHandler) ServeReviewRequest

func (h *WebhookHandler) ServeReviewRequest(w http.ResponseWriter, r *http.Request)

type WebhookManager

type WebhookManager struct {
	KubeClient klient.Client

	ValidatingEventHandlerFn ValidatingEventHandlerFn

	Settings  *WebhookSettings
	Namespace string

	DefaultConfigurationId string

	Server    *server.WebhookServer
	Resources map[string]*WebhookResource
	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

func NewWebhookManager

func NewWebhookManager() *WebhookManager

func (*WebhookManager) AddWebhook

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

func (*WebhookManager) Init

func (m *WebhookManager) Init() error

Init creates dependencies

func (*WebhookManager) Start

func (m *WebhookManager) Start() error

func (*WebhookManager) WithKubeClient

func (m *WebhookManager) WithKubeClient(kubeClient klient.Client)

func (*WebhookManager) WithValidatingEventHandler

func (m *WebhookManager) WithValidatingEventHandler(handler ValidatingEventHandlerFn)

type WebhookResource

type WebhookResource struct {
	KubeClient        klient.Client
	Webhooks          map[string]*ValidatingWebhookConfig
	Namespace         string
	ConfigurationName string
	ServiceName       string
	CABundle          []byte
}

func NewWebhookResource

func NewWebhookResource() *WebhookResource

func (*WebhookResource) AddWebhook

func (w *WebhookResource) AddWebhook(config *ValidatingWebhookConfig)

func (*WebhookResource) CreateConfiguration

func (w *WebhookResource) CreateConfiguration() error

func (*WebhookResource) CreateOrUpdateConfiguration

func (w *WebhookResource) CreateOrUpdateConfiguration(conf *v1.ValidatingWebhookConfiguration) error

func (*WebhookResource) CreateWebhookPath

func (w *WebhookResource) CreateWebhookPath(webhook *ValidatingWebhookConfig) *string

func (*WebhookResource) DeleteConfiguration

func (w *WebhookResource) DeleteConfiguration() error

func (*WebhookResource) UpdateConfiguration

func (w *WebhookResource) UpdateConfiguration() error

type WebhookSettings

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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