From 2dc5ce07ddc5de496a2334760867e245f22e27da Mon Sep 17 00:00:00 2001 From: shichangkuo Date: Fri, 10 Sep 2021 17:12:20 +0800 Subject: [PATCH] config: add validation of domain name (#607) --- flexibleengine/config.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flexibleengine/config.go b/flexibleengine/config.go index de16c7938..03ee146e2 100644 --- a/flexibleengine/config.go +++ b/flexibleengine/config.go @@ -342,10 +342,8 @@ func (c *Config) getDomainID() (string, error) { identityClient.ResourceBase = identityClient.Endpoint + "auth/" - opts := domains.ListOpts{ - Name: c.DomainName, - } - allPages, err := domains.List(identityClient, &opts).AllPages() + // the List request does not support query options + allPages, err := domains.List(identityClient, nil).AllPages() if err != nil { return "", fmt.Errorf("List domains failed, err=%s", err) } @@ -359,6 +357,10 @@ func (c *Config) getDomainID() (string, error) { return "", fmt.Errorf("domain was not found") } + if c.DomainName != "" && c.DomainName != all[0].Name { + return "", fmt.Errorf("domain %s was not found, got %s", c.DomainName, all[0].Name) + } + return all[0].ID, nil }