a more general way of generating provider clients

This commit is contained in:
Jon Perritt 2015-01-25 20:59:01 -07:00
parent b1b693e461
commit b0e8cd5dd3
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package openstack
import (
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
)
func newClient(c *Config, service, region string, version int) (*gophercloud.ServiceClient, error) {
var serviceClient *gophercloud.ServiceClient
switch service {
case "compute":
if version == 2 {
serviceClient, err = openstack.NewComputeV2(c.osClient, gophercloud.EndpointOpts{
Region: region,
})
}
case "networking":
if version == 2 {
serviceClient, err = openstack.NewNetworkV2(c.osClient, gophercloud.EndpointOpts{
Region: region,
})
}
}
return serviceClient, err
}