mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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>
This commit is contained in:
parent
abdfb21e3a
commit
6ffb77afd4
5 changed files with 21 additions and 13 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/docker/docker/opts"
|
||||
flag "github.com/docker/docker/pkg/mflag"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,21 +18,14 @@ var (
|
|||
|
||||
func init() {
|
||||
if dockerCertPath == "" {
|
||||
dockerCertPath = filepath.Join(getHomeDir(), ".docker")
|
||||
dockerCertPath = filepath.Join(utils.GetHomeDir(), ".docker")
|
||||
}
|
||||
}
|
||||
|
||||
func getHomeDir() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return os.Getenv("USERPROFILE")
|
||||
}
|
||||
return os.Getenv("HOME")
|
||||
}
|
||||
|
||||
func getDaemonConfDir() string {
|
||||
// TODO: update for Windows daemon
|
||||
if runtime.GOOS == "windows" {
|
||||
return filepath.Join(os.Getenv("USERPROFILE"), ".docker")
|
||||
return filepath.Join(utils.GetHomeDir(), ".docker")
|
||||
}
|
||||
return "/etc/docker"
|
||||
}
|
||||
|
@ -60,7 +54,7 @@ func setDefaultConfFlag(flag *string, def string) {
|
|||
if *flDaemon {
|
||||
*flag = filepath.Join(getDaemonConfDir(), def)
|
||||
} else {
|
||||
*flag = filepath.Join(getHomeDir(), ".docker", def)
|
||||
*flag = filepath.Join(utils.GetHomeDir(), ".docker", def)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue