args

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package args contains shared utility methods for argument parsing and validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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".

func (*CIDR) Set added in v0.3.1

func (c *CIDR) Set(str string) error

Set parses the provided string in net.IPnet.

func (*CIDR) String added in v0.3.1

func (c *CIDR) String() string

String returns the stringified list.

func (*CIDR) Type added in v0.3.1

func (c *CIDR) Type() string

Type returns the cidrList type.

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".

func (*CIDRList) Set

func (cl *CIDRList) Set(str string) error

Set parses the provided string into the []string list.

func (*CIDRList) String

func (cl *CIDRList) String() string

String returns the stringified list.

func (CIDRList) Type

func (cl CIDRList) Type() string

Type returns the cidrList type.

type ClusterIdentityFlags added in v0.3.2

type ClusterIdentityFlags struct {
	ClusterID   *string
	ClusterName *string
	// contains filtered or unexported fields
}

ClusterIdentityFlags stores the values of flags representing a ClusterIdentity.

func NewClusterIdentityFlags added in v0.3.2

func NewClusterIdentityFlags(local bool, flags *flag.FlagSet) ClusterIdentityFlags

NewClusterIdentityFlags 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 := NewClusterIdentityFlags(false, nil)
flag.Parse()
foreignClusterIdentity := fcFlags.Read()

func (ClusterIdentityFlags) Read added in v0.3.2

Read performs validation on the values passed and returns a ClusterIdentity if successful.

func (ClusterIdentityFlags) ReadOrDie added in v0.3.2

ReadOrDie returns a ClusterIdentity. It prints an error message and exits if the values are not valid.

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.

func (Percentage) Type

func (p Percentage) Type() string

Type returns the percentage type.

type Quantity added in v0.3.2

type Quantity struct {
	Quantity resource.Quantity
}

Quantity implements the flag.Value interface and allows to parse strings expressing resource quantities.

func NewQuantity added in v0.3.2

func NewQuantity(quantity string) Quantity

NewQuantity returns a new Quantity object initialized with the given resource quantity.

func (*Quantity) Set added in v0.3.2

func (q *Quantity) Set(str string) error

Set parses the provided string as a resource quantity.

func (*Quantity) String added in v0.3.2

func (q *Quantity) String() string

String returns the stringified quantity.

func (*Quantity) Type added in v0.3.2

func (q *Quantity) Type() string

Type returns the quantity type.

type StringEnum added in v0.3.2

type StringEnum struct {
	Allowed []string
	Value   string
}

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 (*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.

func (StringList) Type

func (sl StringList) Type() string

Type returns the stringList type.

type StringMap

type StringMap struct {
	StringMap map[string]string
}

StringMap implements the flag.Value interface and allows to parse stringified maps in the form: "key1=val1,key2=val2".

func (*StringMap) Set

func (sm *StringMap) Set(str string) error

Set parses the provided string into the map[string]string map.

func (StringMap) String

func (sm StringMap) String() string

String returns the stringified map.

func (StringMap) Type

func (sm StringMap) Type() string

Type returns the stringMap type.

Jump to

Keyboard shortcuts

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