helpers

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT, + 1 more Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAllNamespace

func AddAllNamespace(flagSet *pflag.FlagSet)

AddAllNamespace adds the '--all-namespaces' flag to the given command

func AddChunkSizeFlag

func AddChunkSizeFlag(flagSet *pflag.FlagSet)

AddChunkSizeFlag adds the '--chunk-size' flag to the given command

func AddFieldSelectorFlag

func AddFieldSelectorFlag(flagSet *pflag.FlagSet)

AddFieldSelectorFlag adds the '--field-selector' flag to the given command

func AddFormatFlag

func AddFormatFlag(flagSet *pflag.FlagSet)

AddFormatFlag adds the format flag to the given command. When given client configuration the user's configured default format is used as the flag's default value.

func AddInteractiveFlag

func AddInteractiveFlag(flagSet *pflag.FlagSet)

AddInteractiveFlag adds the '--interactive' flag to the given command

func AddLabelSelectorFlag

func AddLabelSelectorFlag(flagSet *pflag.FlagSet)

AddLabelSelectorFlag adds the '--label-selector' flag to the given command

func ConfirmDelete

func ConfirmDelete(name string) bool

ConfirmDelete confirm a deletion operation before it is completed.

func ConfirmOptOut

func ConfirmOptOut() bool

ConfirmOptOut confirm an opt-out operation before it is completed.

func DetectEmptyStdin

func DetectEmptyStdin(f *os.File) error

DetectEmptyStdin determines if stdin is empty

func FlagHasChanged

func FlagHasChanged(name string, flagset *pflag.FlagSet) bool

FlagHasChanged determines if the user has set the value of a flag, or left it to default

func GetChangedStringValueFlag

func GetChangedStringValueFlag(name string, flagset *pflag.FlagSet) string

GetChangedStringValueFlag returns the value of a flag that has been explicitely changed by the user, and not left to default

func GetCurrentUsername

func GetCurrentUsername(cfg config.Config) string

GetCurrentUsername retrieves the username from the active JWT

func InputData

func InputData(filename string) (io.Reader, error)

InputData returns the content of filename, if provided, or the standard input. An error is returned if no input data is provided or if the file could not be open

func JoinErrors

func JoinErrors(prelude string, errs []error) error

JoinErrors joins multiple errors messages. Useful when you want the CLI to display more than one error message.

eg.

JoinErrors("Validation: ", []error{errors.New("a"), errors.New("b")})
"Validation: a, and b."

func ListOptionsFromFlags

func ListOptionsFromFlags(flagSet *pflag.FlagSet) (client.ListOptions, error)

ListOptionsFromFlags construct an appropriate ListOptions given a FlagSet.

func Print

func Print(cmd *cobra.Command, format string, printTable printTableFunc, objects []types.Resource, v interface{}) error

Print displays

func PrintFormatted

func PrintFormatted(flag string, format string, v interface{}, w io.Writer, printToList func(interface{}, io.Writer) error) error

PrintFormatted prints the provided interface in the specified format. flag overrides the cli config format if set

func PrintJSON

func PrintJSON(r interface{}, io io.Writer) error

PrintJSON takes a record(s) and an io.Writer, converts the record to human- readable JSON (pretty-prints), and then prints the result to the given writer. Unescapes any &, <, or > characters it finds.

func PrintTitle

func PrintTitle(flag string, format string, title string, w io.Writer) error

PrintTitle prints a title for tabular format only. Flag overrides the cli config format, if set.

func PrintWrappedJSON

func PrintWrappedJSON(r types.Resource, wr io.Writer) error

PrintWrappedJSON takes a record(s) and Resource, converts the record to human-readable JSON (pretty-prints), wraps that JSON using types.Wrapper, and then prints the result to the given writer. Unescapes any &, <, or > characters it finds.

func PrintWrappedJSONList

func PrintWrappedJSONList(r []types.Resource, io io.Writer) error

PrintWrappedJSONList takes a resource list and an io.Writer, converts the record to human-readable JSON (pretty-prints), wraps that JSON using types.Wrapper, and then prints the result to the given writer. Unescapes any &, <, or > characters it finds.

func PrintYAML

func PrintYAML(v interface{}, w io.Writer) (err error)

PrintYAML serializes the value v to yaml and writes the result to w.

func SafeSplitCSV

func SafeSplitCSV(i string) []string

SafeSplitCSV splits given string and trims and extraneous whitespace

func VerifyName

func VerifyName(args []string) error

VerifyName ensures that (only) a name was provided in the arguments

Types

type Confirm

type Confirm struct {
	Message string
	Default bool
}

Confirm an operation before it is completed

func (*Confirm) Ask

func (c *Confirm) Ask() (bool, error)

Ask executes confirmation of operation

type ConfirmDestructiveOp

type ConfirmDestructiveOp struct {
	Type string
	Op   string
}

ConfirmDestructiveOp presents prompt for a destructive operation.

func (*ConfirmDestructiveOp) Ask

func (c *ConfirmDestructiveOp) Ask(name string) (bool, error)

Ask presents prompt confirming a destructive operation.

Jump to

Keyboard shortcuts

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