Documentation ¶
Index ¶
- Constants
- func LabelSliceSHA256Sum(labels []Label) (string, error)
- type Label
- func (l *Label) AbsoluteKey() string
- func (l *Label) Equals(b *Label) bool
- func (l *Label) IsAllLabel() bool
- func (l *Label) IsValid() bool
- func (l *Label) Matches(target *Label) bool
- func (l *Label) Resolve(owner LabelOwner)
- func (l *Label) SetOwner(owner LabelOwner)
- func (l Label) String() string
- func (l *Label) UnmarshalJSON(data []byte) error
- type LabelOwner
- type LabelPrefix
- type LabelPrefixCfg
- type Labels
- func (l Labels) AppendPrefixInKey(prefix string) Labels
- func (l Labels) DeepCopy() Labels
- func (l Labels) DeleteMarked() bool
- func (l Labels) GetModel() []string
- func (l Labels) MarkAllForDeletion()
- func (l Labels) MergeLabels(from Labels)
- func (l Labels) SHA256Sum() string
- func (l Labels) ToSlice() []Label
- type OpLabels
Constants ¶
const ( // IDNameAll is a special label which matches all labels. IDNameAll = "all" // IDNameHost is the label used for the hostname ID. IDNameHost = "host" // IDNameWorld is the label used for the world ID. IDNameWorld = "world" )
const (
// LPCfgFileVersion represents the version of a Label Prefix Configuration File
LPCfgFileVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func LabelSliceSHA256Sum ¶
LabelSliceSHA256Sum returns SHA256 checksum from the labels.
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 ¶
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 NewOwnedLabel ¶
func NewOwnedLabel(key string, value string, source string, owner LabelOwner) *Label
NewOwnedLabel returns a new label like NewLabel but also assigns an owner
func ParseLabel ¶
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 ¶
ParseStringLabelsInOrder returns label representations from strings in order.
func (*Label) AbsoluteKey ¶
AbsoluteKey if set returns the absolute key path, otherwise returns the label's Key.
func (*Label) Equals ¶
Equals returns true if source, AbsoluteKey() and Value are equal and false otherwise.
func (*Label) IsAllLabel ¶
IsAllLabel returns true if the label is reserved and matches with IDNameAll.
func (*Label) Matches ¶
Matches returns true if it's a special label or the label equals the target.
func (*Label) Resolve ¶
func (l *Label) Resolve(owner LabelOwner)
Resolve resolves the absolute key path for this Label from policyNode.
func (*Label) SetOwner ¶
func (l *Label) SetOwner(owner LabelOwner)
SetOwner modifies the owner of a label
func (Label) 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 ¶
UnmarshalJSON TODO create better explanation about unmarshall with examples
type LabelOwner ¶
LabelOwner represents owner of the label.
type LabelPrefix ¶
LabelPrefix is the cilium's representation of a container label.
func ParseLabelPrefix ¶
func ParseLabelPrefix(label string) *LabelPrefix
ParseLabelPrefix returns a LabelPrefix created from the string label parameter.
func (LabelPrefix) String ¶
func (p LabelPrefix) String() string
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
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) Append ¶
func (cfg *LabelPrefixCfg) Append(l *LabelPrefix)
Append adds an additional allowed label prefix to the configuration
func (*LabelPrefixCfg) FilterLabels ¶
func (cfg *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 ¶
Labels is a map of labels where the map's key is the same as the label's key.
func LabelSlice2LabelsMap ¶
LabelSlice2LabelsMap returns a Labels' map with all labels from the given slice of label.
func Map2Labels ¶
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 ¶
NewLabelsFromModel creates labels from string array.
func ParseStringLabels ¶
ParseStringLabels returns label representations from strings.
func (Labels) AppendPrefixInKey ¶
AppendPrefixInKey appends the given prefix to all the Key's of the map and the respective Labels' Key.
func (Labels) DeleteMarked ¶
DeleteMarked deletes the labels which have the DeletionMark set and returns true if any of them were deleted.
func (Labels) MarkAllForDeletion ¶
func (l Labels) MarkAllForDeletion()
MarkAllForDeletion marks all the labels with the DeletionMark.
func (Labels) MergeLabels ¶
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}}
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 }
OpLabels represents the the possible types.
func NewOplabelsFromModel ¶
func NewOplabelsFromModel(base *models.LabelConfiguration) *OpLabels
NewOplabelsFromModel creates new label from the model.