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

Commit f55823b

Browse files
committed
Make Moby command detection (based on help output) more robust. It seems some tabs have been replaced by spaces in CLI 20.10. Covered with e2e test TestUnsupportedCommand.
We need to install docker CLI ourselves in Github actions nodes. Signed-off-by: Guillaume Tardif <[email protected]>
1 parent a87c583 commit f55823b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

cli/mobycli/exec.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"os"
2323
"os/exec"
2424
"os/signal"
25-
"strings"
25+
"regexp"
2626

2727
"github.com/spf13/cobra"
2828

@@ -112,9 +112,7 @@ func IsDefaultContextCommand(dockerCommand string) bool {
112112
if e != nil {
113113
fmt.Println(e)
114114
}
115-
output := string(b)
116-
contains := strings.Contains(output, "Usage:\tdocker "+dockerCommand)
117-
return contains
115+
return regexp.MustCompile("Usage:\\s*docker\\s*" + dockerCommand).Match(b)
118116
}
119117

120118
// ExecSilent executes a command and do redirect output to stdOut, return output

0 commit comments

Comments
 (0)