Merge pull request #77144 from kenegozi/key-in-invalid-label-error-message

Include the key of invalid label's value in error message
This commit is contained in:
Kubernetes Prow Robot 2019-05-07 14:31:15 -07:00 committed by GitHub
commit 167bc954fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -172,7 +172,7 @@ func ConvertSelectorToLabelsMap(selector string) (Set, error) {
return labelsMap, err
}
value := strings.TrimSpace(l[1])
if err := validateLabelValue(value); err != nil {
if err := validateLabelValue(key, value); err != nil {
return labelsMap, err
}
labelsMap[key] = value

View File

@ -162,7 +162,7 @@ func NewRequirement(key string, op selection.Operator, vals []string) (*Requirem
}
for i := range vals {
if err := validateLabelValue(vals[i]); err != nil {
if err := validateLabelValue(key, vals[i]); err != nil {
return nil, err
}
}
@ -837,9 +837,9 @@ func validateLabelKey(k string) error {
return nil
}
func validateLabelValue(v string) error {
func validateLabelValue(k, v string) error {
if errs := validation.IsValidLabelValue(v); len(errs) != 0 {
return fmt.Errorf("invalid label value: %q: %s", v, strings.Join(errs, "; "))
return fmt.Errorf("invalid label value: %q: at key: %q: %s", v, k, strings.Join(errs, "; "))
}
return nil
}