common

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// OperationalPath is the base path to store the operational details in consul.
	OperationalPath = "cilium-net/operational"

	// LastFreeLabelIDKeyPath is the path where the Last free UUID is stored in consul.
	LastFreeLabelIDKeyPath = OperationalPath + "/Labels/LastUUID"
	// LabelsKeyPath is the base path where labels are stored in consul.
	LabelsKeyPath = OperationalPath + "/Labels/SHA256SUMLabels"
	// LabelIDKeyPath is the base path where the IDs are stored in consul.
	LabelIDKeyPath = OperationalPath + "/Labels/IDs"
	// MaxSetOfLabels is maximum number of set of labels that can be stored in consul.
	MaxSetOfLabels = uint32(0xFFFF)
	// LastFreeServiceIDKeyPath is the path where the Last free UUID is stored in consul.
	LastFreeServiceIDKeyPath = OperationalPath + "/Services/LastUUID"
	// ServicesKeyPath is the base path where services are stored in consul.
	ServicesKeyPath = OperationalPath + "/Services/SHA256SUMServices"
	// ServiceIDKeyPath is the base path where the IDs are stored in consul.
	ServiceIDKeyPath = OperationalPath + "/Services/IDs"
	// MaxSetOfServiceID is maximum number of set of service IDs that can be stored in consul.
	MaxSetOfServiceID = uint32(0xFFFF)
	// FirstFreeServiceID is the first ID for which the services should be assigned.
	FirstFreeServiceID = uint32(1)

	// PathDelimiter is the delimiter used in the labels paths.
	PathDelimiter = "."
	// AnyLabelSource is the default label source to select any source.
	AnyLabelSource = "any"
	// CiliumLabelSource is the default label source for the labels read from containers.
	CiliumLabelSource = "cilium"
	// ReservedLabelSource is the label source for reserved types.
	ReservedLabelSource = "reserved"
	// ReservedLabelSourceKeyPrefix is the BaseLabelSourceExtPrefix suffixed with the ReservedLabelSource and PathDelimiter.
	ReservedLabelSourceKeyPrefix = ReservedLabelSource + PathDelimiter
	// EndpointsPerHost is the maximum number of endpoints allowed per host. It should
	// represent the same number of IPv6 addresses supported on each node.
	EndpointsPerHost = 0xFFFF
	// GroupFilePath is the unix group file path.
	GroupFilePath = "/etc/group"
	// CiliumGroupName is the cilium's unix group name.
	CiliumGroupName = "cilium"

	// CHeaderFileName is the name of the C header file for BPF programs for a
	// particular endpoint.
	CHeaderFileName = "lxc_config.h"
	// NetdevHeaderFileName is the name of the header file used for bpf_netdev.c and bpf_overlay.c.
	NetdevHeaderFileName = "netdev_config.h"
	// CiliumCHeaderPrefix is the prefix using when printing/writing an endpoint in a
	// base64 form.
	CiliumCHeaderPrefix = "CILIUM_BASE64_"
)
View Source
const (
	SLevel = "syslog.level"

	Syslog   = "syslog"
	Fluentd  = "fluentd"
	Logstash = "logstash"
)

Variables

View Source
var (
	Green  = color.New(color.FgGreen).SprintFunc()
	Yellow = color.New(color.FgYellow).SprintFunc()
	Red    = color.New(color.FgRed).SprintFunc()
)

Functions

func FindEPConfigCHeader

func FindEPConfigCHeader(basePath string, epFiles []os.FileInfo) string

FindEPConfigCHeader returns the full path of the file that is the CHeaderFileName from the slice of files

func FmtDefineAddress

func FmtDefineAddress(name string, addr []byte) string

FmtDefineAddress returns the a define string from the given name and addr. Example: fmt.Print(FmtDefineAddress("foo", []byte{1, 2, 3})) // "#define foo { .addr = { 0x1, 0x2, 0x3 } }\n"

func FmtDefineArray

func FmtDefineArray(name string, array []byte) string

FmtDefineArray returns the a define string from the given name and array. Example: fmt.Print(FmtDefineArray("foo", []byte{1, 2, 3})) // "#define foo { 0x1, 0x2, 0x3 }\n"

func FmtDefineComma added in v0.9.0

func FmtDefineComma(name string, addr []byte) string

func GetCiliumVersionString

func GetCiliumVersionString(epCHeaderFilePath string) (string, error)

GetCiliumVersionString returns the first line containing CiliumCHeaderPrefix.

func GetGroupIDByName

func GetGroupIDByName(grpName string) (int, error)

GetGroupIDByName returns the group ID for the given grpName.

func RequireRootPrivilege added in v0.9.0

func RequireRootPrivilege(cmd string)

RequireRootPrivilege checks if the user running cmd is root. If not, it exits the program

func SetupLogging added in v0.9.0

func SetupLogging(loggers []string, logOpts map[string]string, tag string, debug bool) error

SetupLogging sets up each logging service provided in loggers and configures each logger with the provided logOpts.

func Swab16

func Swab16(n uint16) uint16

Swab16 swaps the endianness of n.

func Swab32

func Swab32(n uint32) uint32

Swab32 swaps the endianness of n.

Types

type MapOptions added in v0.9.0

type MapOptions struct {
	// contains filtered or unexported fields
}

MapOptions holds a map of values and a validation function.

func NewMapOpts added in v0.9.0

func NewMapOpts(values map[string]string, validator Validator) *MapOptions

NewMapOpts creates a new MapOpts with the specified map of values and an optional validator.

func (*MapOptions) Set added in v0.9.0

func (opts *MapOptions) Set(value string) error

Set validates, if needed, the input value and adds it to the internal map, by splitting on '='.

func (*MapOptions) String added in v0.9.0

func (opts *MapOptions) String() string

func (*MapOptions) Type added in v0.9.0

func (opts *MapOptions) Type() string

Type returns a string name for this Option type

type NamedMapOptions added in v0.9.0

type NamedMapOptions struct {
	MapOptions
	// contains filtered or unexported fields
}

NamedMapOptions is a MapOptions struct with a configuration name. This struct is useful to keep reference to the assigned field name in the internal configuration struct.

func NewNamedMapOptions added in v0.9.0

func NewNamedMapOptions(name string, values *map[string]string, validator Validator) *NamedMapOptions

NewNamedMapOptions creates a reference to a new NamedMapOpts struct.

type Validator added in v0.9.0

type Validator func(val string) (string, error)

Validator returns a validated string along with a possible error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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