Documentation
¶
Index ¶
- Variables
- func BehaviorOnFatal(f func(string, int))
- func CheckErr(err error)
- func CommaSeperated[T any](slice []T) (commaSep string)
- func CreateTestDir(additionalPath string) (string, string, error)
- func DefaultBehaviorOnFatal()
- func Exists(path string) (bool, error)
- func ExistsInSlice(a string, b []string) bool
- func Fatal(msg string, code int)
- func NewPtr[T any](obj T) *T
- func SplitCommand(cmd *cobra.Command, _ interface{}) *cobra.Command
- func StandardErrorMessage(err error) (string, bool)
- func TrimSpaceInSlice(slice []string) []string
- func UsageError(cmd *cobra.Command, format string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
var BinaryName string
BinaryName the binary name to use in help docs
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
var TopLevelCommand string
TopLevelCommand the top level command name
Functions ¶
func BehaviorOnFatal ¶ added in v0.10.3
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 ¶ added in v0.10.3
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 CommaSeperated ¶ added in v0.12.0
func DefaultBehaviorOnFatal ¶ added in v0.10.3
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func ExistsInSlice ¶
ExistsInSlice ranges over a slice returning true if the input exists in the slice
func Fatal ¶ added in v0.10.3
Fatal prints the message (if provided) and then exits. If V(2) or greater, glog.Logger().Fatal is invoked for extended information.
func SplitCommand ¶ added in v0.10.3
SplitCommand helper command to ignore the options object
func StandardErrorMessage ¶ added in v0.10.3
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.
func TrimSpaceInSlice ¶
Types ¶
This section is empty.