labels

package
v0.0.0-...-a5bca4c Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ID_NAME_ALL   = "all"
	ID_NAME_HOST  = "host"
	ID_NAME_WORLD = "world"
)
View Source
const (
	// LPCfgFileVersion represents the version of a Label Prefix Configuration File
	LPCfgFileVersion = 1
)

Variables

This section is empty.

Functions

func LabelSliceSHA256Sum

func LabelSliceSHA256Sum(labels []Label) (string, error)

Types

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
	// Source can be on of the values present in const.go (e.g.: CiliumLabelSource)
	Source string `json:"source"`

	// Mark element to be used to find unused labels in lists
	DeletionMark bool `json:"-"`
	// contains filtered or unexported fields
}

Label is the cilium's representation of a container label.

func NewLabel

func NewLabel(key string, value string, source string) *Label

NewLabel returns a new label from the given key, value and source. If source is empty, the default value will be common.CiliumLabelSource. If key starts with '$', the source will be overwritten with common.ReservedLabelSource. If key contains ':', the value before ':' will be used as source if given source is empty, otherwise the value before ':' will be deleted and unused.

func ParseLabel

func ParseLabel(str string) *Label

ParseLabel returns the label representation of the given string. The str should be in the form of Source:Key=Value or Source:Key if Value is empty. It also parses short forms, for example: $host will be Label{Key: "host", Source: "reserved", Value: ""}.

func ParseStringLabelsInOrder

func ParseStringLabelsInOrder(strLbls []string) []Label

func (*Label) AbsoluteKey

func (l *Label) AbsoluteKey() string

AbsoluteKey if set returns the absolute key path, otherwise returns the label's Key.

func (*Label) Covers

func (l *Label) Covers(path string) bool

func (*Label) Equals

func (l *Label) Equals(b *Label) bool

Equals returns true if source, AbsoluteKey() and Value are equal and false otherwise.

func (*Label) IsAllLabel

func (l *Label) IsAllLabel() bool

func (*Label) IsValid

func (l *Label) IsValid() bool

IsValid returns true if Key != "".

func (*Label) Matches

func (l *Label) Matches(target *Label) bool

func (*Label) Resolve

func (l *Label) Resolve(policyNode LabelAttachment)

Resolve resolves the absolute key path for this Label from policyNode.

func (Label) String

func (l Label) String() string

String returns the string representation of Label in the for of Source:Key=Value or Source:Key if Value is empty.

func (*Label) UnmarshalJSON

func (l *Label) UnmarshalJSON(data []byte) error

UnmarshalJSON TODO create better explanation about unmarshall with examples

type LabelAttachment

type LabelAttachment interface {
	GetLabelParent() LabelAttachment
	Path() string
}

Interface to implement in order to attach a label to it

type LabelOp

type LabelOp map[LabelOpType]Labels

type LabelOpType

type LabelOpType string
const (
	AddLabelsOp     LabelOpType = "AddLabelsOp"
	DelLabelsOp     LabelOpType = "DelLabelsOp"
	EnableLabelsOp  LabelOpType = "EnableLabelsOp"
	DisableLabelsOp LabelOpType = "DisableLabelsOp"
)

type LabelPrefix

type LabelPrefix struct {
	Prefix string `json:"prefix"`
	Source string `json:"source"`
}

Label is the cilium's representation of a container label.

type LabelPrefixCfg

type LabelPrefixCfg struct {
	Version       int            `json:"version"`
	LabelPrefixes []*LabelPrefix `json:"valid-prefixes"`
}

LabelPrefixCfg is the label prefix configuration to filter labels of started containers.

func DefaultK8sLabelPrefixCfg

func DefaultK8sLabelPrefixCfg() *LabelPrefixCfg

DefaultK8sLabelPrefixCfg returns a default LabelPrefixCfg using the latest LPCfgFileVersion and the following label prefixes: Key: "k8s-app", Source: common.K8sLabelSource and Key: "version", Source: common.K8sLabelSource.

