blob: 493f61e20074b60dc430a1ed2b671a7070999517 [file] [log] [blame]
Jon Perritt816d2a02014-03-11 20:49:46 -05001package 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//Populates an ApiCriteria struct with the api values
20//from one of the api maps
21func PopulateApi(variant string) (ApiCriteria, error) {
22 var Api ApiCriteria
23 var variantMap map[string]interface{}
24
25 switch variant {
26 case "":
27 variantMap = OpenstackApi
28
29 case "openstack":
30 variantMap = OpenstackApi
31
32 case "rackspace":
33 variantMap = RackspaceApi
34 }
35
36 err := mapstructure.Decode(variantMap, &Api)
37 if err != nil {
38 return Api, err
39 }
40 return Api, err
41}