mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Make IsValidLabelValue return error strings
This commit is contained in:
@@ -124,9 +124,12 @@ func parseLabels(spec []string) (map[string]string, []string, error) {
|
||||
for _, labelSpec := range spec {
|
||||
if strings.Index(labelSpec, "=") != -1 {
|
||||
parts := strings.Split(labelSpec, "=")
|
||||
if len(parts) != 2 || len(parts[1]) == 0 || !validation.IsValidLabelValue(parts[1]) {
|
||||
if len(parts) != 2 || len(parts[1]) == 0 {
|
||||
return nil, nil, fmt.Errorf("invalid label spec: %v", labelSpec)
|
||||
}
|
||||
if errs := validation.IsValidLabelValue(parts[1]); len(errs) != 0 {
|
||||
return nil, nil, fmt.Errorf("invalid label value: %q: %s", labelSpec, strings.Join(errs, ";"))
|
||||
}
|
||||
labels[parts[0]] = parts[1]
|
||||
} else if strings.HasSuffix(labelSpec, "-") {
|
||||
remove = append(remove, labelSpec[:len(labelSpec)-1])
|
||||
|
||||
Reference in New Issue
Block a user