Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/commands/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ func (c *DockerCommand) setDockerComposeCommand(config *config.AppConfig) {
return
}

// it's possible that a user is still using docker-compose, so we'll check if 'docker comopose' is available, and if not, we'll fall back to 'docker-compose'
if os.Getenv(dockerHostEnvKey) != "" {
return
}

// it's possible that a user is still using docker-compose, so we'll check if 'docker compose' is available, and if not, we'll fall back to 'docker-compose'
err := c.OSCommand.RunCommand("docker compose version")
if err != nil {
config.UserConfig.CommandTemplates.DockerCompose = "docker-compose"
Expand Down
17 changes: 17 additions & 0 deletions pkg/commands/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"os"
"os/exec"
"testing"

"github.com/docker/docker/client"
Expand Down Expand Up @@ -89,3 +90,19 @@ func TestIsProjectScoped(t *testing.T) {
})
}
}

func TestSetDockerComposeCommandKeepsDefaultForRemoteDockerHost(t *testing.T) {
t.Setenv(dockerHostEnvKey, "ssh://example.com")

userConfig := config.GetDefaultConfig()
appConfig := &config.AppConfig{UserConfig: &userConfig}
osCommand := NewOSCommand(NewDummyLog(), appConfig)
osCommand.SetCommand(func(string, ...string) *exec.Cmd {
return exec.Command("sh", "-c", "exit 1")
})

dockerCommand := &DockerCommand{OSCommand: osCommand}
dockerCommand.setDockerComposeCommand(appConfig)

assert.Equal(t, "docker compose", appConfig.UserConfig.CommandTemplates.DockerCompose)
}