utils

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTypeShort = log.LstdFlags
	LogType      = log.LstdFlags | log.Lshortfile
)

Variables

This section is empty.

Functions

func GetBoolValue

func GetBoolValue(dataValue, dataName string) (result bool, err error)

func GetK8sAPILogger added in v1.4.4

func GetK8sAPILogger() *logger

func GetLogger added in v1.4.4

func GetLogger() *logger

func HomeDir

func HomeDir() string

func ParseTime

func ParseTime(data string) (*int64, error)

func PtrInt64

func PtrInt64(value int64) *int64

func PtrString

func PtrString(value string) *string

nolint deadcode

func RandomString

func RandomString(n int) string

RandomString returns random string of size n

Types

type LogLevel added in v1.4.4

type LogLevel int8
const (
	Panic   LogLevel = 1
	Error   LogLevel = 2
	Warning LogLevel = 3
	Info    LogLevel = 4
	Debug   LogLevel = 5
	Trace   LogLevel = 6
)

type LogLevelValue added in v1.4.4

type LogLevelValue struct {
	LogLevel LogLevel
}

LogLevel used to automatically distinct namespace/name string

func (*LogLevelValue) UnmarshalFlag added in v1.4.4

func (n *LogLevelValue) UnmarshalFlag(value string) error

UnmarshalFlag Unmarshal flag

type Logger added in v1.4.4

type Logger interface {
	Print(args ...interface{}) // always print regardles of Log level
	Trace(args ...interface{}) // used for heavy duty output everything, not recommended for production
	Debug(args ...interface{}) // used to have detailed output of application flow
	Info(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Err(args ...interface{}) []error
	Panic(args ...interface{})

	Printf(format string, args ...interface{})   // similar to fmt.SPrintf function
	Tracef(format string, args ...interface{})   // similar to fmt.SPrintf function
	Debugf(format string, args ...interface{})   // similar to fmt.SPrintf function
	Infof(format string, args ...interface{})    // similar to fmt.SPrintf function
	Warningf(format string, args ...interface{}) // similar to fmt.SPrintf function
	Errorf(format string, args ...interface{})   // similar to fmt.SPrintf function
	Panicf(format string, args ...interface{})   // similar to fmt.SPrintf function

	SetLevel(level LogLevel)
	ShowFilename(show bool)
}

Logger provides functions to writing log messages level can be defined only as `trace`, `debug`, `info`, `warning`, `error` error and panic are always printed, panic also exits application.

if nil is sent, it won't be printed. This is usefull for printing errors only if they exist. ```

if err != nil {
  logger.Error(err)
}

``` can be shortened to ``` logger.Error(err) ```

type NamespaceValue

type NamespaceValue struct {
	Namespace, Name string
}

NamespaceValue used to automatically distinct namespace/name string

func (NamespaceValue) MarshalFlag

func (n NamespaceValue) MarshalFlag() (string, error)

MarshalFlag Marshals flag

func (*NamespaceValue) UnmarshalFlag

func (n *NamespaceValue) UnmarshalFlag(value string) error

UnmarshalFlag Unmarshal flag

type OSArgs

type OSArgs struct {
	Version               []bool         `short:"v" long:"version" description:"version"`
	DefaultBackendService NamespaceValue `` /* 131-byte string literal not displayed */
	DefaultCertificate    NamespaceValue `long:"default-ssl-certificate" default:"" description:"secret name of the certificate"`
	ConfigMap             NamespaceValue `long:"configmap" description:"configmap designated for HAProxy" default:""`
	ConfigMapTCPServices  NamespaceValue `long:"configmap-tcp-services" description:"configmap used to define tcp services" default:""`
	KubeConfig            string         `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
	NamespaceWhitelist    []string       `long:"namespace-whitelist" description:"whitelisted namespaces"`
	NamespaceBlacklist    []string       `long:"namespace-blacklist" description:"blacklisted namespaces"`
	OutOfCluster          bool           `short:"e" description:"use as out of cluster controller NOTE: experimental"`
	Test                  bool           `short:"t" description:"simulate running HAProxy"`
	Help                  []bool         `short:"h" long:"help" description:"show this help message"`
	IngressClass          string         `long:"ingress.class" default:"" description:"ingress.class to monitor in multiple controllers environment"`
	PublishService        string         `` /* 205-byte string literal not displayed */
	SyncPeriod            time.Duration  `` /* 133-byte string literal not displayed */
	LogLevel              LogLevelValue  `long:"log" default:"info" description:"level of log messages you can see"`
}

OSArgs contains arguments that can be sent to controller

Jump to

Keyboard shortcuts

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