From 7d53e736cf0a525808864585b52e5df0c4107343 Mon Sep 17 00:00:00 2001 From: Matt Bell <mappum@gmail.com> Date: Mon, 27 Oct 2014 17:05:48 -0700 Subject: [PATCH] cmd/ipfs: Added getConfig function --- cmd/ipfs/daemon.go | 8 +------- cmd/ipfs/ipfs.go | 9 +++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 79a4b4df3..88fa1f508 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -43,13 +43,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) { } defer lk.Close() - configFile, err := config.Filename(configPath) - if err != nil { - res.SetError(err, cmds.ErrNormal) - return - } - - config, err := config.Load(configFile) + config, err := getConfig(configPath) if err != nil { res.SetError(err, cmds.ErrNormal) return diff --git a/cmd/ipfs/ipfs.go b/cmd/ipfs/ipfs.go index e8316ca29..dbff801ed 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -149,3 +149,12 @@ func getConfigPath(req cmds.Request) (string, error) { } return configPath, nil } + +func getConfig(path string) (*config.Config, error) { + configFile, err := config.Filename(path) + if err != nil { + return nil, err + } + + return config.Load(configFile) +} -- GitLab