cmd

package
v1.96.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 118

Documentation

Index

Constants

View Source
const (
	// LeaderElectionFlag is the name of the command line flag to specify whether to do leader election or not.
	LeaderElectionFlag = "leader-election"
	// LeaderElectionIDFlag is the name of the command line flag to specify the leader election ID.
	LeaderElectionIDFlag = "leader-election-id"
	// LeaderElectionNamespaceFlag is the name of the command line flag to specify the leader election namespace.
	LeaderElectionNamespaceFlag = "leader-election-namespace"
	// WebhookServerHostFlag is the name of the command line flag to specify the webhook config host for 'url' mode.
	WebhookServerHostFlag = "webhook-config-server-host"
	// WebhookServerPortFlag is the name of the command line flag to specify the webhook server port.
	WebhookServerPortFlag = "webhook-config-server-port"
	// WebhookCertDirFlag is the name of the command line flag to specify the webhook certificate directory.
	WebhookCertDirFlag = "webhook-config-cert-dir"
	// MetricsBindAddressFlag is the name of the command line flag to specify the TCP address that the controller
	// should bind to for serving prometheus metrics.
	// It can be set to "0" to disable the metrics serving.
	MetricsBindAddressFlag = "metrics-bind-address"
	// HealthBindAddressFlag is the name of the command line flag to specify the TCP address that the controller
	// should bind to for serving health probes
	HealthBindAddressFlag = "health-bind-address"

	// MaxConcurrentReconcilesFlag is the name of the command line flag to specify the maximum number of
	// concurrent reconciliations a controller can do.
	MaxConcurrentReconcilesFlag = "max-concurrent-reconciles"

	// KubeconfigFlag is the name of the command line flag to specify a kubeconfig used to retrieve
	// a rest.Config for a manager.Manager.
	KubeconfigFlag = clientcmd.RecommendedConfigPathFlag
	// MasterURLFlag is the name of the command line flag to specify the master URL override for
	// a rest.Config of a manager.Manager.
	MasterURLFlag = "master"

	// DisableFlag is the name of the command line flag to disable individual controllers.
	DisableFlag = "disable-controllers"

	// GardenerVersionFlag is the name of the command line flag containing the Gardener version.
	GardenerVersionFlag = "gardener-version"

	// LogLevelFlag is the name of the command line flag containing the log level.
	LogLevelFlag = "log-level"

	// LogFormatFlag is the name of the command line flag containing the log format.
	LogFormatFlag = "log-format"
)
View Source
const (
	// IgnoreOperationAnnotationFlag is the name of the command line flag to specify whether the operation annotation
	// is ignored or not.
	IgnoreOperationAnnotationFlag = "ignore-operation-annotation"
)

Variables

View Source
var (
	// BuildConfigFromFlags creates a build configuration from the given flags. Exposed for testing.
	BuildConfigFromFlags = clientcmd.BuildConfigFromFlags
	// InClusterConfig obtains the current in-cluster config. Exposed for testing.
	InClusterConfig = rest.InClusterConfig
	// Getenv obtains the environment variable with the given name. Exposed for testing.
	Getenv = os.Getenv
	// RecommendedHomeFile is the recommended location of the kubeconfig. Exposed for testing.
	RecommendedHomeFile = clientcmd.RecommendedHomeFile
)

Functions

func LeaderElectionNameID

func LeaderElectionNameID(name string) string

LeaderElectionNameID returns a leader election ID for the given name.

Types

type Completer

type Completer interface {
	// Complete completes the work, optionally returning an error.
	Complete() error
}

Completer completes some work.

type ControllerConfig

type ControllerConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles.
	MaxConcurrentReconciles int
}

ControllerConfig is a completed controller configuration.

func (*ControllerConfig) Apply

func (c *ControllerConfig) Apply(opts *controller.Options)

Apply sets the values of this ControllerConfig in the given controller.Options.

func (*ControllerConfig) Options

func (c *ControllerConfig) Options() controller.Options

Options initializes empty controller.Options, applies the set values and returns it.

type ControllerOptions

type ControllerOptions struct {
	// MaxConcurrentReconciles are the maximum concurrent reconciles.
	MaxConcurrentReconciles int
	// contains filtered or unexported fields
}

