fix(compose): add project directory option to compose command [EE-7093] (#11870)
parent
9e0e0a12fa
commit
0c870bf37b
|
@ -126,6 +126,10 @@ func (wrapper *PluginWrapper) command(command composeCommand, options libstack.O
|
||||||
command.WithHost(options.Host)
|
command.WithHost(options.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.ProjectDir != "" {
|
||||||
|
command.WithProjectDirectory(options.ProjectDir)
|
||||||
|
}
|
||||||
|
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
|
|
||||||
args := []string{}
|
args := []string{}
|
||||||
|
@ -237,6 +241,10 @@ func (command *composeCommand) WithEnvFilePath(envFilePath string) {
|
||||||
command.globalArgs = append(command.globalArgs, "--env-file", envFilePath)
|
command.globalArgs = append(command.globalArgs, "--env-file", envFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (command *composeCommand) WithProjectDirectory(projectDir string) {
|
||||||
|
command.globalArgs = append(command.globalArgs, "--project-directory", projectDir)
|
||||||
|
}
|
||||||
|
|
||||||
func (command *composeCommand) ToArgs() []string {
|
func (command *composeCommand) ToArgs() []string {
|
||||||
return append(command.globalArgs, command.subCommandAndArgs...)
|
return append(command.globalArgs, command.subCommandAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ type WaitResult struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
// WorkingDir is the working directory for the command execution
|
||||||
WorkingDir string
|
WorkingDir string
|
||||||
Host string
|
Host string
|
||||||
ProjectName string
|
ProjectName string
|
||||||
|
@ -42,6 +43,10 @@ type Options struct {
|
||||||
EnvFilePath string
|
EnvFilePath string
|
||||||
// Env is a list of environment variables to pass to the command, example: "FOO=bar"
|
// Env is a list of environment variables to pass to the command, example: "FOO=bar"
|
||||||
Env []string
|
Env []string
|
||||||
|
// ProjectDir is the working directory for containers created by docker compose file.
|
||||||
|
// By default, it is an empty string, which means it corresponds to the path of the compose file itself.
|
||||||
|
// This is particularly helpful when mounting a relative path.
|
||||||
|
ProjectDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeployOptions struct {
|
type DeployOptions struct {
|
||||||
|
|
Loading…
Reference in New Issue