diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go index 4f39d92..4a3ab84 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/urls.go @@ -1,23 +1,26 @@ package tenants -import "github.com/gophercloud/gophercloud" +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/openstack/utils" +) func listURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("v2.0/tenants") + return utils.V2ServiceURL(client, "tenants") } func getURL(client *gophercloud.ServiceClient, tenantID string) string { - return client.ServiceURL("v2.0/tenants", tenantID) + return utils.V2ServiceURL(client, "tenants", tenantID) } func createURL(client *gophercloud.ServiceClient) string { - return client.ServiceURL("v2.0/tenants") + return utils.V2ServiceURL(client, "tenants") } func deleteURL(client *gophercloud.ServiceClient, tenantID string) string { - return client.ServiceURL("v2.0/tenants", tenantID) + return utils.V2ServiceURL(client, "tenants", tenantID) } func updateURL(client *gophercloud.ServiceClient, tenantID string) string { - return client.ServiceURL("v2.0/tenants", tenantID) + return utils.V2ServiceURL(client, "tenants", tenantID) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/users/urls.go b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/users/urls.go index 4613e7a..5a4f0ff 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/users/urls.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/users/urls.go @@ -1,25 +1,28 @@ package users -import "github.com/gophercloud/gophercloud" +import ( + "github.com/gophercloud/gophercloud" + "github.com/gophercloud/gophercloud/openstack/utils" +) const ( - tenantPath = "v2.0/tenants" - userPath = "v2.0/users" + tenantPath = "tenants" + userPath = "users" rolePath = "roles" ) func ResourceURL(c *gophercloud.ServiceClient, id string) string { - return c.ServiceURL(userPath, id) + return utils.V2ServiceURL(c, userPath, id) } func rootURL(c *gophercloud.ServiceClient) string { - return c.ServiceURL(userPath) + return utils.V2ServiceURL(c, userPath) } func listRolesURL(c *gophercloud.ServiceClient, tenantID, userID string) string { - return c.ServiceURL(tenantPath, tenantID, userPath, userID, rolePath) + return utils.V2ServiceURL(c, tenantPath, tenantID, userPath, userID, rolePath) } func listUsersURL(c *gophercloud.ServiceClient, tenantID string) string { - return c.ServiceURL(tenantPath, tenantID, "users") + return utils.V2ServiceURL(c, tenantPath, tenantID, userPath) } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go b/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go index c605d08..4d0529f 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/utils/choose_version.go @@ -7,6 +7,18 @@ import ( "github.com/gophercloud/gophercloud" ) +// V2ServiceURL insures service url use v2.0 version. +func V2ServiceURL(client *gophercloud.ServiceClient, parts ...string) string { + baseURL := client.ResourceBaseURL() + if strings.HasSuffix(baseURL, "v2.0/") { + return baseURL + strings.Join(parts, "/") + } + if strings.HasSuffix(baseURL, "v3/") { + return strings.Replace(baseURL, "v3/", "v2.0/", 1) + strings.Join(parts, "/") + } + return baseURL + "v2.0/" + strings.Join(parts, "/") +} + // Version is a supported API version, corresponding to a vN package within the appropriate service. type Version struct { ID string