Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI represents command line interface for the operator.
func (*CLI) FlagSet ¶
FlagSet returns bare underlying flagset of the cli. It can be used to register additional flags. They will be parsed by Parse() method. Caller needs to take care of values set by flags added to this flagset.
type ValidatedValue ¶ added in v1.6.0
type ValidatedValue[T any] struct { // contains filtered or unexported fields }
ValidatedValue implements `pflag.Value` interface. It can be used for hooking up arbitrary validation logic to any type. It should be passed to `pflag.FlagSet.Var()`.
func NewValidatedValue ¶ added in v1.6.0
func NewValidatedValue[T any](variable *T, constructor func(flagValue string) (T, error), opts ...ValidatedValueOpt[T]) ValidatedValue[T]
NewValidatedValue creates a validated variable of type T. Constructor should validate the input and return an error in case of any failures. If validation passes, constructor should return a value that's to be set in the variable. The constructor accepts a flagValue that is raw input from user's command line (or an env variable that was bind to the flag, see: bindEnvVars). It accepts a variadic list of options that can be used e.g. to set the default value or override the type name.
func (ValidatedValue[T]) Set ¶ added in v1.6.0
func (v ValidatedValue[T]) Set(s string) error
Set sets the value of the variable. It uses the constructor to validate the input and set the value.
func (ValidatedValue[T]) String ¶ added in v1.6.0
func (v ValidatedValue[T]) String() string
func (ValidatedValue[T]) Type ¶ added in v1.6.0
func (v ValidatedValue[T]) Type() string
Type returns the type of the variable. If the type name is overridden, it returns that.
type ValidatedValueOpt ¶ added in v1.6.0
type ValidatedValueOpt[T any] func(*ValidatedValue[T])
ValidatedValueOpt is a function that modifies a ValidatedValue.
func WithDefault ¶ added in v1.6.0
func WithDefault[T any](defaultValue T) ValidatedValueOpt[T]
WithDefault sets the default value for the validated variable.
func WithTypeNameOverride ¶ added in v1.6.0
func WithTypeNameOverride[T any](typeName string) ValidatedValueOpt[T]
WithTypeNameOverride overrides the type name that's printed in the help message.