cmd

package
v0.0.0-...-60d224e Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0, MIT Imports: 10 Imported by: 0

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"

	// 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"
)

Variables

View Source
var (
	// Log is log.Log. Exposed for testing.
	Log = log.Log
	// Exit calls os.Exit. Exposed for testing.
	Exit = os.Exit
)
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.

func LogErrAndExit

func LogErrAndExit(err error, msg string, keysAndValues ...interface{})

LogErrAndExit logs the given error with msg and keysAndValues and calls `os.Exit(1)`.

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 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
}

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
	// 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(manager.Manager) error
}

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

func Switch

func Switch(name string, f func(manager.Manager) error) NameToAddToManagerFunc

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 SwitchConfig

type SwitchConfig struct {
	AddToManager func(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.

Jump to

Keyboard shortcuts

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