print more error details about CertSANs validation

pull/564/head
SataQiu 2019-01-20 08:42:09 +08:00
parent 6ce59dd1a2
commit 7bf6ff2ec1
1 changed files with 4 additions and 2 deletions

View File

@ -307,8 +307,10 @@ func ValidateEtcd(e *kubeadm.Etcd, fldPath *field.Path) field.ErrorList {
func ValidateCertSANs(altnames []string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
for _, altname := range altnames {
if len(validation.IsDNS1123Subdomain(altname)) != 0 && net.ParseIP(altname) == nil {
allErrs = append(allErrs, field.Invalid(fldPath, altname, "altname is not a valid dns label or ip address"))
if errs := validation.IsDNS1123Subdomain(altname); len(errs) != 0 {
if net.ParseIP(altname) == nil {
allErrs = append(allErrs, field.Invalid(fldPath, altname, fmt.Sprintf("altname is not a valid IP address or DNS label: %s", strings.Join(errs, "; "))))
}
}
}
return allErrs