Commit 2cb84fb6 authored by k8s-merge-robot's avatar k8s-merge-robot Committed by GitHub

Merge pull request #27815 from mml/fed-validation

Automatic merge from submit-queue 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.: federation not a valid federation 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')"]
parents 1ea3b171 62c052bb
...@@ -112,13 +112,13 @@ func (fv federationsVar) Set(keyVal string) error { ...@@ -112,13 +112,13 @@ func (fv federationsVar) Set(keyVal string) error {
splits := strings.SplitN(strings.TrimSpace(val), "=", 2) splits := strings.SplitN(strings.TrimSpace(val), "=", 2)
name := strings.TrimSpace(splits[0]) name := strings.TrimSpace(splits[0])
domain := strings.TrimSpace(splits[1]) domain := strings.TrimSpace(splits[1])
if len(validation.IsDNS1123Label(name)) != 0 { if errs := validation.IsDNS1123Label(name); len(errs) != 0 {
return fmt.Errorf("%s not a valid federation name", name) return fmt.Errorf("%q not a valid federation name: %q", name, errs)
} }
// The federation domain name need not strictly be domain names, we // The federation domain name need not strictly be domain names, we
// accept valid dns names with subdomain components. // accept valid dns names with subdomain components.
if len(validation.IsDNS1123Subdomain(domain)) != 0 { if errs := validation.IsDNS1123Subdomain(domain); len(errs) != 0 {
return fmt.Errorf("%s not a valid federation name", name) return fmt.Errorf("%q not a valid domain name: %q", domain, errs)
} }
fv.nameDomainMap[name] = domain fv.nameDomainMap[name] = domain
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment