cmd/ipfs: Added getConfig function
Matt Bell committed
Oct 27, 2014 at 17:05 UTC
7d53e736cf0a525808864585b52e5df0c4107343
2 files changed
+10
-7
cmd/ipfs/daemon.go
+1
-7
@@ -43,13 +43,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
43
}
44
defer lk.Close()
45
46
- configFile, err := config.Filename(configPath)
47
- if err != nil {
48
- res.SetError(err, cmds.ErrNormal)
49
- return
50
- }
51
-
52
- config, err := config.Load(configFile)
46
+ config, err := getConfig(configPath)
47
if err != nil {
48
res.SetError(err, cmds.ErrNormal)
49
return
cmd/ipfs/ipfs.go
+9
@@ -149,3 +149,12 @@ func getConfigPath(req cmds.Request) (string, error) {
149
}
150
return configPath, nil
151
}
152
+
153
+func getConfig(path string) (*config.Config, error) {
154
+ configFile, err := config.Filename(path)
155
+ if err != nil {
156
+ return nil, err
157
+ }
158
+
159
+ return config.Load(configFile)
160
+}