Merge pull request #114412 from thockin/api_warn_workloads_name_not_dnslabel

Issue API warnings when workload names are not DNS labels
This commit is contained in:
Kubernetes Prow Robot
2022-12-16 18:07:41 -08:00
committed by GitHub
8 changed files with 95 additions and 40 deletions

View File

@@ -191,7 +191,13 @@ func IsDNS1123Label(value string) []string {
errs = append(errs, MaxLenError(DNS1123LabelMaxLength))
}
if !dns1123LabelRegexp.MatchString(value) {
errs = append(errs, RegexError(dns1123LabelErrMsg, dns1123LabelFmt, "my-name", "123-abc"))
if dns1123SubdomainRegexp.MatchString(value) {
// It was a valid subdomain and not a valid label. Since we
// already checked length, it must be dots.
errs = append(errs, "must not contain dots")
} else {
errs = append(errs, RegexError(dns1123LabelErrMsg, dns1123LabelFmt, "my-name", "123-abc"))
}
}
return errs
}