This commit is contained in:
Puneet Dixit 2026-06-04 08:40:43 +05:30 committed by GitHub
commit bdb93025dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -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"

View file

@ -2,6 +2,7 @@ package commands
import (
"os"
"os/exec"
"testing"
"github.com/docker/docker/client"
@ -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)
}