Documentation
¶
Index ¶
- Constants
- func AvailableLogLevels() string
- func Error(msg string, args ...interface{})
- func Fatal(msg string, args ...interface{})
- func FatalWithExitCode(code int, msg string, args ...interface{})
- func GetKubeConfig(ctx context.Context, namespace string, kubeConfig string, kubecontext string) (*kube.KubernetesClient, error)
- func InitLogging()
- func LogFormatter(format string) (logrus.Formatter, error)
- func MarshalStruct(s any, outputFormat string) ([]byte, error)
- func PrintVersion(v *version.Version, format string)
- func ReadFromTerm(prompt string, maxRetries int, isValid func(s string) (valid bool)) (string, error)
- func StringToLoglevel(l string) (logrus.Level, error)
- func StructToTabwriter(s any, tw *tabwriter.Writer) error
- func ValidPort(num int) error
Constants ¶
const ( VersionFormatText = "text" VersionFormatJSONCompact = "json" VersionFormatJSONIndent = "json-indent" VersionFormatYAML = "yaml" )
Variables ¶
This section is empty.
Functions ¶
func AvailableLogLevels ¶
func AvailableLogLevels() string
func FatalWithExitCode ¶
func GetKubeConfig ¶
func InitLogging ¶
func InitLogging()
InitLogging will initialize logrus with the setting and hooks we want it to use by default.
func MarshalStruct ¶
MarshalStruct marshals any tagged struct in the output format given. Formats supported are json, yaml and text. Struct fields to be marshaled must be exported and properly tagged.
func PrintVersion ¶
func ReadFromTerm ¶
func ReadFromTerm(prompt string, maxRetries int, isValid func(s string) (valid bool)) (string, error)
ReadFromTerm displays a prompt and reads user input from the terminal
It writes prompt to stdout and then reads user input from stdin.
If isValid is nil, the string entered by the user will be immediately returned. Otherwise, if isValid is non-nil, it will determine the validity of the user's input.
maxRetries specifies how often the user is allowed to retry their input. If maxRetries is -1, the function will only return once the input is considered valid, otherwise the function will return an error after maxRetries has been reached.
func StructToTabwriter ¶
StructToTabwriter takes any struct s and produces a formatted text output using the tabwriter tw. The fields in struct s to render must be tagged properly with a "text" tag, and they must be exported.
This function will not flush the tabwriter's writer, so the caller is expected to do that after this function returns.
An error will be returned if the data type passed as s was unexpected.
Types ¶
This section is empty.