mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
labels: Fixing linting errors.
This commit is contained in:
parent
628667a2b0
commit
f4d989ae92
@ -26,11 +26,11 @@ type Labels interface {
|
|||||||
Get(label string) (value string)
|
Get(label string) (value string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A map of label:value. Implements Labels.
|
// Set is a map of label:value. Implements Labels.
|
||||||
type Set map[string]string
|
type Set map[string]string
|
||||||
|
|
||||||
// All labels listed as a human readable string. Conveniently, exactly the format
|
// String returns all labels listed as a human readable string.
|
||||||
// that ParseSelector takes.
|
// Conveniently, exactly the format that ParseSelector takes.
|
||||||
func (ls Set) String() string {
|
func (ls Set) String() string {
|
||||||
selector := make([]string, 0, len(ls))
|
selector := make([]string, 0, len(ls))
|
||||||
for key, value := range ls {
|
for key, value := range ls {
|
||||||
@ -41,12 +41,12 @@ func (ls Set) String() string {
|
|||||||
return strings.Join(selector, ",")
|
return strings.Join(selector, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement Labels interface.
|
// Get returns the value for the provided label.
|
||||||
func (ls Set) Get(label string) string {
|
func (ls Set) Get(label string) string {
|
||||||
return ls[label]
|
return ls[label]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience function: convert these labels to a selector.
|
// AsSelector converts labels into a selectors.
|
||||||
func (ls Set) AsSelector() Selector {
|
func (ls Set) AsSelector() Selector {
|
||||||
return SelectorFromSet(ls)
|
return SelectorFromSet(ls)
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Represents a selector.
|
// Selector represents a label selector.
|
||||||
type Selector interface {
|
type Selector interface {
|
||||||
// Returns true if this selector matches the given set of labels.
|
// Matches returns true if this selector matches the given set of labels.
|
||||||
Matches(Labels) bool
|
Matches(Labels) bool
|
||||||
|
|
||||||
// Prints a human readable version of this selector.
|
// String returns a human readable string that represents this selector.
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ func try(selectorPiece, op string) (lhs, rhs string, ok bool) {
|
|||||||
return "", "", false
|
return "", "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a Set, return a Selector which will match exactly that Set.
|
// SelectorFromSet converts a Set into a Selector.
|
||||||
func SelectorFromSet(ls Set) Selector {
|
func SelectorFromSet(ls Set) Selector {
|
||||||
var items []Selector
|
var items []Selector
|
||||||
for label, value := range ls {
|
for label, value := range ls {
|
||||||
@ -99,7 +99,8 @@ func SelectorFromSet(ls Set) Selector {
|
|||||||
return andTerm(items)
|
return andTerm(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes a string repsenting a selector and returns an object suitable for matching, or an error.
|
// ParseSelector takes a string repsenting a selector and returns an
|
||||||
|
// object suitable for matching, or an error.
|
||||||
func ParseSelector(selector string) (Selector, error) {
|
func ParseSelector(selector string) (Selector, error) {
|
||||||
parts := strings.Split(selector, ",")
|
parts := strings.Split(selector, ",")
|
||||||
sort.StringSlice(parts).Sort()
|
sort.StringSlice(parts).Sort()
|
||||||
|
Loading…
Reference in New Issue
Block a user