(cachePath string)
| 158 | } |
| 159 | |
| 160 | func LoadConfiguration(cachePath string) (*Configuration, error) { |
| 161 | configuration := &Configuration{ |
| 162 | PurgeTime: 3, |
| 163 | } |
| 164 | |
| 165 | configFileName := filepath.Join(cachePath, consts.BossConfigFile) |
| 166 | buffer, err := ioutil.ReadFile(configFileName) |
| 167 | if err != nil { |
| 168 | return makeDefault(cachePath), err |
| 169 | } |
| 170 | err = json.Unmarshal(buffer, configuration) |
| 171 | if err != nil { |
| 172 | msg.Err("Fail to load cfg %s", err) |
| 173 | return makeDefault(cachePath), err |
| 174 | } |
| 175 | if configuration.Key != crypto.Md5MachineID() { |
| 176 | msg.Err("Failed to load auth... recreate login accounts") |
| 177 | configuration.Key = crypto.Md5MachineID() |
| 178 | configuration.Auth = make(map[string]*Auth) |
| 179 | } |
| 180 | |
| 181 | configuration.path = cachePath |
| 182 | |
| 183 | return configuration, nil |
| 184 | } |
no test coverage detected