Skip to content

Commit

Permalink
config: add validation of domain name (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo authored Sep 10, 2021
1 parent f26b34f commit 2dc5ce0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions flexibleengine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}

Expand Down

0 comments on commit 2dc5ce0

Please sign in to comment.