-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
43 lines (36 loc) · 976 Bytes
/
config.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
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"encoding/json"
"fmt"
"os"
)
type Config struct {
ServerUrl string `json:"server_url"`
CbsdEnv string `json:"cbsdenv"`
Broker string `json:"broker"`
ImageList string `json:"imagelist"`
Recomendation string `json:"recomendation"`
Freejname string `json:"freejname"`
Freeid string `json:"freeid"`
Cloud_images_list string `json:"cloud_images_list"`
Iso_images_list string `json:"iso_images_list"`
Flavors_list string `json:"flavors_list"`
BeanstalkConfig `json:"beanstalkd"`
}
func LoadConfiguration(file string) (Config, error) {
var config Config
configFile, err := os.Open(file)
defer configFile.Close()
if err != nil {
fmt.Println(err.Error())
return config, err
}
jsonParser := json.NewDecoder(configFile)
err = jsonParser.Decode(&config)
if err != nil {
fmt.Printf("config error: %s: %s\n", file, err.Error())
return config, err
}
fmt.Printf("Using config file: %s\n", file)
return config, err
}