cmdutil

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionFormatText        = "text"
	VersionFormatJSONCompact = "json"
	VersionFormatJSONIndent  = "json-indent"
	VersionFormatYAML        = "yaml"
)

Variables

This section is empty.

Functions

func AvailableLogLevels

func AvailableLogLevels() string

func Error

func Error(msg string, args ...interface{})

func Fatal

func Fatal(msg string, args ...interface{})

func FatalWithExitCode

func FatalWithExitCode(code int, msg string, args ...interface{})

func GetKubeConfig

func GetKubeConfig(ctx context.Context, namespace string, kubeConfig string, kubecontext string) (*kube.KubernetesClient, error)

func InitLogging

func InitLogging()

InitLogging will initialize logrus with the setting and hooks we want it to use by default.

func LogFormatter

func LogFormatter(format string) (logrus.Formatter, error)

func MarshalStruct

func MarshalStruct(s any, outputFormat string) ([]byte, error)

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 PrintVersion(v *version.Version, format string)

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 StringToLoglevel

func StringToLoglevel(l string) (logrus.Level, error)

func StructToTabwriter

func StructToTabwriter(s any, tw *tabwriter.Writer) error

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.

func ValidPort

func ValidPort(num int) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL