mirror of
https://github.com/docker/compose.git
synced 2026-10-21 03:12:52 +00:00
Allow setting config dir with env var
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
parent
d218c0745e
commit
b7fb7e2e84
1 changed files with 7 additions and 3 deletions
|
|
@ -51,10 +51,14 @@ type ConfigFlags struct {
|
|||
|
||||
// AddConfigFlags adds persistent (global) flags
|
||||
func (c *ConfigFlags) AddConfigFlags(flags *pflag.FlagSet) {
|
||||
flags.StringVar(&c.Config, ConfigFlagName, filepath.Join(home(), ConfigFileDir), "Location of the client config files `DIRECTORY`")
|
||||
flags.StringVar(&c.Config, ConfigFlagName, confDir(), "Location of the client config files `DIRECTORY`")
|
||||
}
|
||||
|
||||
func home() string {
|
||||
func confDir() string {
|
||||
env := os.Getenv("DOCKER_CONFIG")
|
||||
if env != "" {
|
||||
return env
|
||||
}
|
||||
home, _ := os.UserHomeDir()
|
||||
return home
|
||||
return filepath.Join(home, ConfigFileDir)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue