Documentation
¶
Index ¶
- Constants
- Variables
- func InitFromFlags(configName, serviceName, certPath, keyPath, caPath string, clientCAs []string, ...)
- type Event
- type EventHandlerFn
- type IWebhookConfig
- type Metadata
- type MutatingWebhookConfig
- type MutatingWebhookResource
- type Response
- type ValidatingWebhookConfig
- type ValidatingWebhookResource
- type WebhookHandler
- type WebhookManager
- func (m *WebhookManager) AddMutatingWebhook(config *MutatingWebhookConfig)
- func (m *WebhookManager) AddValidatingWebhook(config *ValidatingWebhookConfig)
- func (m *WebhookManager) Init() error
- func (m *WebhookManager) Start() error
- func (m *WebhookManager) WithAdmissionEventHandler(handler EventHandlerFn)
- type WebhookResourceOptions
- type WebhookSettings
Constants ¶
View Source
const DefaultConfigurationId = "hooks"
DefaultConfigurationId is a ConfigurationId for ValidatingWebhookConfiguration/MutatingWebhookConfiguration without suffix.
Variables ¶
View Source
var DefaultSettings = &WebhookSettings{ Settings: server.Settings{ ServerCertPath: app.ValidatingServerCertPathDefault, ServerKeyPath: app.ValidatingServerKeyPathDefault, ClientCAPaths: nil, ServiceName: app.ValidatingServiceNameDefault, ListenAddr: app.ValidatingListenAddrDefault, ListenPort: app.ValidatingListenPortDefault, }, CAPath: app.ValidatingCAPathDefault, ConfigurationName: app.ValidatingConfigurationNameDefault, DefaultFailurePolicy: app.ValidatingFailurePolicyTypeDefault, }
DefaultSettings returns default settings for validating webhook This is initialized at startup and can be modified by flag parsing
Functions ¶
func InitFromFlags ¶ added in v1.12.3
func InitFromFlags(configName, serviceName, certPath, keyPath, caPath string, clientCAs []string, failurePolicy, port, addr string)
InitFromFlags updates DefaultSettings with values from parsed flags
Types ¶
type Event ¶ added in v1.4.12
type Event struct {
WebhookId string
ConfigurationId string
Request *v1.AdmissionRequest
}
type EventHandlerFn ¶ added in v1.4.12
type IWebhookConfig ¶
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 (w *MutatingWebhookResource) Get(id string) *MutatingWebhookConfig
func (*MutatingWebhookResource) Register ¶
func (w *MutatingWebhookResource) Register() error
func (*MutatingWebhookResource) Set ¶
func (w *MutatingWebhookResource) Set(whc *MutatingWebhookConfig)
func (*MutatingWebhookResource) Unregister ¶
func (w *MutatingWebhookResource) Unregister() error
type Response ¶ added in v1.4.12
type Response struct {
Allowed bool `json:"allowed"`
Message string `json:"message,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Patch []byte `json:"patch,omitempty"`
}
func ResponseFromBytes ¶ added in v1.4.12
func ResponseFromFile ¶ added in v1.4.12
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 NewValidatingWebhookResource ¶
func NewValidatingWebhookResource(opts WebhookResourceOptions) *ValidatingWebhookResource
func (*ValidatingWebhookResource) Get ¶
func (w *ValidatingWebhookResource) Get(id string) *ValidatingWebhookConfig
func (*ValidatingWebhookResource) Register ¶
func (w *ValidatingWebhookResource) Register() error
func (*ValidatingWebhookResource) Set ¶
func (w *ValidatingWebhookResource) Set(whc *ValidatingWebhookConfig)
func (*ValidatingWebhookResource) Unregister ¶
func (w *ValidatingWebhookResource) Unregister() error
type WebhookHandler ¶
type WebhookHandler struct {
Router chi.Router
Handler EventHandlerFn
}
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) Start ¶
func (m *WebhookManager) Start() error
func (*WebhookManager) WithAdmissionEventHandler ¶
func (m *WebhookManager) WithAdmissionEventHandler(handler EventHandlerFn)
type WebhookResourceOptions ¶
Click to show internal directories.
Click to hide internal directories.