mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Clean up ValidateHasLabel()
This commit is contained in:
parent
493b3fab65
commit
09f1c97447
@ -65,11 +65,13 @@ func ValidateHasLabel(meta api.ObjectMeta, fldPath *field.Path, key, expectedVal
|
|||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
actualValue, found := meta.Labels[key]
|
actualValue, found := meta.Labels[key]
|
||||||
if !found {
|
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
|
return allErrs
|
||||||
}
|
}
|
||||||
if actualValue != expectedValue {
|
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
|
return allErrs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user