mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 06:02:18 +00:00
Add dns-952-identifier validation to service ids.
This commit is contained in:
@@ -58,3 +58,13 @@ func IsCIdentifier(value string) bool {
|
||||
func IsValidPortNum(port int) bool {
|
||||
return 0 < port && port < 65536
|
||||
}
|
||||
|
||||
const dns952IdentifierFmt string = "[a-z]([-a-z0-9]*[a-z0-9])?"
|
||||
|
||||
var dns952Regexp = regexp.MustCompile("^" + dns952IdentifierFmt + "$")
|
||||
|
||||
const dns952MaxLength = 24
|
||||
|
||||
func IsDNS952Label(value string) bool {
|
||||
return len(value) <= dns952MaxLength && dns952Regexp.MatchString(value)
|
||||
}
|
||||
|
Reference in New Issue
Block a user