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

Commit d218c07

Browse files
authored
Merge pull request #121 from gtardif/docker-classic
delegate Moby to docker-classic binary, link docker-classic in e2e tests
2 parents c1875a2 + 2610b98 commit d218c07

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ cache-clear: ## Clear the builder cache
6464
lint: ## run linter(s)
6565
docker run --rm -t -v $(PWD):/app -w /app golangci/golangci-lint:v1.27-alpine golangci-lint run --timeout 10m0s ./...
6666

67+
classic-link: ## create docker-classic symlink if does not already exist
68+
ln -s /usr/local/bin/docker-classic /Applications/Docker.app/Contents/Resources/bin/docker
69+
6770
help: ## Show help
6871
@echo Please specify a build target. The choices are:
6972
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7073

7174
FORCE:
7275

73-
.PHONY: all protos cli e2e-local cross test cache-clear lint help
76+
.PHONY: all protos cli e2e-local cross test cache-clear lint help classic-link

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ If you don't have or want to use Docker for building you need to make sure you h
1616

1717
And then you can call the same make targets but you need to pass it the `builder.Makefile` (`make -f builder.Makefile`).
1818

19+
The new CLI delegates to the classic docker for default contexts ; delegation is done to `docker-classic`.
20+
* `make classic-link` will create a `docker-classic` link in `/usr/local/bin` if you don't already have it from Docker Desktop
21+
1922
## Building the project
2023

2124
```bash

cli/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func execMoby(ctx context.Context) {
180180
// Only run original docker command if the current context is not
181181
// ours.
182182
if err != nil {
183-
cmd := exec.Command("docker", os.Args[1:]...)
183+
cmd := exec.Command("docker-classic", os.Args[1:]...)
184184
cmd.Stdin = os.Stdin
185185
cmd.Stdout = os.Stdout
186186
cmd.Stderr = os.Stderr

tests/framework/helper.go

+18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package framework
22

33
import (
4+
"fmt"
45
"log"
6+
"os"
57
"strings"
68

79
"github.com/robpike/filter"
@@ -36,4 +38,20 @@ func gomegaFailHandler(message string, callerSkip ...int) {
3638
//SetupTest Init gomega fail handler
3739
func SetupTest() {
3840
gomega.RegisterFailHandler(gomegaFailHandler)
41+
42+
linkClassicDocker()
43+
}
44+
45+
func linkClassicDocker() {
46+
dockerOriginal := strings.TrimSuffix(NewCommand("which", "docker").ExecOrDie(), "\n")
47+
_, err := NewCommand("rm", "-r", "./bin/tests").Exec()
48+
if err == nil {
49+
fmt.Println("Removing existing /bin/tests folder before running tests")
50+
}
51+
_, err = NewCommand("mkdir", "-p", "./bin/tests").Exec()
52+
gomega.Expect(err).To(gomega.BeNil())
53+
NewCommand("ln", "-s", dockerOriginal, "./bin/tests/docker-classic").ExecOrDie()
54+
newPath := "./bin/tests:" + os.Getenv("PATH")
55+
err = os.Setenv("PATH", newPath)
56+
gomega.Expect(err).To(gomega.BeNil())
3957
}

0 commit comments

Comments
 (0)