mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-22 07:11:01 +00:00
Merge c02e5e4cb4 into 7e7aadc207
This commit is contained in:
commit
bdb93025dc
2 changed files with 22 additions and 1 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue