Documentation ¶
Index ¶
- Constants
- Variables
- func ActionConfirm(actionRaw, msg string) (*bool, error)
- func CheckInputHas1ArgsOr0ArgAndAll(cmd *cobra.Command, args []string) error
- func CheckInputHas2ArgsOr1ArgAndAll(cmd *cobra.Command, args []string) error
- func ConfirmAction(msg string, reader io.Reader, writer io.Writer) bool
- func DecodeDefinition(cmd *cobra.Command, flagname string, v interface{}) error
- func DecodeFile(filename string, v interface{}) error
- func FileOrStdin(cmd *cobra.Command, name string) error
- func GetHomePath(goos string) string
- func GetInsecurePassword(insecure string) ([]byte, error)
- func GetInstances(cmd *cobra.Command, params util.ClusterParams, flagName string) ([]string, error)
- func IncompatibleFlags(cmd *cobra.Command, first, second string) error
- func InsecureOrSecurePassword(insecure, message string, verify bool) ([]byte, error)
- func MinimumNArgsAndUUID(argsCount int) func(cmd *cobra.Command, args []string) error
- func OpenFile(name string) (*os.File, error)
- func ParseBoolP(cmd *cobra.Command, name string) (*bool, error)
- func ParseQueryDSLFile(f string) (models.SearchRequest, error)
- func PasswordVerify(password []byte) error
- func Track(params TrackParams) error
- type TrackParams
Constants ¶
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" )
const DefaultECERegion = "ece-region"
DefaultECERegion is the region for ECE
Variables ¶
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"`) )
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", ) )
var ( // ErrNodefinitionLoaded is returned by DecodeDefinition when no reader // has been returned from either File or Stdin. ErrNodefinitionLoaded = errors.New("failed obtaining a reader from file or stdin") )
Functions ¶
func ActionConfirm ¶
ActionConfirm asks you to confirm before performing an action
func CheckInputHas1ArgsOr0ArgAndAll ¶
CheckInputHas1ArgsOr0ArgAndAll checks that the input has either: * 1 argument * 0 arguments and the --all flag.
func CheckInputHas2ArgsOr1ArgAndAll ¶
CheckInputHas2ArgsOr1ArgAndAll checks that the input has either: * 2 arguments * 1 argument and the --all flag.
func ConfirmAction ¶
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 DecodeDefinition ¶
DecodeDefinition takes a cobra command, a flagname and the desired structure on which to decode the contents of either the os.Stdin or the file contents. If both are empty, an error is returned.
func DecodeFile ¶
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 ¶
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 ¶
GetHomePath obtains a home path from a GOOS architecture.
based on spf13/viper (userHomeDir)
func GetInsecurePassword ¶
GetInsecurePassword retrieves an insecure password from a CLI command
func GetInstances ¶
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 ¶
IncompatibleFlags checks if both flags have been specified, and if so returns an error.
func InsecureOrSecurePassword ¶
InsecureOrSecurePassword checks if an insecure password has been set and gets a password in a secure or insecure way.
func MinimumNArgsAndUUID ¶
MinimumNArgsAndUUID ensures that the command has at least N number of arguments and the first argument is 32 characters long.
func ParseBoolP ¶
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 ¶
PasswordVerify retrieves a password from terminal input and verifies a match
func Track ¶
func Track(params TrackParams) error
Track will either print and track the parameter specified Response. If the formatter is not specified an error will be returned.
Types ¶
type TrackParams ¶
type TrackParams struct { depresource.TrackResourcesParams // Formatter used to print the structure. Formatter formatter.Formatter // When set to true, it tracks the progress of the resource change with the // specified TrackResourcesParams. Track bool // Template is the template name which the formatter will use. Template string // Response will be printed using the formatter and template name. Response interface{} }
TrackParams is consumed by Track.
func (TrackParams) Validate ¶
func (params TrackParams) Validate() error
Validate ensures the parameters are usable by the consuming function.