Generalize loadConfig method to avoid reading from disk (#5819)

As we move to multiple config backends like local disk and etcd,
config file should not be read from the disk, instead the quick
package should load and verify for duplicate entries.
This commit is contained in:
Nitish Tiwari
2018-04-14 03:44:19 +05:30
committed by Harshavardhana
parent 57b8db2088
commit 638f01f9e4
6 changed files with 97 additions and 96 deletions

View File

@@ -136,6 +136,11 @@ func loadFileConfig(filename string, v interface{}) error {
if runtime.GOOS == "windows" {
fileData = []byte(strings.Replace(string(fileData), "\r\n", "\n", -1))
}
if err = checkDupJSONKeys(string(fileData)); err != nil {
return err
}
// Unmarshal file's content
return toUnmarshaller(filepath.Ext(filename))(fileData, v)
}