Skip to content

Commit

Permalink
Merge pull request #2161 from thaJeztah/config_dont_init
Browse files Browse the repository at this point in the history
config: don't call homedir on init()
  • Loading branch information
cpuguy83 authored May 7, 2020
2 parents 3080921 + 8a30653 commit f7185d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strings"
"sync"

"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"
Expand All @@ -23,17 +24,23 @@ const (
)

var (
configDir = os.Getenv("DOCKER_CONFIG")
initConfigDir sync.Once
configDir string
)

func init() {
func setConfigDir() {
if configDir != "" {
return
}
configDir = os.Getenv("DOCKER_CONFIG")
if configDir == "" {
configDir = filepath.Join(homedir.Get(), configFileDir)
}
}

// Dir returns the directory the configuration file is stored in
func Dir() string {
initConfigDir.Do(setConfigDir)
return configDir
}

Expand Down

0 comments on commit f7185d2

Please sign in to comment.