@@ -3,6 +3,8 @@ package wrapper
3
3
import (
4
4
"bytes"
5
5
"errors"
6
+ "fmt"
7
+ "os"
6
8
"os/exec"
7
9
)
8
10
@@ -26,17 +28,17 @@ func NewComposeWrapper(binaryPath string) (*ComposeWrapper, error) {
26
28
}
27
29
28
30
// Up create and start containers
29
- func (wrapper * ComposeWrapper ) Up (filePath , url , projectName , envFilePath string ) ([]byte , error ) {
30
- return wrapper .Command (newUpCommand (filePath ), url , projectName , envFilePath )
31
+ func (wrapper * ComposeWrapper ) Up (filePath , url , projectName , envFilePath , configPath string ) ([]byte , error ) {
32
+ return wrapper .Command (newUpCommand (filePath ), url , projectName , envFilePath , configPath )
31
33
}
32
34
33
35
// Down stop and remove containers
34
36
func (wrapper * ComposeWrapper ) Down (filePath , url , projectName string ) ([]byte , error ) {
35
- return wrapper .Command (newDownCommand (filePath ), url , projectName , "" )
37
+ return wrapper .Command (newDownCommand (filePath ), url , projectName , "" , "" )
36
38
}
37
39
38
40
// Command exectue a docker-compose commanåd
39
- func (wrapper * ComposeWrapper ) Command (command composeCommand , url , projectName , envFilePath string ) ([]byte , error ) {
41
+ func (wrapper * ComposeWrapper ) Command (command composeCommand , url , projectName , envFilePath , configPath string ) ([]byte , error ) {
40
42
program := programPath (wrapper .binaryPath , "docker-compose" )
41
43
42
44
if projectName != "" {
@@ -53,6 +55,12 @@ func (wrapper *ComposeWrapper) Command(command composeCommand, url, projectName,
53
55
54
56
var stderr bytes.Buffer
55
57
cmd := exec .Command (program , command .ToArgs ()... )
58
+
59
+ if configPath != "" {
60
+ cmd .Env = os .Environ ()
61
+ cmd .Env = append (cmd .Env , fmt .Sprintf ("DOCKER_CONFIG=%s" , configPath ))
62
+ }
63
+
56
64
cmd .Stderr = & stderr
57
65
58
66
output , err := cmd .Output ()
0 commit comments