mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #38171 from xingzhou/kube-typo
Automatic merge from submit-queue Fixed a typo of wildcard DNS regex variable name. Happened to see the typo while reading code, fixed the typo and refined the code.
This commit is contained in:
commit
0175399d49
@ -143,19 +143,19 @@ func IsDNS1035Label(value string) []string {
|
|||||||
// examples:
|
// examples:
|
||||||
// - valid: *.bar.com, *.foo.bar.com
|
// - valid: *.bar.com, *.foo.bar.com
|
||||||
// - invalid: *.*.bar.com, *.foo.*.com, *bar.com, f*.bar.com, *
|
// - invalid: *.*.bar.com, *.foo.*.com, *bar.com, f*.bar.com, *
|
||||||
const wildcardDNF1123SubdomainFmt = "\\*\\." + dns1123SubdomainFmt
|
const wildcardDNS1123SubdomainFmt = "\\*\\." + dns1123SubdomainFmt
|
||||||
|
|
||||||
// IsWildcardDNS1123Subdomain tests for a string that conforms to the definition of a
|
// IsWildcardDNS1123Subdomain tests for a string that conforms to the definition of a
|
||||||
// wildcard subdomain in DNS (RFC 1034 section 4.3.3).
|
// wildcard subdomain in DNS (RFC 1034 section 4.3.3).
|
||||||
func IsWildcardDNS1123Subdomain(value string) []string {
|
func IsWildcardDNS1123Subdomain(value string) []string {
|
||||||
wildcardDNS1123SubdomainRegexp := regexp.MustCompile("^\\*\\." + dns1123SubdomainFmt + "$")
|
wildcardDNS1123SubdomainRegexp := regexp.MustCompile("^" + wildcardDNS1123SubdomainFmt + "$")
|
||||||
|
|
||||||
var errs []string
|
var errs []string
|
||||||
if len(value) > DNS1123SubdomainMaxLength {
|
if len(value) > DNS1123SubdomainMaxLength {
|
||||||
errs = append(errs, MaxLenError(DNS1123SubdomainMaxLength))
|
errs = append(errs, MaxLenError(DNS1123SubdomainMaxLength))
|
||||||
}
|
}
|
||||||
if !wildcardDNS1123SubdomainRegexp.MatchString(value) {
|
if !wildcardDNS1123SubdomainRegexp.MatchString(value) {
|
||||||
errs = append(errs, RegexError(wildcardDNF1123SubdomainFmt, "*.example.com"))
|
errs = append(errs, RegexError(wildcardDNS1123SubdomainFmt, "*.example.com"))
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user