validating

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 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

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 kube.KubernetesClient

	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 kube.KubernetesClient)

func (*WebhookManager) WithValidatingEventHandler

func (m *WebhookManager) WithValidatingEventHandler(handler ValidatingEventHandlerFn)

type WebhookResource

type WebhookResource struct {
	KubeClient        kube.KubernetesClient
	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