ControllerOptions are command line options that can be set for controller.Options.

func (*ControllerOptions) AddFlags

func (c *ControllerOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*ControllerOptions) Complete

func (c *ControllerOptions) Complete() error

Complete implements Completer.Complete.

func (*ControllerOptions) Completed

func (c *ControllerOptions) Completed() *ControllerConfig

Completed returns the completed ControllerConfig. Only call this if `Complete` was successful.

type Flagger

type Flagger interface {
	// AddFlags adds the flags of this Flagger to the given FlagSet.
	AddFlags(*pflag.FlagSet)
}

Flagger adds flags to a given FlagSet.

func PrefixFlagger

func PrefixFlagger(prefix string, flagger Flagger) Flagger

PrefixFlagger creates a flagger that prefixes all its flags with the given prefix.

type GeneralConfig added in v1.39.0

type GeneralConfig struct {
	// GardenerVersion is the version of the Gardener.
	GardenerVersion string
}

GeneralConfig is a completed general configuration.

type GeneralOptions added in v1.39.0

type GeneralOptions struct {
	// GardenerVersion is the version of the Gardener.
	GardenerVersion string
	// contains filtered or unexported fields
}

GeneralOptions are command line options that can be set for general configuration.

func (*GeneralOptions) AddFlags added in v1.39.0

func (r *GeneralOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*GeneralOptions) Complete added in v1.39.0

func (r *GeneralOptions) Complete() error

Complete implements Complete.

func (*GeneralOptions) Completed added in v1.39.0

func (r *GeneralOptions) Completed() *GeneralConfig

Completed returns the completed GeneralConfig. Only call this if `Complete` was successful.

type ManagerConfig

type ManagerConfig struct {
	// LeaderElection is whether leader election is turned on or not.
	LeaderElection bool
	// LeaderElectionID is the id to do leader election with.
	LeaderElectionID string
	// LeaderElectionNamespace is the namespace to do leader election in.
	LeaderElectionNamespace string
	// WebhookServerHost is the host for the webhook server.
	WebhookServerHost string
	// WebhookServerPort is the port for the webhook server.
	WebhookServerPort int
	// WebhookCertDir is the directory that contains the webhook server key and certificate.
	WebhookCertDir string
	// MetricsBindAddress is the TCP address that the controller should bind to for serving prometheus metrics.
	MetricsBindAddress string
	// HealthBindAddress is the TCP address that the controller should bind to for serving health probes.
	HealthBindAddress string
	// Logger is a logr.Logger compliant logger
	Logger logr.Logger
}

ManagerConfig is a completed manager configuration.

func (*ManagerConfig) Apply

func (c *ManagerConfig) Apply(opts *manager.Options)

Apply sets the values of this ManagerConfig in the given manager.Options.

func (*ManagerConfig) Options

func (c *ManagerConfig) Options() manager.Options

Options initializes empty manager.Options, applies the set values and returns it.

type ManagerOptions

type ManagerOptions struct {
	// LeaderElection is whether leader election is turned on or not.
	LeaderElection bool
	// LeaderElectionID is the id to do leader election with.
	LeaderElectionID string
	// LeaderElectionNamespace is the namespace to do leader election in.
	LeaderElectionNamespace string
	// WebhookServerHost is the host for the webhook server.
	WebhookServerHost string
	// WebhookServerPort is the port for the webhook server.
	WebhookServerPort int
	// WebhookCertDir is the directory that contains the webhook server key and certificate.
	WebhookCertDir string
	// MetricsBindAddress is the TCP address that the controller should bind to for serving prometheus metrics.
	MetricsBindAddress string
	// HealthBindAddress is the TCP address that the controller should bind to for serving health probes.
	HealthBindAddress string
	// LogLevel defines the level/severity for the logs. Must be one of [info,debug,error]
	LogLevel string
	// LogFormat defines the format for the logs. Must be one of [json,text]
	LogFormat string
	// contains filtered or unexported fields
}

ManagerOptions are command line options that can be set for manager.Options.

func (*ManagerOptions) AddFlags

func (m *ManagerOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*ManagerOptions) Complete

func (m *ManagerOptions) Complete() error

Complete implements Completer.Complete.

func (*ManagerOptions) Completed

