Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit d457f9a

Browse files
authored
feat: set config path (#8)
1 parent 2bcbd37 commit d457f9a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

wrapper.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package wrapper
33
import (
44
"bytes"
55
"errors"
6+
"fmt"
7+
"os"
68
"os/exec"
79
)
810

@@ -26,17 +28,17 @@ func NewComposeWrapper(binaryPath string) (*ComposeWrapper, error) {
2628
}
2729

2830
// 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)
3133
}
3234

3335
// Down stop and remove containers
3436
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, "", "")
3638
}
3739

3840
// 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) {
4042
program := programPath(wrapper.binaryPath, "docker-compose")
4143

4244
if projectName != "" {
@@ -53,6 +55,12 @@ func (wrapper *ComposeWrapper) Command(command composeCommand, url, projectName,
5355

5456
var stderr bytes.Buffer
5557
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+
5664
cmd.Stderr = &stderr
5765

5866
output, err := cmd.Output()

0 commit comments

Comments
 (0)