blob: 54ca9be4834b7abbad95dbc455cdf05f53a139db [file] [log] [blame]
Torrent Glenn12bc4df2014-02-03 13:26:41 -08001package gophercloud
2
3import(
4 "github.com/mitchellh/mapstructure"
5)
6
7//The default generic openstack api
8var OpenstackApi = map[string]interface{}{
9 "UrlChoice": PublicURL,
10}
11
12// Api for use with rackspace
13var RackspaceApi = map[string]interface{}{
14 "Name": "cloudServersOpenStack",
15 "VersionId": "2",
16 "UrlChoice": PublicURL,
17}
18
19
20//Populates an ApiCriteria struct with the api values
21//from one of the api maps
22func PopulateApi(variant string) (ApiCriteria, error){
23 var Api ApiCriteria
24 var variantMap map[string]interface{}
25
26 switch variant {
27 case "":
28 variantMap = OpenstackApi
29
30 case "openstack":
31 variantMap = OpenstackApi
32
33 case "rackspace":
34 variantMap = RackspaceApi
35 }
36
37 err := mapstructure.Decode(variantMap,&Api)
38 if err != nil{
39 return Api,err
40 }
41 return Api, err
42}