Documentation ¶
Overview ¶
Package args contains shared utility methods for argument parsing and validation.
Index ¶
- func GetObjectRefFromNamespacedName(nsName string) (*corev1.ObjectReference, error)
- func SplitNamespacedName(nsName string) (splits []string, err error)
- type CIDR
- type CIDRList
- type ClassName
- type ClassNameList
- type ClusterIDFlags
- func (f ClusterIDFlags) GetClusterID() liqov1beta1.ClusterID
- func (f ClusterIDFlags) Read() (liqov1beta1.ClusterID, error)
- func (f ClusterIDFlags) ReadOrDie() liqov1beta1.ClusterID
- func (f *ClusterIDFlags) Set(value string) error
- func (f ClusterIDFlags) String() string
- func (f ClusterIDFlags) Type() string
- type Percentage
- type Quantity
- type ResourceMap
- type StringEnum
- type StringList
- type StringMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetObjectRefFromNamespacedName ¶
func GetObjectRefFromNamespacedName(nsName string) (*corev1.ObjectReference, error)
GetObjectRefFromNamespacedName returns an ObjectReference from a namespaced name string.
func SplitNamespacedName ¶
SplitNamespacedName splits a namespaced name string into its namespace and name components.
Types ¶
type CIDR ¶ added in v0.3.1
type CIDR struct {
// contains filtered or unexported fields
}
CIDR implements the flag.Value interface and allows to parse strings in CIDR format lists in the form: "x.x.x.x/y".
type CIDRList ¶
type CIDRList struct { StringList StringList CIDRList []net.IPNet }
CIDRList implements the flag.Value interface and allows to parse stringified lists in the form: "val1,val2".
type ClassName ¶ added in v0.10.2
ClassName contains the name of a class and whether it is the default class.
type ClassNameList ¶ added in v0.10.2
type ClassNameList struct {
Classes []ClassName
}
ClassNameList implements the flag.Value interface and allows to parse stringified list of class names in the form: "class1;default,class2,class3".
func (*ClassNameList) GetDefault ¶ added in v0.10.2
func (cnl *ClassNameList) GetDefault() string
GetDefault returns the default class name, or the first class name if no default class is specified.
func (*ClassNameList) Set ¶ added in v0.10.2
func (cnl *ClassNameList) Set(str string) error
Set parses the provided string into the []ClassName list.
func (ClassNameList) String ¶ added in v0.10.2
func (cnl ClassNameList) String() string
String returns the stringified list.
func (ClassNameList) Type ¶ added in v0.10.2
func (cnl ClassNameList) Type() string
Type returns the classNameList type.
type ClusterIDFlags ¶
type ClusterIDFlags struct { ClusterID *string // contains filtered or unexported fields }
ClusterIDFlags stores the values of flags representing a ClusterID.
func NewClusterIDFlags ¶
func NewClusterIDFlags(local bool, flags *pflag.FlagSet) ClusterIDFlags
NewClusterIDFlags returns a set of command line flags to read a cluster identity. If local=true the identity refers to the local cluster, otherwise it refers to a foreign cluster. Set flags=nil to use command-line flags (os.Argv).
Example usage:
fcFlags := NewClusterIDFlags(false, nil) flag.Parse() foreignClusterID := fcFlags.Read()
func (ClusterIDFlags) GetClusterID ¶
func (f ClusterIDFlags) GetClusterID() liqov1beta1.ClusterID
GetClusterID returns the ClusterID stored in the flags.
func (ClusterIDFlags) Read ¶
func (f ClusterIDFlags) Read() (liqov1beta1.ClusterID, error)
Read performs validation on the values passed and returns a ClusterID if successful.
func (ClusterIDFlags) ReadOrDie ¶
func (f ClusterIDFlags) ReadOrDie() liqov1beta1.ClusterID
ReadOrDie returns a ClusterID. It prints an error message and exits if the values are not valid.
func (*ClusterIDFlags) Set ¶
func (f *ClusterIDFlags) Set(value string) error
Set implements the flag.Value interface.
func (ClusterIDFlags) String ¶
func (f ClusterIDFlags) String() string
String implements the flag.Value interface.
func (ClusterIDFlags) Type ¶
func (f ClusterIDFlags) Type() string
Type implements the flag.Value interface.
type Percentage ¶
type Percentage struct {
Val uint64
}
Percentage implements the flag.Value interface and allows to parse stringified percentages.
func (*Percentage) Set ¶
func (p *Percentage) Set(str string) error
Set parses the provided string into the percentage.
func (Percentage) String ¶
func (p Percentage) String() string
String returns the stringified percentage.
type Quantity ¶ added in v0.3.2
Quantity implements the flag.Value interface and allows to parse strings expressing resource quantities.
func NewQuantity ¶ added in v0.3.2
NewQuantity returns a new Quantity object initialized with the given resource quantity.
type ResourceMap ¶
ResourceMap implements the flag.Value interface and allows to parse stringified maps of resources in the form: "key1=4,key2=2Gi".
func (*ResourceMap) Set ¶
func (rm *ResourceMap) Set(str string) error
Set parses the provided string into the map[string]resource.Quantity map.
func (ResourceMap) String ¶
func (rm ResourceMap) String() string
String returns the stringified map.
func (*ResourceMap) ToResourceList ¶
func (rm *ResourceMap) ToResourceList() corev1.ResourceList
ToResourceList converts the ResourceMap into a corev1.ResourceList.
type StringEnum ¶ added in v0.3.2
StringEnum is a type used to validate a string parameter is included in a set of allowed values.
func NewEnum ¶ added in v0.3.2
func NewEnum(allowed []string, d string) *StringEnum
NewEnum give a list of allowed flag parameters, where the second argument is the default.
func NewEnumWithVoidDefault ¶ added in v0.8.2
func NewEnumWithVoidDefault(allowed []string) *StringEnum
NewEnumWithVoidDefault give a list of allowed flag parameters, where the default is a void string.
func (*StringEnum) Set ¶ added in v0.3.2
func (a *StringEnum) Set(p string) error
Set parses the provided string checking its validity and setting it inside the Value field.
func (StringEnum) String ¶ added in v0.3.2
func (a StringEnum) String() string
String returns the stringified value.
func (*StringEnum) Type ¶ added in v0.3.2
func (a *StringEnum) Type() string
Type returns the enum type.
type StringList ¶
type StringList struct {
StringList []string
}
StringList implements the flag.Value interface and allows to parse stringified lists in the form: "val1,val2".
func (*StringList) Set ¶
func (sl *StringList) Set(str string) error
Set parses the provided string into the []string list.
func (StringList) String ¶
func (sl StringList) String() string
String returns the stringified list.
type StringMap ¶
StringMap implements the flag.Value interface and allows to parse stringified maps in the form: "key1=val1,key2=val2". Values can contain additional '=' characters, for example: "argocd.argoproj.io/sync-options=Prune=false". In this case, only the first '=' is used as the key-value separator.