mirror of
https://github.com/docker/compose.git
synced 2025-10-11 18:38:47 +02:00
Fix: set PWD only if not set
Signed-off-by: Kian Eliasi <kian.elbo@gmail.com>
This commit is contained in:
parent
fa7e85ed83
commit
ce463d50b2
@ -383,32 +383,38 @@ func (o *ProjectOptions) remoteLoaders(dockerCli command.Cli) []loader.ResourceL
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
|
func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
|
||||||
pwd, err := os.Getwd()
|
opts := []cli.ProjectOptionsFn{
|
||||||
if err != nil {
|
cli.WithWorkingDirectory(o.ProjectDir),
|
||||||
return nil, err
|
// First apply os.Environment, always win
|
||||||
|
cli.WithOsEnv,
|
||||||
}
|
}
|
||||||
|
|
||||||
return cli.NewProjectOptions(o.ConfigPaths,
|
if _, present := os.LookupEnv("PWD"); !present {
|
||||||
append(po,
|
if pwd, err := os.Getwd(); err != nil {
|
||||||
cli.WithWorkingDirectory(o.ProjectDir),
|
return nil, err
|
||||||
// First apply os.Environment, always win
|
} else {
|
||||||
cli.WithOsEnv,
|
opts = append(opts, cli.WithEnv([]string{"PWD=" + pwd}))
|
||||||
// set PWD as this variable is not consistently supported on Windows
|
}
|
||||||
cli.WithEnv([]string{"PWD=" + pwd}),
|
}
|
||||||
// Load PWD/.env if present and no explicit --env-file has been set
|
|
||||||
cli.WithEnvFiles(o.EnvFiles...),
|
opts = append(opts,
|
||||||
// read dot env file to populate project environment
|
// Load PWD/.env if present and no explicit --env-file has been set
|
||||||
cli.WithDotEnv,
|
cli.WithEnvFiles(o.EnvFiles...),
|
||||||
// get compose file path set by COMPOSE_FILE
|
// read dot env file to populate project environment
|
||||||
cli.WithConfigFileEnv,
|
cli.WithDotEnv,
|
||||||
// if none was selected, get default compose.yaml file from current dir or parent folder
|
// get compose file path set by COMPOSE_FILE
|
||||||
cli.WithDefaultConfigPath,
|
cli.WithConfigFileEnv,
|
||||||
// .. and then, a project directory != PWD maybe has been set so let's load .env file
|
// if none was selected, get default compose.yaml file from current dir or parent folder
|
||||||
cli.WithEnvFiles(o.EnvFiles...),
|
cli.WithDefaultConfigPath,
|
||||||
cli.WithDotEnv,
|
// .. and then, a project directory != PWD maybe has been set so let's load .env file
|
||||||
// eventually COMPOSE_PROFILES should have been set
|
cli.WithEnvFiles(o.EnvFiles...),
|
||||||
cli.WithDefaultProfiles(o.Profiles...),
|
cli.WithDotEnv,
|
||||||
cli.WithName(o.ProjectName))...)
|
// eventually COMPOSE_PROFILES should have been set
|
||||||
|
cli.WithDefaultProfiles(o.Profiles...),
|
||||||
|
cli.WithName(o.ProjectName),
|
||||||
|
)
|
||||||
|
|
||||||
|
return cli.NewProjectOptions(o.ConfigPaths, append(po, opts...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginName is the name of the plugin
|
// PluginName is the name of the plugin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user