Lots of URL normalization.
So it doesn't matter if you have a trailing / or not.
diff --git a/openstack/client.go b/openstack/client.go
index 253fcdc..d244053 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -22,6 +22,10 @@
// This is useful if you wish to explicitly control the version of the identity service that's used for authentication explicitly,
// for example.
func NewClient(endpoint string) (*gophercloud.ProviderClient, error) {
+ if !strings.HasSuffix(endpoint, "/") {
+ endpoint = endpoint + "/"
+ }
+
return &gophercloud.ProviderClient{IdentityEndpoint: endpoint}, nil
}
@@ -54,10 +58,6 @@
return err
}
- if !strings.HasSuffix(endpoint, "/") {
- endpoint = endpoint + "/"
- }
-
switch chosen.ID {
case v20:
v2Client := NewIdentityV2(client)
@@ -116,19 +116,9 @@
}
// Extract Endpoints from the catalog entries that match the requested Type, Name if provided, and Region if provided.
- var endpoints = make([]identity2.Endpoint, 0, 6)
+ var endpoints = make([]identity2.Endpoint, 0, 1)
for _, entry := range entries {
- matched := true
-
- if entry.Type != opts.Type {
- matched = false
- }
-
- if opts.Name != "" && entry.Name != opts.Name {
- matched = false
- }
-
- if matched {
+ if (entry.Type == opts.Type) && (opts.Name == "" || entry.Name == opts.Name) {
for _, endpoint := range entry.Endpoints {
if opts.Region == "" || endpoint.Region == opts.Region {
endpoints = append(endpoints, endpoint)
@@ -243,7 +233,7 @@
// NewIdentityV2 creates a ServiceClient that may be used to interact with the v2 identity service.
func NewIdentityV2(client *gophercloud.ProviderClient) *gophercloud.ServiceClient {
- v2Endpoint := client.IdentityEndpoint + "/v2.0/"
+ v2Endpoint := client.IdentityEndpoint + "v2.0/"
return &gophercloud.ServiceClient{
Provider: client,
@@ -253,7 +243,7 @@
// NewIdentityV3 creates a ServiceClient that may be used to access the v3 identity service.
func NewIdentityV3(client *gophercloud.ProviderClient) *gophercloud.ServiceClient {
- v3Endpoint := client.IdentityEndpoint + "/v3/"
+ v3Endpoint := client.IdentityEndpoint + "v3/"
return &gophercloud.ServiceClient{
Provider: client,