@@ -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 )
@@ -197,6 +198,40 @@ func NewIdentityV3(client *gophercloud.ProviderClient) *gophercloud.ServiceClien
197
198
}
198
199
}
199
200
201
+ func NewIdentityAdminV2 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
202
+ eo .ApplyDefaults ("identity" )
203
+ eo .Availability = gophercloud .AvailabilityAdmin
204
+
205
+ url , err := client .EndpointLocator (eo )
206
+ if err != nil {
207
+ return nil , err
208
+ }
209
+
210
+ // Force using v2 API
211
+ if strings .Contains (url , "/v3" ) {
212
+ url = strings .Replace (url , "/v3" , "/v2.0" , - 1 )
213
+ }
214
+
215
+ return & gophercloud.ServiceClient {ProviderClient : client , Endpoint : url }, nil
216
+ }
217
+
218
+ func NewIdentityAdminV3 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
219
+ eo .ApplyDefaults ("identity" )
220
+ eo .Availability = gophercloud .AvailabilityAdmin
221
+
222
+ url , err := client .EndpointLocator (eo )
223
+ if err != nil {
224
+ return nil , err
225
+ }
226
+
227
+ // Force using v3 API
228
+ if strings .Contains (url , "/v2.0" ) {
229
+ url = strings .Replace (url , "/v2.0" , "/v3" , - 1 )
230
+ }
231
+
232
+ return & gophercloud.ServiceClient {ProviderClient : client , Endpoint : url }, nil
233
+ }
234
+
200
235
// NewObjectStorageV1 creates a ServiceClient that may be used with the v1 object storage package.
201
236
func NewObjectStorageV1 (client * gophercloud.ProviderClient , eo gophercloud.EndpointOpts ) (* gophercloud.ServiceClient , error ) {
202
237
eo .ApplyDefaults ("object-store" )
0 commit comments