Documentation ¶
Index ¶
- Constants
- func CmdToString(c cmd.Cmd) string
- func DeferIgnoreError(f func() error)
- func IgnoreError(err error)
- func IsTypeError(err error, target error) bool
- func NilError(err error) string
- func PrettyString(v interface{}) string
- func RandBytes(nByte int) (string, error)
- func RandString(length int) (string, error)
- func StreamCmdToLogs(c *cmd.Cmd, log logr.Logger)
- func StructToMap(s any) (map[string]any, error)
- type ContentType
- type ListOfErrors
- type MatchError
Constants ¶
const (
UserGroupAllPerm = 0770
)
Variables ¶
This section is empty.
Functions ¶
func CmdToString ¶
CmdToString generates a string representation of a command
func DeferIgnoreError ¶
func DeferIgnoreError(f func() error)
DeferIgnoreError is a helper function to ignore errors returned by functions called with defer.
func IgnoreError ¶
func IgnoreError(err error)
IgnoreError is a helper function to deal with errors.
func IsTypeError ¶
IsTypeError returns true if the error is of type TypeError or if any of the causes is of the given type. This is different from errors.Is because errors.Is relies on the Is interface being implemented for errors which isn't the case for many errors. This method uses reflect to compare error types.
func PrettyString ¶
func PrettyString(v interface{}) string
PrettyString returns a prettily formatted string of the object.
func RandBytes ¶
RandBytes generates a string with the given number of bytes. The string is base64 so the length is not the same as the number of bytes
func RandString ¶
RandString generates a random string of the desired length
func StreamCmdToLogs ¶
StreamCmdToLogs streams the output of a command to the logs
Types ¶
type ContentType ¶
type ContentType string
const ( ContentTypeJSON ContentType = "application/json" ContentTypeText ContentType = "text/plain" ContentTypeHTML ContentType = "text/html" )
type ListOfErrors ¶
ListOfErrors is used when we want to return more then one error. This happens when we want to keep going and accumulate errors
func (*ListOfErrors) AddCause ¶
func (l *ListOfErrors) AddCause(e error)
AddCause adds an error to the list.
func (*ListOfErrors) Error ¶
func (l *ListOfErrors) Error() string
Error returns a single error wrapping all the errors.
type MatchError ¶
MatchError is a function for matching errors. Returns empty string if no match
func NewTypeErrorMatcher ¶
func NewTypeErrorMatcher(target error) MatchError
NewTypeErrorMatcher creates a new MatchError function that matches errors of the given type.