forked from gophercloud/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clients.go
32 lines (27 loc) · 806 Bytes
/
clients.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package clients contains functions for creating service clients
// for utils services.
// That clients can be used in acceptance tests.
package clients
import (
"os"
"github.com/cro8ox/gophercloud"
"github.com/cro8ox/gophercloud/openstack"
"github.com/cro8ox/utils/gnocchi"
)
// NewGnocchiV1Client returns a *ServiceClient for making calls
// to the Gnocchi v1 API.
// An error will be returned if authentication or client
// creation was not possible.
func NewGnocchiV1Client() (*gophercloud.ServiceClient, error) {
ao, err := openstack.AuthOptionsFromEnv()
if err != nil {
return nil, err
}
client, err := openstack.AuthenticatedClient(ao)
if err != nil {
return nil, err
}
return gnocchi.NewGnocchiV1(client, gophercloud.EndpointOpts{
Region: os.Getenv("OS_REGION_NAME"),
})
}