func DefaultLabelPrefixCfg

func DefaultLabelPrefixCfg() *LabelPrefixCfg

DefaultLabelPrefixCfg returns a default LabelPrefixCfg using the latest LPCfgFileVersion and the following label prefixes: Key: common.GlobalLabelPrefix, Source: common.CiliumLabelSource, Key: common.GlobalLabelPrefix, Source: common.CiliumLabelSource, Key: common.GlobalLabelPrefix, Source: common.K8sLabelSource and Key: common.K8sPodNamespaceLabel, Source: common.K8sLabelSource.

func ReadLabelPrefixCfgFrom

func ReadLabelPrefixCfgFrom(fileName string) (*LabelPrefixCfg, error)

ReadLabelPrefixCfgFrom reads a label prefix configuration file from fileName. If the version is not supported by us it returns an error.

func (*LabelPrefixCfg) FilterLabels

func (lpc *LabelPrefixCfg) FilterLabels(lbls Labels) Labels

FilterLabels returns Labels from the given labels that have the same source and the same prefix as one of lpc valid prefixes.

type Labels

type Labels map[string]*Label

Labels is a map of labels where the map's key is the same as the label's key.

func LabelSlice2LabelsMap

func LabelSlice2LabelsMap(lbls []Label) Labels

/ LabelSlice2LabelsMap returns a Labels' map with all labels from the given slice of label.

func Map2Labels

func Map2Labels(m map[string]string, source string) Labels

Map2Labels transforms in the form: map[key(string)]value(string) into Labels. The source argument will overwrite the source written in the key of the given map. Example: l := Map2Labels(map[string]string{"k8s:foo": "bar"}, "cilium") fmt.Printf("%+v\n", l)

map[string]Label{"foo":Label{Key:"foo", Value:"bar", Source:"cilium"}}

func NewLabelsFromModel

func NewLabelsFromModel(base []string) Labels

func ParseStringLabels

func ParseStringLabels(strLbls []string) Labels

func (Labels) AppendPrefixInKey

func (l Labels) AppendPrefixInKey(prefix string) Labels

AppendPrefixInKey appends the given prefix to all the Key's of the map and the respective Labels' Key.

func (Labels) DeepCopy

func (lbls Labels) DeepCopy() Labels

func (Labels) DeleteMarked

func (l Labels) DeleteMarked() bool

Deletes the labels which have the DeletionMark set and returns true if any

func (Labels) GetModel

func (lbls Labels) GetModel() []string

func (Labels) MarkAllForDeletion

func (l Labels) MarkAllForDeletion()

Marks all labels with the DeletionMark

func (Labels) MergeLabels

func (lbls Labels) MergeLabels(from Labels)

MergeLabels merges labels from into to. It overwrites all labels with the same Key as from written into to. Example: to := Labels{Label{key1, value1, source1}, Label{key2, value3, source4}} from := Labels{Label{key1, value3, source4}} to.MergeLabels(from) fmt.Printf("%+v\n", to)

Labels{Label{key1, value3, source4}, Label{key2, value3, source4}}

func (Labels) SHA256Sum

func (lbls Labels) SHA256Sum() string

SHA256Sum calculates lbls' internal SHA256Sum. For a particular set of labels is guarantee that it will always have the same SHA256Sum.

func (Labels) ToSlice

func (lbls Labels) ToSlice() []Label

/ ToSlice returns a slice of label with the values of the given Labels' map.

type OpLabels

type OpLabels struct {
	// Active labels that are enabled and disabled but not deleted
	Custom Labels
	// Labels derived from orchestration system
	Orchestration Labels
	// Orchestration labels which have been disabled
	Disabled Labels
}

func NewOplabelsFromModel

func NewOplabelsFromModel(base *models.LabelConfiguration) *OpLabels

func (*OpLabels) DeepCopy

func (o *OpLabels) DeepCopy() *OpLabels

func (*OpLabels) Enabled

func (o *OpLabels) Enabled() Labels

Jump to

Keyboard shortcuts

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