Documentation ¶
Index ¶
Constants ¶
const ( // ModeFlag is the name of the command line flag to specify the webhook config mode. ModeFlag = "webhook-config-mode" // URLFlag is the name of the command line flag to specify the URL that is used to register the webhooks in Kubernetes. URLFlag = "webhook-config-url" // ServicePortFlag is the name of the command line flag to specify the service port that exposes the webhook server. // If not specified it will fallback to the webhook server port. ServicePortFlag = "webhook-config-service-port" // NamespaceFlag is the name of the command line flag to specify the webhook config namespace for 'service' mode. NamespaceFlag = "webhook-config-namespace" )
const DisableFlag = "disable-webhooks"
DisableFlag is the name of the command line flag to disable individual webhooks.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddToManagerConfig ¶
type AddToManagerConfig struct { Server ServerConfig Switch SwitchConfig // contains filtered or unexported fields }
AddToManagerConfig is a completed AddToManager configuration.
func (*AddToManagerConfig) AddToManager ¶
func (c *AddToManagerConfig) AddToManager(mgr manager.Manager) ([]admissionregistrationv1beta1.MutatingWebhook, []admissionregistrationv1beta1.MutatingWebhook, error)
AddToManager instantiates all webhooks of this configuration. If there are any webhooks, it creates a webhook server, registers the webhooks and adds the server to the manager. Otherwise, it is a no-op. It generates and registers the seed targeted webhooks via a Mutatingwebhookconfiguration.
type AddToManagerOptions ¶
type AddToManagerOptions struct { Server ServerOptions Switch SwitchOptions // contains filtered or unexported fields }
AddToManagerOptions are options to create an `AddToManager` function from ServerOptions and SwitchOptions.
func NewAddToManagerOptions ¶
func NewAddToManagerOptions(serverName string, serverOpts *ServerOptions, switchOpts *SwitchOptions) *AddToManagerOptions
NewAddToManagerOptions creates new AddToManagerOptions with the given server name, server, and switch options. It is supposed to be used for webhooks which should be automatically registered in the cluster via a Mutatingwebhookconfiguration.
func (*AddToManagerOptions) AddFlags ¶
func (c *AddToManagerOptions) AddFlags(fs *pflag.FlagSet)
AddFlags implements Option.
func (*AddToManagerOptions) Complete ¶
func (c *AddToManagerOptions) Complete() error
Complete implements Option.
func (*AddToManagerOptions) Completed ¶
func (c *AddToManagerOptions) Completed() *AddToManagerConfig
Completed returns the completed AddToManagerConfig. Only call this if a previous call to `Complete` succeeded.
type AddToManagerSimple ¶
type AddToManagerSimple struct {
Switch SwitchConfig
}
AddToManagerSimple is a completed AddToManager configuration w/o webhook registration.
func (*AddToManagerSimple) AddToManager ¶
func (s *AddToManagerSimple) AddToManager(mgr manager.Manager) error
AddToManager makes the configured webhooks known to the given manager. The registration for these webhooks must happen separately via Validatingwebhookconfiguration or Mutatingwebhookconfiguration.
type AddToManagerSimpleOptions ¶
type AddToManagerSimpleOptions struct {
Switch SwitchOptions
}
AddToManagerSimpleOptions are options to create an `AddToManager` function from SwitchOptions.
func NewAddToManagerSimpleOptions ¶
func NewAddToManagerSimpleOptions(switchOpts *SwitchOptions) *AddToManagerSimpleOptions
NewAddToManagerSimpleOptions creates new AddToManagerSimpleOptions with the given switch options. It can be used for webhooks which are required to run only without an automatic registration in the K8s cluster. Hence, Validatingwebhookconfiguration or Mutatingwebhookconfiguration must be created separately.
func (*AddToManagerSimpleOptions) AddFlags ¶
func (o *AddToManagerSimpleOptions) AddFlags(fs *pflag.FlagSet)
AddFlags implements Option.
func (*AddToManagerSimpleOptions) Complete ¶
func (o *AddToManagerSimpleOptions) Complete() error
Complete implements Option.
func (*AddToManagerSimpleOptions) Completed ¶
func (o *AddToManagerSimpleOptions) Completed() *AddToManagerSimple
Completed returns the completed AddToManagerSimpleOptions. Only call this if a previous call to `Complete` succeeded.
type FactoryAggregator ¶
type FactoryAggregator []func(manager.Manager) (*extensionswebhook.Webhook, error)
FactoryAggregator aggregates various Factory functions.
func NewFactoryAggregator ¶
func NewFactoryAggregator(m []func(manager.Manager) (*extensionswebhook.Webhook, error)) FactoryAggregator
NewFactoryAggregator creates a new FactoryAggregator and registers the given functions.
func (*FactoryAggregator) Register ¶
func (a *FactoryAggregator) Register(f func(manager.Manager) (*extensionswebhook.Webhook, error))
Register registers the given functions in this builder.
func (*FactoryAggregator) Webhooks ¶
func (a *FactoryAggregator) Webhooks(mgr manager.Manager) ([]*extensionswebhook.Webhook, error)
Webhooks calls all factories with the given managers and returns all created webhooks. As soon as there is an error creating a webhook, the error is returned immediately.
type NameToFactory ¶
type NameToFactory struct { Name string Func func(manager.Manager) (*extensionswebhook.Webhook, error) }
NameToFactory binds a specific name to a webhook's factory function.
func Switch ¶
func Switch(name string, f func(manager.Manager) (*extensionswebhook.Webhook, error)) NameToFactory
Switch binds the given name to the given AddToManager function.
type ServerConfig ¶
type ServerConfig struct { // Mode is the webhook client config mode (service or url). Mode string // URL is the URL that is used to register the webhooks in Kubernetes. URL string // ServicePort is the service port that exposes the webhook server. ServicePort int // Namespace is the webhook config namespace for 'service' mode. Namespace string }
ServerConfig is a completed webhook server configuration.
type ServerOptions ¶
type ServerOptions struct { // Mode is the URl that is used to register the webhooks in Kubernetes. Mode string // URL is the URl that is used to register the webhooks in Kubernetes. URL string // ServicePort is the service port that exposes the webhook server. ServicePort int // Namespace is the webhook config namespace for 'service' mode. Namespace string // contains filtered or unexported fields }
ServerOptions are command line options that can be set for ServerConfig.
func (*ServerOptions) AddFlags ¶
func (w *ServerOptions) AddFlags(fs *pflag.FlagSet)
AddFlags implements Flagger.AddFlags.
func (*ServerOptions) Complete ¶
func (w *ServerOptions) Complete() error
Complete implements Completer.Complete.
func (*ServerOptions) Completed ¶
func (w *ServerOptions) Completed() *ServerConfig
Completed returns the completed ServerConfig. Only call this if `Complete` was successful.
type SwitchConfig ¶
type SwitchConfig struct {
WebhooksFactory func(manager.Manager) ([]*extensionswebhook.Webhook, error)
}
SwitchConfig is the completed configuration of SwitchOptions.
type SwitchOptions ¶
type SwitchOptions struct { Disabled []string // contains filtered or unexported fields }
SwitchOptions are options to build an AddToManager function that filters the disabled webhooks.
func NewSwitchOptions ¶
func NewSwitchOptions(pairs ...NameToFactory) *SwitchOptions
NewSwitchOptions creates new SwitchOptions with the given initial pairs.
func (*SwitchOptions) AddFlags ¶
func (w *SwitchOptions) AddFlags(fs *pflag.FlagSet)
AddFlags implements Option.
func (*SwitchOptions) Complete ¶
func (w *SwitchOptions) Complete() error
Complete implements Option.
func (*SwitchOptions) Completed ¶
func (w *SwitchOptions) Completed() *SwitchConfig
Completed returns the completed SwitchConfig. Call this only after successfully calling `Completed`.
func (*SwitchOptions) Register ¶
func (w *SwitchOptions) Register(pairs ...NameToFactory)
Register registers the given NameToWebhookFuncs in the options.