common

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

View Source
const (

	// LoggingLevelNone for no logging
	LoggingLevelNone loggingLevelType = iota
	// LoggingLevelError for error level logging
	LoggingLevelError
	// LoggingLevelInfo for info level logging
	LoggingLevelInfo
	// LoggingLevelDebug for debug level logging
	LoggingLevelDebug
)

Variables

This section is empty.

Functions

func CloseLogFile

func CloseLogFile(f *os.File)

CloseLogFile finalizes logging

func GetNetworkIfname

func GetNetworkIfname(networkName string) string

GetNetworkIfname from a networkName return a device name by hashing the networkName and prefixing it with auxNetworkIfnamePrefix

func IsLoggingEnabled

func IsLoggingEnabled() bool

IsLoggingEnabled return true if loggingLevelEnvironmentVar is set

func LogDebug

func LogDebug(format string, args ...interface{})

LogDebug debug level logging function

func LogError

func LogError(format string, args ...interface{})

LogError error level logging function

func LogInfo

func LogInfo(format string, args ...interface{})

LogInfo info level logging function

func OpenLogFile

func OpenLogFile(params *LoggingParams) *os.File

OpenLogFile initializes logging

  • if loggingLevelEnvironmentVar is not defined or not enabled the log functions would be a nop
  • the optioanl params specifies the log file to use and log entries prefix, these can be overwritten via loggingFileEnvironmentVar and loggingPrefixEnvironmentVar env. variables respectively. Note: if a log file has not been specified, logs will be redirected to stderr

Types

type LoggingParams

type LoggingParams struct {
	File   string
	Prefix string
}

LoggingParams define logging parameters, File for the log filename and Prefix for log entries prefix

type NetworkConfig

type NetworkConfig struct {
	NetworkName  string   `json:"name"`                   // required parameter: the network name for the CRD network resource in k8s
	IfMAC        string   `json:"ifMac,omitempty"`        // optional parameter: the network device mac address in the form of 00:11:22:33:44:55
	IsPrimary    bool     `json:"isPrimary,omitempty"`    // optional parameter: specify that this network is associated with the primary device in the Pod i.e. eth0
	UpperLayers  []string `json:"upperLayers,omitempty"`  // optional parameter: specify the upper layers for this network i.e. a hierarchy in which this network is a lower layer of another network(s)
	Namespace    string   `json:"namespace,omitempty"`    // optional parameter: the namespace to which this network belongs to, if not specified it would be the namespace of the pod
	PodagentSkip bool     `json:"podagentSkip,omitempty"` // optional parameter: if true, then podagent won't try to configure this network
}

NetworkConfig is a struct of the Pod's annotations networks element (a json array of NetworkConfig)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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