fix S1017 and S1002 in pkg/apis/core/validation/validation.go

This commit is contained in:
shawnhanx
2021-11-13 17:02:40 +08:00
parent e4c795168b
commit 063e64c4ec

View File

@@ -3179,9 +3179,7 @@ func validatePodDNSConfig(dnsConfig *core.PodDNSConfig, dnsPolicy *core.DNSPolic
} }
for i, search := range dnsConfig.Searches { for i, search := range dnsConfig.Searches {
// it is fine to have a trailing dot // it is fine to have a trailing dot
if strings.HasSuffix(search, ".") { search = strings.TrimSuffix(search, ".")
search = search[0 : len(search)-1]
}
allErrs = append(allErrs, ValidateDNS1123Subdomain(search, fldPath.Child("searches").Index(i))...) allErrs = append(allErrs, ValidateDNS1123Subdomain(search, fldPath.Child("searches").Index(i))...)
} }
// Validate options. // Validate options.
@@ -6320,7 +6318,7 @@ func validateWindowsHostProcessPod(podSpec *core.PodSpec, fieldPath *field.Path,
} }
// At present Windows Pods which contain HostProcess containers must also set HostNetwork. // At present Windows Pods which contain HostProcess containers must also set HostNetwork.
if hostNetwork != true { if !hostNetwork {
errMsg := "hostNetwork must be true if pod contains any hostProcess containers" errMsg := "hostNetwork must be true if pod contains any hostProcess containers"
allErrs = append(allErrs, field.Invalid(fieldPath.Child("hostNetwork"), hostNetwork, errMsg)) allErrs = append(allErrs, field.Invalid(fieldPath.Child("hostNetwork"), hostNetwork, errMsg))
} }