mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Report validation errors when command-line flag parsing fails.
Before this, I was stumped with invalid argument "federation=kubernetes-federation.test." for --federations=federation=kubernetes-federation.test.: federation not a valid federation name but now invalid argument "federation=kubernetes-federation.test." for --federations=federation=kubernetes-federation.test.: "kubernetes-federation.test." not a valid domain name: ["must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)* (e.g. 'example.com')"]
This commit is contained in:
parent
8b817c4a0d
commit
62c052bb6b
@ -112,13 +112,13 @@ func (fv federationsVar) Set(keyVal string) error {
|
||||
splits := strings.SplitN(strings.TrimSpace(val), "=", 2)
|
||||
name := strings.TrimSpace(splits[0])
|
||||
domain := strings.TrimSpace(splits[1])
|
||||
if len(validation.IsDNS1123Label(name)) != 0 {
|
||||
return fmt.Errorf("%s not a valid federation name", name)
|
||||
if errs := validation.IsDNS1123Label(name); len(errs) != 0 {
|
||||
return fmt.Errorf("%q not a valid federation name: %q", name, errs)
|
||||
}
|
||||
// The federation domain name need not strictly be domain names, we
|
||||
// accept valid dns names with subdomain components.
|
||||
if len(validation.IsDNS1123Subdomain(domain)) != 0 {
|
||||
return fmt.Errorf("%s not a valid federation name", name)
|
||||
if errs := validation.IsDNS1123Subdomain(domain); len(errs) != 0 {
|
||||
return fmt.Errorf("%q not a valid domain name: %q", domain, errs)
|
||||
}
|
||||
fv.nameDomainMap[name] = domain
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user