From 09f1c97447855e1f114962e42212663fed59637d Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 28 Apr 2016 21:09:23 -0700 Subject: [PATCH] Clean up ValidateHasLabel() --- pkg/api/validation/validation.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index b983c60a71d..12d58438b7e 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -65,11 +65,13 @@ func ValidateHasLabel(meta api.ObjectMeta, fldPath *field.Path, key, expectedVal allErrs := field.ErrorList{} actualValue, found := meta.Labels[key] if !found { - allErrs = append(allErrs, field.Required(fldPath.Child("labels"), key+"="+expectedValue)) + allErrs = append(allErrs, field.Required(fldPath.Child("labels").Key(key), + fmt.Sprintf("must be '%s'", expectedValue))) return allErrs } if actualValue != expectedValue { - allErrs = append(allErrs, field.Invalid(fldPath.Child("labels"), meta.Labels, "expected "+key+"="+expectedValue)) + allErrs = append(allErrs, field.Invalid(fldPath.Child("labels").Key(key), meta.Labels, + fmt.Sprintf("must be '%s'", expectedValue))) } return allErrs }