Merge pull request #86 from justinsb/match_service_by_type_not_name
Add test for type matching
diff --git a/authenticate.go b/authenticate.go
index 52bc1ab..886a6fa 100644
--- a/authenticate.go
+++ b/authenticate.go
@@ -17,6 +17,9 @@
// The TenantId field is optional for the Identity V2 API.
TenantId string
+ // The TenantName can be specified instead of the TenantId
+ TenantName string
+
// AllowReauth should be set to true if you grant permission for Gophercloud to cache
// your credentials in memory, and to allow Gophercloud to attempt to re-authenticate
// automatically if/when your token expires. If you set it to false, it will not cache
@@ -36,6 +39,7 @@
type Auth struct {
PasswordCredentials PasswordCredentials `json:"passwordCredentials"`
TenantId string `json:"tenantId,omitempty"`
+ TenantName string `json:"tenantName,omitempty"`
}
// PasswordCredentials provides a JSON encoding wrapper for passing credentials to the Identity
@@ -114,7 +118,8 @@
Username: options.Username,
Password: options.Password,
},
- TenantId: options.TenantId,
+ TenantId: options.TenantId,
+ TenantName: options.TenantName,
},
},
Results: &struct {
diff --git a/context.go b/context.go
index ebad36c..21d0ae0 100644
--- a/context.go
+++ b/context.go
@@ -2,6 +2,7 @@
import (
"net/http"
+ "strings"
)
// Provider structures exist for each tangible provider of OpenStack service.
@@ -92,6 +93,12 @@
return descriptor, nil
}
}
+ if strings.Contains(name, "://") {
+ p = Provider {
+ AuthEndpoint: name,
+ }
+ return p, nil
+ }
return Provider{}, ErrProvider
}