Merge pull request #121 from gtardif/docker-classic

delegate Moby to docker-classic binary, link docker-classic in e2e tests
This commit is contained in:
Guillaume Tardif 2020-05-20 14:28:35 +02:00 committed by GitHub
commit d218c0745e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 2 deletions

View File

@ -64,10 +64,13 @@ cache-clear: ## Clear the builder cache
lint: ## run linter(s)
docker run --rm -t -v $(PWD):/app -w /app golangci/golangci-lint:v1.27-alpine golangci-lint run --timeout 10m0s ./...
classic-link: ## create docker-classic symlink if does not already exist
ln -s /usr/local/bin/docker-classic /Applications/Docker.app/Contents/Resources/bin/docker
help: ## Show help
@echo Please specify a build target. The choices are:
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
FORCE:
.PHONY: all protos cli e2e-local cross test cache-clear lint help
.PHONY: all protos cli e2e-local cross test cache-clear lint help classic-link

View File

@ -16,6 +16,9 @@ If you don't have or want to use Docker for building you need to make sure you h
And then you can call the same make targets but you need to pass it the `builder.Makefile` (`make -f builder.Makefile`).
The new CLI delegates to the classic docker for default contexts ; delegation is done to `docker-classic`.
* `make classic-link` will create a `docker-classic` link in `/usr/local/bin` if you don't already have it from Docker Desktop
## Building the project
```bash

View File

@ -180,7 +180,7 @@ func execMoby(ctx context.Context) {
// Only run original docker command if the current context is not
// ours.
if err != nil {
cmd := exec.Command("docker", os.Args[1:]...)
cmd := exec.Command("docker-classic", os.Args[1:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

View File

@ -1,7 +1,9 @@
package framework
import (
"fmt"
"log"
"os"
"strings"
"github.com/robpike/filter"
@ -36,4 +38,20 @@ func gomegaFailHandler(message string, callerSkip ...int) {
//SetupTest Init gomega fail handler
func SetupTest() {
gomega.RegisterFailHandler(gomegaFailHandler)
linkClassicDocker()
}
func linkClassicDocker() {
dockerOriginal := strings.TrimSuffix(NewCommand("which", "docker").ExecOrDie(), "\n")
_, err := NewCommand("rm", "-r", "./bin/tests").Exec()
if err == nil {
fmt.Println("Removing existing /bin/tests folder before running tests")
}
_, err = NewCommand("mkdir", "-p", "./bin/tests").Exec()
gomega.Expect(err).To(gomega.BeNil())
NewCommand("ln", "-s", dockerOriginal, "./bin/tests/docker-classic").ExecOrDie()
newPath := "./bin/tests:" + os.Getenv("PATH")
err = os.Setenv("PATH", newPath)
gomega.Expect(err).To(gomega.BeNil())
}