@@ -3,6 +3,7 @@ package openstack
3
3
import (
4
4
"fmt"
5
5
"net/url"
6
+ "strings"
6
7
7
8
"github.com/rackspace/gophercloud"
8
9
tokens2 "github.com/rackspace/gophercloud/openstack/identity/v2/tokens"
@@ -64,8 +65,8 @@ func AuthenticatedClient(options gophercloud.AuthOptions) (*gophercloud.Provider
64
65
// Authenticate or re-authenticate against the most recent identity service supported at the provided endpoint.
65
66
func Authenticate (client * gophercloud.ProviderClient , options gophercloud.AuthOptions ) error {
66
67
versions := []* utils.Version {
67
- & utils. Version {ID : v20 , Priority : 20 , Suffix : "/v2.0/" },
68
- & utils. Version {ID : v30 , Priority : 30 , Suffix : "/v3/" },
68
+ {ID : v20 , Priority : 20 , Suffix : "/v2.0/" },
69
+ {ID : v30 , Priority : 30 , Suffix : "/v3/" },
69
70
}
70
71
71
72
chosen , endpoint , err := utils .ChooseVersion (client , versions )
@@ -198,6 +199,40 @@ func NewIdentityV3(client *gophercloud.ProviderClient) *gophercloud.ServiceClien
198
199
}
199
200
}
200
201
202
+ func NewIdentityAdminV2 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
203
+ eo .ApplyDefaults ("identity" )
204
+ eo .Availability = gophercloud .AvailabilityAdmin
205
+
206
+ url , err := client .EndpointLocator (eo )
207
+ if err != nil {
208
+ return nil , err
209
+ }
210
+
211
+ // Force using v2 API
212
+ if strings .Contains (url , "/v3" ) {
213
+ url = strings .Replace (url , "/v3" , "/v2.0" , - 1 )
214
+ }
215
+
216
+ return & gophercloud.ServiceClient {ProviderClient : client , Endpoint : url }, nil
217
+ }
218
+
219
+ func NewIdentityAdminV3 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
220
+ eo .ApplyDefaults ("identity" )
221
+ eo .Availability = gophercloud .AvailabilityAdmin
222
+
223
+ url , err := client .EndpointLocator (eo )
224
+ if err != nil {
225
+ return nil , err
226
+ }
227
+
228
+ // Force using v3 API
229
+ if strings .Contains (url , "/v2.0" ) {
230
+ url = strings .Replace (url , "/v2.0" , "/v3" , - 1 )
231
+ }
232
+
233
+ return & gophercloud.ServiceClient {ProviderClient : client , Endpoint : url }, nil
234
+ }
235
+
201
236
// NewObjectStorageV1 creates a ServiceClient that may be used with the v1 object storage package.
202
237
func NewObjectStorageV1 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
203
238
eo .ApplyDefaults ("object-store" )
0 commit comments