MCPcopy Create free account
hub / github.com/HashLoad/boss / LoadConfiguration

Function LoadConfiguration

env/configuration.go:160–184  ·  view source on GitHub ↗
(cachePath string)

Source from the content-addressed store, hash-verified

158}
159
160func 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}

Callers 1

env.goFile · 0.85

Calls 3

ErrFunction · 0.92
Md5MachineIDFunction · 0.92
makeDefaultFunction · 0.85

Tested by

no test coverage detected