cmdutil

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PlanRetriesFlagMessage is the message to be used by the --retries flag.
	PlanRetriesFlagMessage = "Number of times monitoring will be retried. Meaning it accepts an N number of API errors"
	// TrackFlagMessage is the message to be used by the --track flag.
	TrackFlagMessage = "Tracks the progress of the performed task"
)

Variables

View Source
var (
	// ErrCannotSpecifyEnableAndDisable is returned when --enable and --disable are set.
	ErrCannotSpecifyEnableAndDisable = errors.New(`command only accepts one flag and it should be either "--enable" or "--disable"`)
	// ErrMustSpecifyOneOfEnableOrDisable is returned when --enable or --disable must be set.
	ErrMustSpecifyOneOfEnableOrDisable = errors.New(`command must specify one flag and it should be either "--enable" or "--disable"`)
)
View Source
var (
	// ErrEmptyStdinAndFile thrown when either the Sdin or the file are empty.
	ErrEmptyStdinAndFile = errors.New(
		"empty stdin and file definition, need one of the two to be populated",
	)
)

Functions

func ActionConfirm

func ActionConfirm(actionRaw, msg string) (*bool, error)

ActionConfirm asks you to confirm before performing an action

func CheckInputHas1ArgsOr0ArgAndAll

func CheckInputHas1ArgsOr0ArgAndAll(cmd *cobra.Command, args []string) error

CheckInputHas1ArgsOr0ArgAndAll checks that the input has either: * 1 argument * 0 arguments and the --all flag.

func CheckInputHas2ArgsOr1ArgAndAll

func CheckInputHas2ArgsOr1ArgAndAll(cmd *cobra.Command, args []string) error

CheckInputHas2ArgsOr1ArgAndAll checks that the input has either: * 2 arguments * 1 argument and the --all flag.

func ConfirmAction

func ConfirmAction(msg string, reader io.Reader, writer io.Writer) bool

ConfirmAction is used to print a message to the writer and read the input from the reader. If the first letter is "y" or "Y" it will return true.

func DecodeFile

func DecodeFile(filename string, v interface{}) error

DecodeFile takes a filename and the pointer to a structure, opening the file and dumping the contents into the desired structure. Make sure a pointer is passed rather than the copy of a structure.

func FileOrStdin

func FileOrStdin(cmd *cobra.Command, name string) error

FileOrStdin returns an error when the followong scenarios happen: * No Stdin and Flag value are empty. * Unredable Stdin * Both Stdin and Flag value present.

func GetHomePath

func GetHomePath(goos string) string

GetHomePath obtains a home path from a GOOS architecture.

based on spf13/viper (userHomeDir)

func GetInsecurePassword

func GetInsecurePassword(insecure string) ([]byte, error)

GetInsecurePassword retrieves an insecure password from a CLI command

func GetInstances

func GetInstances(cmd *cobra.Command, params util.ClusterParams, flagName string) ([]string, error)

GetInstances tries to obtain a slice with the elasticsearch cluster instance names either from the current cluster topology or from the specified --instance flag in the cobra.Command.

func IncompatibleFlags

func IncompatibleFlags(cmd *cobra.Command, first, second string) error

IncompatibleFlags checks if both flags have been specified, and if so returns an error.

func InsecureOrSecurePassword

func InsecureOrSecurePassword(insecure, message string, verify bool) ([]byte, error)

InsecureOrSecurePassword checks if an insecure password has been set and gets a password in a secure or insecure way.

func MinimumNArgsAndUUID

func MinimumNArgsAndUUID(argsCount int) func(cmd *cobra.Command, args []string) error

MinimumNArgsAndUUID ensures that the command has at least N number of arguments and the first argument is 32 characters long.

func OpenFile

func OpenFile(name string) (*os.File, error)

OpenFile encapsulates the stat and os.OpenFile into its own function

func ParseBoolP

func ParseBoolP(cmd *cobra.Command, name string) (*bool, error)

ParseBoolP parses a string flag that is meant to be a boolean with 3 values: * true * false * nil

func ParseQueryDSLFile

func ParseQueryDSLFile(f string) (models.SearchRequest, error)

ParseQueryDSLFile parses a file that contains a query dsl json and returns the corresponding binary representation

func PasswordVerify

func PasswordVerify(password []byte) error

PasswordVerify retrieves a password from terminal input and verifies a match

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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