Skip to content

Commit

Permalink
fix: Allow to use the COMPOSE_FILE variable in finch compose
Browse files Browse the repository at this point in the history
Add a process to convert the path of the file specified in the
COMPOSE_FILE variable to WSL path in Windows environment.

Signed-off-by: Hayato Kiwata <[email protected]>
  • Loading branch information
haytok committed Jun 27, 2024
1 parent 8751a9e commit 207ba50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/finch/nerdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"path/filepath"
"runtime"
"strings"

"golang.org/x/exp/slices"
Expand Down Expand Up @@ -240,9 +241,17 @@ func (nc *nerdctlCommand) run(cmdName string, args []string) error {
var passedEnvArgs []string
for _, e := range passedEnvs {
v, b := nc.systemDeps.LookupEnv(e)
if b {
passedEnvArgs = append(passedEnvArgs, fmt.Sprintf("%s=%s", e, v))
if !b {
continue
}
if runtime.GOOS == "windows" && e == "COMPOSE_FILE" {
wslPath, err := convertToWSLPath(nc.systemDeps, v)
if err != nil {
return err
}
v = wslPath
}
passedEnvArgs = append(passedEnvArgs, fmt.Sprintf("%s=%s", e, v))
}

var additionalEnv []string
Expand Down
4 changes: 4 additions & 0 deletions cmd/finch/nerdctl_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/runfinch/finch/pkg/flog"
)

func convertToWSLPath(_ NerdctlCommandSystemDeps, _ string) (string, error) {
return "", nil
}

var aliasMap = map[string]string{}

var argHandlerMap = map[string]map[string]argHandler{}
Expand Down

0 comments on commit 207ba50

Please sign in to comment.