Extract $HOME usages into utils.GetHomeDir()

Refactored getHomeDir in docker/docker to GetHomeDir in utils
pkg. Currently covers all use cases on the client-side.

Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
Upstream-commit: 6ffb77afd4c3705322417f0673d254038f01a187
Component: engine
This commit is contained in:
Ahmet Alp Balkan
2015-01-26 11:04:16 -08:00
committed by Ahmet Alp Balkan
parent a99f7cd89b
commit 63b6feced2
5 changed files with 21 additions and 13 deletions

View File

@ -17,6 +17,7 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
)
type DockerCli struct {
@ -104,7 +105,7 @@ func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bo
}
func (cli *DockerCli) LoadConfigFile() (err error) {
cli.configFile, err = registry.LoadConfig(os.Getenv("HOME"))
cli.configFile, err = registry.LoadConfig(utils.GetHomeDir())
if err != nil {
fmt.Fprintf(cli.err, "WARNING: %s\n", err)
}

View File

@ -388,7 +388,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
var out2 engine.Env
err = out2.Decode(stream)
if err != nil {
cli.configFile, _ = registry.LoadConfig(os.Getenv("HOME"))
cli.configFile, _ = registry.LoadConfig(utils.GetHomeDir())
return err
}
registry.SaveConfig(cli.configFile)