utils

package
v1.9.14 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func EqualSliceStringsWithoutOrder

func EqualSliceStringsWithoutOrder(a, b []string) bool

func GetBoolValue

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

func GetLogger

func GetLogger() *logger

func GetPodPrefix

func GetPodPrefix(podName string) (prefix string, err error)

func Hash

func Hash(input []byte) string

func HomeDir

func HomeDir() string

func ParseInt

func ParseInt(data string) (v int64, err error)

func ParseSize

func ParseSize(size string) (*int64, error)

func ParseTime

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

func PtrInt64

func PtrInt64(value int64) *int64

func PtrString

func PtrString(value string) *string

Types

type Errors

type Errors []error

func (*Errors) Add

func (e *Errors) Add(errors ...error)

func (*Errors) Result

func (e *Errors) Result() error

type LogLevel

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

type LogLevelValue

type LogLevelValue struct {
	LogLevel LogLevel
}

LogLevel used to automatically distinct namespace/name string

func (*LogLevelValue) UnmarshalFlag

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

UnmarshalFlag Unmarshal flag

type Logger

type Logger interface {
	Print(args ...interface{}) // always print regardless 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 useful 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) String

func (n NamespaceValue) String() string

func (*NamespaceValue) UnmarshalFlag

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

UnmarshalFlag Unmarshal flag

type OSArgs

type OSArgs struct {
	Help                       []bool         `short:"h" long:"help" description:"show this help message"`
	Version                    []bool         `short:"v" long:"version" description:"version"`
	DefaultBackendService      NamespaceValue `` /* 131-byte string literal not displayed */
	DefaultBackendPort         int            `long:"default-backend-port" description:"port to use for default service" default:"6061"`
	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:""`
	ConfigMapErrorFiles        NamespaceValue `` /* 127-byte string literal not displayed */
	ConfigMapPatternFiles      NamespaceValue `` /* 137-byte string literal not displayed */
	KubeConfig                 string         `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
	IngressClass               string         `long:"ingress.class" default:"" description:"ingress.class to monitor in multiple controllers environment"`
	EmptyIngressClass          bool           `` /* 175-byte string literal not displayed */
	PublishService             string         `` /* 205-byte string literal not displayed */
	NamespaceWhitelist         []string       `long:"namespace-whitelist" description:"whitelisted namespaces"`
	NamespaceBlacklist         []string       `long:"namespace-blacklist" description:"blacklisted namespaces"`
	SyncPeriod                 time.Duration  `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
	CacheResyncPeriod          time.Duration  `` /* 147-byte string literal not displayed */
	LogLevel                   LogLevelValue  `long:"log" default:"info" description:"level of log messages you can see"`
	External                   bool           `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`
	Test                       bool           `short:"t" description:"simulate running HAProxy"`
	DisableIPV4                bool           `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
	DisableIPV6                bool           `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"`
	DisableHTTP                bool           `long:"disable-http" description:"toggle to disable the HTTP frontend"`
	DisableHTTPS               bool           `long:"disable-https" description:"toggle to disable the HTTPs frontend"`
	HTTPBindPort               int64          `long:"http-bind-port" default:"80" description:"port to listen on for HTTP traffic"`
	HTTPSBindPort              int64          `long:"https-bind-port" default:"443" description:"port to listen on for HTTPS traffic"`
	IPV4BindAddr               string         `long:"ipv4-bind-address" default:"0.0.0.0" description:"IPv4 address the Ingress Controller listens on (if enabled)"`
	IPV6BindAddr               string         `long:"ipv6-bind-address" default:"::" description:"IPv6 address the Ingress Controller listens on (if enabled)"`
	HealthzBindPort            int64          `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
	StatsBindPort              int64          `long:"stats-bind-port" default:"1024" description:"port to listen on for stats page"`
	LocalPeerPort              int64          `long:"localpeer-port" default:"10000" description:"port to listen on for local peer"`
	Program                    string         `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"`
	CfgDir                     string         `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"`
	RuntimeDir                 string         `long:"runtime-dir" description:"path to HAProxy runtime directory. NOTE: works only in External mode"`
	DisableServiceExternalName bool           `long:"disable-service-external-name" description:"disable forwarding to ExternalName Services due to CVE-2021-25740"`
	UseWiths6Overlay           bool           `long:"with-s6-overlay" description:"use s6 overlay to start/stpop/reload HAProxy"`
	ControllerPort             int            `long:"controller-port" description:"port to listen on for controller data: prometheus, pprof" default:"6060"`
	PprofEnabled               bool           `long:"pprof" short:"p" description:"enable pprof"`
	PrometheusEnabled          bool           `long:"prometheus" description:"enable prometheus of IC data"`
	ChannelSize                int64          `` /* 172-byte string literal not displayed */
	JobCheckCRD                bool           `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"`
}

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