cmd

package
v1.64.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 14 Imported by: 86

Documentation

Index

Constants

View Source
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"
)
View Source
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
	Clock  clock.Clock
	// contains filtered or unexported fields
}

AddToManagerConfig is a completed AddToManager configuration.

func (*AddToManagerConfig) AddToManager

func (c *AddToManagerConfig) AddToManager(ctx context.Context, mgr manager.Manager) (*atomic.Value, 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(extensionName string, shootWebhookManagedResourceName string, shootNamespaceSelector map[string]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 added in v1.4.0

type AddToManagerSimple struct {
	Switch SwitchConfig
}

AddToManagerSimple is a completed AddToManager configuration w/o webhook registration.

func (*AddToManagerSimple) AddToManager added in v1.4.0

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 added in v1.4.0

type AddToManagerSimpleOptions struct {
	Switch SwitchOptions
}

AddToManagerSimpleOptions are options to create an `AddToManager` function from SwitchOptions.

func NewAddToManagerSimpleOptions added in v1.4.0

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 added in v1.4.0

func (o *AddToManagerSimpleOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Option.

func (*AddToManagerSimpleOptions) Complete added in v1.4.0

func (o *AddToManagerSimpleOptions) Complete() error

Complete implements Option.

func (*AddToManagerSimpleOptions) Completed added in v1.4.0

Completed returns the completed AddToManagerSimpleOptions. Only call this if a previous call to `Complete` succeeded.

type FactoryAggregator added in v1.4.0

type FactoryAggregator []func(manager.Manager) (*extensionswebhook.Webhook, error)

FactoryAggregator aggregates various Factory functions.

func NewFactoryAggregator added in v1.4.0

func NewFactoryAggregator(m []func(manager.Manager) (*extensionswebhook.Webhook, error)) FactoryAggregator

NewFactoryAggregator creates a new FactoryAggregator and registers the given functions.

func (*FactoryAggregator) Register added in v1.4.0

Register registers the given functions in this builder.

func (*FactoryAggregator) Webhooks added in v1.4.0

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

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.

Jump to

Keyboard shortcuts

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