Documentation ¶
Index ¶
- Constants
- Variables
- func BashExample(binaryCommand string, cli string) string
- func BehaviorOnFatal(f func(string, int))
- func CheckErr(err error)
- func DefaultBehaviorOnFatal()
- func Fatal(msg string, code int)
- func RegexRetryFunction(retryErrorRegexes []string) func(error) bool
- func RetryOnErrorCommand(command *cobra.Command, fn func(error) bool) *cobra.Command
- func SeeAlsoText(commands ...string) string
- func StandardErrorMessage(err error) (string, bool)
- func UsageError(cmd *cobra.Command, format string, args ...interface{}) error
Constants ¶
const (
DefaultCommandRetries = 3
)
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 BashExample ¶
BashExample returns markdown for a bash script expression for the CLI help
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 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-Kubectl commands.
func DefaultBehaviorOnFatal ¶
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func Fatal ¶
Fatal prints the message (if provided) and then exits. If V(2) or greater, glog.Logger().Fatal is invoked for extended information.
func RegexRetryFunction ¶ added in v3.0.25
RegexRetryFunction uses a list of supplied regexes and returns a function that will accept an error and return true if if the error matches against any supplied regexes
func RetryOnErrorCommand ¶ added in v3.0.25
RetryOnErrorCommand accepts an existing cobra Command with an optional function to determine which errors constitute ones which will cause the command to be reattempted
func SeeAlsoText ¶
SeeAlsoText returns text to describe which other commands to look at which are related to the current command
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 glog.
This method is generic to the command in use and may be used by non-Kubectl commands.
Types ¶
This section is empty.