// Package controlname validates identifiers used as control-plane key segments. package controlname import ( "regexp" "strings" ) var ( account = regexp.MustCompile(`^[a-z]{3,16}$`) app = regexp.MustCompile(`^[a-z][a-z0-9-]{0,31}$`) label = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`) ) func ValidAccount(s string) bool { return account.MatchString(s) } func ValidApp(s string) bool { return app.MatchString(s) } func ValidLabel(s string) bool { return label.MatchString(s) } func ValidHostShape(host string) bool { if host == "" || len(host) > 253 { return false } for _, part := range strings.Split(host, ".") { if !ValidLabel(part) { return false } } return true }