func (m *ManagerOptions) Completed() *ManagerConfig

Completed returns the completed ManagerConfig. Only call this if `Complete` was successful.

type NameToAddToManagerFunc

type NameToAddToManagerFunc struct {
	Name string
	Func func(context.Context, manager.Manager) error
}

NameToAddToManagerFunc binds a specific name to a controller's AddToManager function.

func Switch

Switch binds the given name to the given AddToManager function.

type Option

type Option interface {
	Flagger
	Completer
}

Option is a Flagger and Completer. It sets command line flags and does some work when the flags have been parsed, optionally producing an error.

func PrefixOption

func PrefixOption(prefix string, option Option) Option

PrefixOption creates an option that prefixes all its flags with the given prefix.

type OptionAggregator

type OptionAggregator []Option

OptionAggregator is a builder that aggregates multiple options.

func NewOptionAggregator

func NewOptionAggregator(options ...Option) OptionAggregator

NewOptionAggregator instantiates a new OptionAggregator and registers all given options.

func (*OptionAggregator) AddFlags

func (b *OptionAggregator) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*OptionAggregator) Complete

func (b *OptionAggregator) Complete() error

Complete implements Completer.Complete.

func (*OptionAggregator) Register

func (b *OptionAggregator) Register(options ...Option)

Register registers the given options in this OptionAggregator.

type RESTConfig

type RESTConfig struct {
	// Config is the rest.Config.
	Config *rest.Config
}

RESTConfig is a completed REST configuration.

type RESTOptions

type RESTOptions struct {
	// Kubeconfig is the path to a kubeconfig.
	Kubeconfig string
	// MasterURL is an override for the URL in a kubeconfig. Only used if out-of-cluster.
	MasterURL string
	// contains filtered or unexported fields
}

RESTOptions are command line options that can be set for rest.Config.

func (*RESTOptions) AddFlags

func (r *RESTOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*RESTOptions) Complete

func (r *RESTOptions) Complete() error

Complete implements RESTCompleter.Complete.

func (*RESTOptions) Completed

func (r *RESTOptions) Completed() *RESTConfig

Completed returns the completed RESTConfig. Only call this if `Complete` was successful.

type ReconcilerConfig

type ReconcilerConfig struct {
	// IgnoreOperationAnnotation defines whether to ignore the operation annotation or not.
	IgnoreOperationAnnotation bool
}

ReconcilerConfig is a completed controller configuration.

func (*ReconcilerConfig) Apply

func (c *ReconcilerConfig) Apply(ignore *bool)

Apply sets the values of this ReconcilerConfig in the given controller.Options.

type ReconcilerOptions

type ReconcilerOptions struct {
	// IgnoreOperationAnnotation defines whether to ignore the operation annotation or not.
	IgnoreOperationAnnotation bool
	// contains filtered or unexported fields
}

ReconcilerOptions are command line options that can be set for controller.Options.

func (*ReconcilerOptions) AddFlags

func (c *ReconcilerOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Flagger.AddFlags.

func (*ReconcilerOptions) Complete

func (c *ReconcilerOptions) Complete() error

Complete implements Completer.Complete.

func (*ReconcilerOptions) Completed

func (c *ReconcilerOptions) Completed() *ReconcilerConfig

Completed returns the completed ReconcilerConfig. Only call this if `Complete` was successful.

type SwitchConfig

type SwitchConfig struct {
	AddToManager func(context.Context, manager.Manager) 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 controllers.

func NewSwitchOptions

func NewSwitchOptions(pairs ...NameToAddToManagerFunc) *SwitchOptions

NewSwitchOptions creates new SwitchOptions with the given initial pairs.

func (*SwitchOptions) AddFlags

func (d *SwitchOptions) AddFlags(fs *pflag.FlagSet)

AddFlags implements Option.

func (*SwitchOptions) Complete

func (d *SwitchOptions) Complete() error

Complete implements Option.

func (*SwitchOptions) Completed

func (d *SwitchOptions) Completed() *SwitchConfig

Completed returns the completed SwitchConfig. Call this only after successfully calling `Completed`.

func (*SwitchOptions) Register

func (d *SwitchOptions) Register(pairs ...NameToAddToManagerFunc)

Register registers the given NameToControllerFuncs in the options.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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