Documentation ¶
Index ¶
- Constants
- Variables
- func AddCleanFlags(cmd *cobra.Command)
- func BehaviorOnFatal(f func(string, int))
- func CheckDiffErr(err error)
- func CheckErr(err error)
- func CombineRequestErr(resp gorequest.Response, body string, errs []error) error
- func DefaultBehaviorOnFatal()
- func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string)
- func GetFlagBool(cmd *cobra.Command, flag string) bool
- func GetFlagDuration(cmd *cobra.Command, flag string) time.Duration
- func GetFlagInt(cmd *cobra.Command, flag string) int
- func GetFlagInt32(cmd *cobra.Command, flag string) int32
- func GetFlagInt64(cmd *cobra.Command, flag string) int64
- func GetFlagString(cmd *cobra.Command, flag string) string
- func GetFlagStringArray(cmd *cobra.Command, flag string) []string
- func GetFlagStringSlice(cmd *cobra.Command, flag string) []string
- func IsFilenameSliceEmpty(filenames []string, directory string) bool
- func IsSiblingCommandExists(cmd *cobra.Command, targetCmdName string) bool
- func ManualStrip(file []byte) []byte
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func RequireNoArguments(c *cobra.Command, args []string)
- func SignToken(secretID string, secretKey string) (string, error)
- func StandardErrorMessage(err error) (string, bool)
- func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
- func UsageErrorf(cmd *cobra.Command, format string, args ...any) error
- func Warning(cmdErr io.Writer, newGeneratorName, oldGeneratorName string)
- type Factory
- type ValidateOptions
Constants ¶
const (
// DefaultErrorExitCode defines the default exit code.
DefaultErrorExitCode = 1
)
Variables ¶
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
Functions ¶
func BehaviorOnFatal ¶
BehaviorOnFatal allows you to override the default behavior when a fatal error occurs, which is to call os.Exit(code). You can pass 'panic' as a function here if you prefer the panic() over os.Exit(1).
func CheckDiffErr ¶
func CheckDiffErr(err error)
CheckDiffErr prints a user-friendly error to STDERR and exits with a non-zero and non-one exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is meant specifically for `onexctl diff` and may be used by other commands.
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user-friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-onexctl commands.
func CombineRequestErr ¶
CombineRequestErr combines the http response error and error in errs array.
func DefaultBehaviorOnFatal ¶
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func DefaultSubCommandRun ¶
DefaultSubCommandRun prints a command's help string to the specified output if no arguments (sub-commands) are provided, or a usage error otherwise.
func GetFlagBool ¶
GetFlagBool returns the value of the given flag.
func GetFlagDuration ¶
GetFlagDuration return the value of the given flag.
func GetFlagInt ¶
GetFlagInt returns the value of the given flag.
func GetFlagInt32 ¶
GetFlagInt32 returns the value of the given flag.
func GetFlagInt64 ¶
GetFlagInt64 returns the value of the given flag.
func GetFlagString ¶
GetFlagString returns the value of the given flag.
func GetFlagStringArray ¶
GetFlagStringArray can be used to accept multiple argument with flag repetition (e.g. -f arg1 -f arg2 ...).
func GetFlagStringSlice ¶
GetFlagStringSlice can be used to accept multiple argument with flag repetition (e.g. -f arg1,arg2 -f arg3 ...).
func IsFilenameSliceEmpty ¶
IsFilenameSliceEmpty checkes where filenames and directory are both zero value.
func IsSiblingCommandExists ¶
IsSiblingCommandExists receives a pointer to a cobra command and a target string. Returns true if the target string is found in the list of sibling commands.
func ManualStrip ¶
ManualStrip is used for dropping comments from a YAML file.
func MultilineError ¶
MultilineError returns a string representing an error that splits sub errors into their own lines. The returned string will end with a newline.
func MultipleErrors ¶
MultipleErrors returns a newline delimited string containing the prefix and referenced errors in standard form.
func RequireNoArguments ¶
RequireNoArguments exits with a usage error if extra arguments are provided.
func StandardErrorMessage ¶
StandardErrorMessage translates common errors into a human readable message, or returns false if the error is not one of the recognized types. It may also log extended information to klog.
This method is generic to the command in use and may be used by non-onexctl commands.
func TableWriterDefaultConfig ¶
func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
func UsageErrorf ¶
UsageErrorf returns error with command path.
Types ¶
type Factory ¶
type Factory interface { Login() (token string, err error) UserCenterClient() usercenterv1.UserCenterHTTPClient GatewayClient() gatewayv1.GatewayHTTPClient GetOptions() *clioptions.Options }
func NewFactory ¶
func NewFactory(opts *clioptions.Options) Factory
type ValidateOptions ¶
type ValidateOptions struct {
EnableValidation bool
}
ValidateOptions defines the validate options.