DockerCLI/cli/config
Sebastiaan van Stijn d513e46bfc
cli/config: prevent warning if HOME is not set
commit c2626a8270 replaced the use of
github.com/docker/docker/pkg/homedir with Golang's os.UserHomeDir().

This change was partially reverted in 7a279af43d
to account for situations where `$HOME` is not set.

In  situations where no configuration file is present in `~/.config/`, the CLI
falls back to looking for the (deprecated) `~/.dockercfg` configuration file,
which was still using `os.UserHomeDir()`, which produces an error/warning if
`$HOME` is not set.

This patch introduces a helper function and a global variable to get the user's
home-directory. The global variable is used to prevent repeatedly looking up
the user's information (which, depending on the setup can be a costly operation).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c85a37dbb4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-04 14:38:27 +01:00
..
configfile Config-file: remove User-Agent from config.json when saving 2020-10-01 15:04:39 +02:00
credentials Use golang.org/x/sys/execabs 2021-01-28 22:27:59 +00:00
types Remove docker api dependency from cli/config 2019-01-31 21:25:43 +00:00
config.go cli/config: prevent warning if HOME is not set 2021-02-04 14:38:27 +01:00
config_test.go cli/config: prevent warning if HOME is not set 2021-02-04 14:38:27 +01:00