7 "github.com/bytom/vapor/errors"
10 // Config represent root of config
12 OssConfig *OssConfig `json:"oss_config"`
13 VaporURL string `json:"vapor_url"`
18 Endpoint string `json:"endpoint"`
19 AccessKeyID string `json:"access_key_id"`
20 AccessKeySecret string `json:"access_key_secret"`
24 type OssConfig struct {
25 Login *Login `json:"login"`
26 Bucket string `json:"bucket"`
27 Directory string `json:"directory"`
30 // LoadConfig read path file to the config object for Upload from Vapor to OSS
31 func LoadConfig(config interface{}) error {
32 if len(os.Args) <= 1 {
33 return errors.New("Please setup the config file path as Args[1]")
35 return LoadConfigByPath(os.Args[1], config)
38 // LoadConfigByPath read path file to the config object
39 func LoadConfigByPath(path string, config interface{}) error {
40 configFile, err := os.Open(path)
42 return errors.Wrap(err, "fail to open config file")
45 defer configFile.Close()
46 return json.NewDecoder(configFile).Decode(config)