utils

package
v1.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(err error)

CheckErr logs the error and exits with a non-zero code. This is similar to cobra.CheckErr except that it prints with logrus.

func ConvertStringToTypeOrDefault

func ConvertStringToTypeOrDefault[T any](str string, defaultValue T) T

ConvertStringToTypeOrDefault converts a string to the type of the default value. If string is empty, it will return the default value. If string is not empty, it will attempt to convert it to the type of the default value. If conversion fails, it will return the default value.

func GetKernelVersion

func GetKernelVersion() (string, error)

func GetOSRelease

func GetOSRelease() (string, error)

func GetPackageManagerType

func GetPackageManagerType(osRelease string) (pkgmgr.PackageManagerType, error)

func HandleResult

func HandleResult(resultBytes []byte, outputFile string, logger *logrus.Entry) error

func IsModuleLoaded

func IsModuleLoaded(moduleName string) (bool, error)

func SetFlagHidden

func SetFlagHidden(cmd *cobra.Command, option string)

SetFlagHidden adds a option flag to the given command and mark it as hidden. This is useful for hiding flags that are not meant to be used or are not intended to be exposed to users via the command-line help menus.

func SetGlobalOptionsLocal

func SetGlobalOptionsLocal(cmd *cobra.Command, globalOpts *types.GlobalCmdOptions)

SetGlobalOptionsLocal sets global options for local commands.

func SetGlobalOptionsRemote

func SetGlobalOptionsRemote(cmd *cobra.Command, globalOpts *types.GlobalCmdOptions)

SetGlobalOptionsRemote sets global options for remote commands.

func SetLog

func SetLog(logLevel string) error

SetLog initializes logrus. It sets log level and timestamp format.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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