type Labels … type Set … // String returns all labels listed as a human readable string. // Conveniently, exactly the format that ParseSelector takes. func (ls Set) String() string { … } // Has returns whether the provided label exists in the map. func (ls Set) Has(label string) bool { … } // Get returns the value in the map for the provided label. func (ls Set) Get(label string) string { … } // AsSelector converts labels into a selectors. It does not // perform any validation, which means the server will reject // the request if the Set contains invalid values. func (ls Set) AsSelector() Selector { … } // AsValidatedSelector converts labels into a selectors. // The Set is validated client-side, which allows to catch errors early. func (ls Set) AsValidatedSelector() (Selector, error) { … } // AsSelectorPreValidated converts labels into a selector, but // assumes that labels are already validated and thus doesn't // perform any validation. // According to our measurements this is significantly faster // in codepaths that matter at high scale. func (ls Set) AsSelectorPreValidated() Selector { … } // FormatLabels convert label map into plain string func FormatLabels(labelMap map[string]string) string { … } // Conflicts takes 2 maps and returns true if there a key match between // the maps but the value doesn't match, and returns false in other cases func Conflicts(labels1, labels2 Set) bool { … } // Merge combines given maps, and does not check for any conflicts // between the maps. In case of conflicts, second map (labels2) wins func Merge(labels1, labels2 Set) Set { … } // Equals returns true if the given maps are equal func Equals(labels1, labels2 Set) bool { … } // AreLabelsInWhiteList verifies if the provided label list // is in the provided whitelist and returns true, otherwise false. func AreLabelsInWhiteList(labels, whitelist Set) bool { … } // ConvertSelectorToLabelsMap converts selector string to labels map // and validates keys and values func ConvertSelectorToLabelsMap(selector string) (Set, error) { … }