From 5827fd03c8bfb78ceaf78edfed16e106309bce27 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 18 Mar 2019 13:07:22 +0100 Subject: [PATCH 01/28] CircleCI: Increase no-output timeout to 15 minutes for vendoring Vendoring can take some time, depending on network-speed, so reduce flakiness by increasing the default timeout, to prevent: make[1]: Entering directory '/go/src/github.com/docker/cli' rm -rf vendor bash -c 'vndr |& grep -v -i clone' 2019/03/18 11:38:26 Collecting initial packages Too long with no output (exceeded 10m0s) Signed-off-by: Sebastiaan van Stijn (cherry picked from commit dba90e4999ba4e87d590e6aa2c562c669e587c3a) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 90fa621791304c0ec4676492c56a29ec52d8eb28 Component: cli --- components/cli/circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/components/cli/circle.yml b/components/cli/circle.yml index 3b4d9259e9..f2e51a9195 100644 --- a/components/cli/circle.yml +++ b/components/cli/circle.yml @@ -87,6 +87,7 @@ jobs: docker build -f dockerfiles/Dockerfile.dev --tag cli-builder-with-git:$CIRCLE_BUILD_NUM . docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \ make ci-validate + no_output_timeout: 15m shellcheck: working_directory: /work docker: [{image: 'docker:18.03-git'}] From ff6fb95074dc9ec487076c34530c357fc076aa8b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 9 Oct 2018 23:36:04 -0700 Subject: [PATCH 02/28] cli/registry: fix a Debugf statement Fix this warning from go-1.11 > cli/registry/client/fetcher.go:234: Debugf format %s has arg > repoEndpoint of wrong type client.repositoryEndpoint Signed-off-by: Kir Kolyshkin (cherry picked from commit 51848bf3bb3c6cad43ead02ef0660e47e741d2d5) Signed-off-by: Sebastiaan van Stijn Upstream-commit: a13ec91543dc27a2230c9d04e007ba885c95e94a Component: cli --- components/cli/cli/registry/client/fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/cli/cli/registry/client/fetcher.go b/components/cli/cli/registry/client/fetcher.go index c4c267cfa7..e3d6cd6069 100644 --- a/components/cli/cli/registry/client/fetcher.go +++ b/components/cli/cli/registry/client/fetcher.go @@ -231,7 +231,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named, repoEndpoint := repositoryEndpoint{endpoint: endpoint, info: repoInfo} repo, err := c.getRepositoryForReference(ctx, namedRef, repoEndpoint) if err != nil { - logrus.Debugf("error with repo endpoint %s: %s", repoEndpoint, err) + logrus.Debugf("error %s with repo endpoint %+v", err, repoEndpoint) if _, ok := err.(ErrHTTPProto); ok { continue } From 38a4a307e2c630205b5bd04508371fce71cdf290 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 11 Oct 2018 01:15:33 -0700 Subject: [PATCH 03/28] scripts/build/osx: set CXX, too In case go build will see a need to call C++ (rather than C) compiler, CXX env var need to be properly set (to osxcross wrapper). Signed-off-by: Kir Kolyshkin (cherry picked from commit ee461303f9e74937a0a598650249f4331b1dd498) Signed-off-by: Sebastiaan van Stijn Upstream-commit: f9a42a40244c18659d2c20cc6301b79290bbd9af Component: cli --- components/cli/scripts/build/osx | 1 + 1 file changed, 1 insertion(+) diff --git a/components/cli/scripts/build/osx b/components/cli/scripts/build/osx index a5e7d9432c..a075ede412 100755 --- a/components/cli/scripts/build/osx +++ b/components/cli/scripts/build/osx @@ -11,6 +11,7 @@ export CGO_ENABLED=1 export GOOS=darwin export GOARCH=amd64 export CC=o64-clang +export CXX=o64-clang++ export LDFLAGS="$LDFLAGS -linkmode external -s" export LDFLAGS_STATIC_DOCKER='-extld='${CC} From d81b1cb7eb435fe4ec8236d27dc7b6a1c2de5d5f Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 9 Oct 2018 23:46:48 -0700 Subject: [PATCH 04/28] Bump Go to 1.11.1 Release notes: https://golang.org/doc/devel/release.html#go1.11 Signed-off-by: Kir Kolyshkin (cherry picked from commit 941273918665ddbf2ba062c0889e443882a90825) Signed-off-by: Sebastiaan van Stijn Upstream-commit: dbd66addb97d336a562aa0968840435fb4eb4787 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index 05a4914062..e19aa0b6e3 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.10.8 + GOVERSION: 1.11.1 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index 20f8012a4b..8b97ef731b 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.10.8-alpine +FROM golang:1.11.1-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 240ff2bfb5..0f54c9f64a 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.10.8@sha256:a93210f55a8137b4aa4b9f033ac7a80b66ab6337e98e7afb62abe93b4ad73cad +FROM dockercore/golang-cross:1.11.1@sha256:57ce59bec5445d27cc00f9e27fc171bea44eed7a9890df6eea6540f214300a01 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index c8ce67ab06..3134680585 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,5 +1,5 @@ -FROM golang:1.10.8-alpine +FROM golang:1.11.1-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index b8428abb41..e884334128 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.10.8 +ARG GO_VERSION=1.11.1 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 2a5354f432..10be9db265 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.10.8-alpine +FROM golang:1.11.1-alpine RUN apk add -U git From 19a658ee39023c3b58d1d593a652a160b9923c32 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 9 Oct 2018 23:37:35 -0700 Subject: [PATCH 05/28] gofmt with go-1.11 gofmt/goimports changed some heuristics in 1.11 and the code is now formatted slightly differently. No functional change, just whitespace. Signed-off-by: Kir Kolyshkin (cherry picked from commit 906c2d161a6ad4ccd3c6d16134385d619d1f7cc9) Signed-off-by: Sebastiaan van Stijn Upstream-commit: edbc0e0613f5196913281cb4cb45f479276c242c Component: cli --- .../cli/command/stack/swarm/deploy_test.go | 4 ++-- components/cli/opts/hosts_test.go | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/cli/cli/command/stack/swarm/deploy_test.go b/components/cli/cli/command/stack/swarm/deploy_test.go index b1df60dcba..970d790bf2 100644 --- a/components/cli/cli/command/stack/swarm/deploy_test.go +++ b/components/cli/cli/command/stack/swarm/deploy_test.go @@ -71,14 +71,14 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) { }{ // Image not changed { - image: "foobar:1.2.3", + image: "foobar:1.2.3", expectedQueryRegistry: false, expectedImage: "foobar:1.2.3@sha256:deadbeef", expectedForceUpdate: 123, }, // Image changed { - image: "foobar:1.2.4", + image: "foobar:1.2.4", expectedQueryRegistry: true, expectedImage: "foobar:1.2.4", expectedForceUpdate: 123, diff --git a/components/cli/opts/hosts_test.go b/components/cli/opts/hosts_test.go index 8aada6a953..a2b03f46d9 100644 --- a/components/cli/opts/hosts_test.go +++ b/components/cli/opts/hosts_test.go @@ -69,18 +69,18 @@ func TestParseDockerDaemonHost(t *testing.T) { "[::1]:5555/path": "tcp://[::1]:5555/path", "[0:0:0:0:0:0:0:1]:": "tcp://[0:0:0:0:0:0:0:1]:2375", "[0:0:0:0:0:0:0:1]:5555/path": "tcp://[0:0:0:0:0:0:0:1]:5555/path", - ":6666": fmt.Sprintf("tcp://%s:6666", DefaultHTTPHost), - ":6666/path": fmt.Sprintf("tcp://%s:6666/path", DefaultHTTPHost), - "tcp://": DefaultTCPHost, - "tcp://:7777": fmt.Sprintf("tcp://%s:7777", DefaultHTTPHost), - "tcp://:7777/path": fmt.Sprintf("tcp://%s:7777/path", DefaultHTTPHost), - "unix:///run/docker.sock": "unix:///run/docker.sock", - "unix://": "unix://" + DefaultUnixSocket, - "fd://": "fd://", - "fd://something": "fd://something", - "localhost:": "tcp://localhost:2375", - "localhost:5555": "tcp://localhost:5555", - "localhost:5555/path": "tcp://localhost:5555/path", + ":6666": fmt.Sprintf("tcp://%s:6666", DefaultHTTPHost), + ":6666/path": fmt.Sprintf("tcp://%s:6666/path", DefaultHTTPHost), + "tcp://": DefaultTCPHost, + "tcp://:7777": fmt.Sprintf("tcp://%s:7777", DefaultHTTPHost), + "tcp://:7777/path": fmt.Sprintf("tcp://%s:7777/path", DefaultHTTPHost), + "unix:///run/docker.sock": "unix:///run/docker.sock", + "unix://": "unix://" + DefaultUnixSocket, + "fd://": "fd://", + "fd://something": "fd://something", + "localhost:": "tcp://localhost:2375", + "localhost:5555": "tcp://localhost:5555", + "localhost:5555/path": "tcp://localhost:5555/path", } for invalidAddr, expectedError := range invalids { if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError { From 1b195edabfdb642b2187b487ac56587475a01d88 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Nov 2018 01:06:10 +0100 Subject: [PATCH 06/28] Do not patch Dockerfiles in CI When building the Dockerfiles for development, those images are mainly used to create a reproducible build-environment. The source code is bind-mounted into the image at runtime; there is no need to create an image with the actual source code, and copying the source code into the image would lead to a new image being created for each code-change (possibly leading up to many "dangling" images for previous code-changes). However, when building (and using) the development images in CI, bind-mounting is not an option, because the daemon is running remotely. To make this work, the circle-ci script patched the Dockerfiles when CI is run; adding a `COPY` to the respective Dockerfiles. Patching Dockerfiles is not really a "best practice" and, even though the source code does not and up in the image, the source would still be _sent_ to the daemon for each build (unless BuildKit is used). This patch updates the makefiles, circle-ci script, and Dockerfiles; - When building the Dockerfiles locally, pipe the Dockerfile through stdin. Doing so, prevents the build-context from being sent to the daemon. This speeds up the build, and doesn't fill up the Docker "temp" directory with content that's not used - Now that no content is sent, add the COPY instructions to the Dockerfiles, and remove the code in the circle-ci script to "live patch" the Dockerfiles. Before this patch is applied (with cache): ``` $ time make -f docker.Makefile build_shell_validate_image docker build -t docker-cli-shell-validate -f ./dockerfiles/Dockerfile.shellcheck . Sending build context to Docker daemon 41MB Step 1/2 : FROM debian:stretch-slim ... Successfully built 81e14e8ad856 Successfully tagged docker-cli-shell-validate:latest 2.75 real 0.45 user 0.56 sys ``` After this patch is applied (with cache):: ``` $ time make -f docker.Makefile build_shell_validate_image cat ./dockerfiles/Dockerfile.shellcheck | docker build -t docker-cli-shell-validate - Sending build context to Docker daemon 2.048kB Step 1/2 : FROM debian:stretch-slim ... Successfully built 81e14e8ad856 Successfully tagged docker-cli-shell-validate:latest 0.33 real 0.07 user 0.08 sys ``` Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 166856ab1b1681de107b5e064ea89ea4b27154fd) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 206ea57da8deb66eab74d92d9103a4d78869b1f8 Component: cli --- components/cli/dockerfiles/Dockerfile.dev | 1 - 1 file changed, 1 deletion(-) diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index 3134680585..69de827da8 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,3 @@ - FROM golang:1.11.1-alpine RUN apk add -U git make bash coreutils ca-certificates curl From 93eb5300f808c295720b17e666fce00c002ceb72 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 10 Dec 2018 13:17:14 +0000 Subject: [PATCH 07/28] build: Add a `fmt` target which runs `gofmt` on all files. Signed-off-by: Ian Campbell (cherry picked from commit 7c8ee78eaf69106beac78d9bf69e5034cfff8f9d) Signed-off-by: Sebastiaan van Stijn Upstream-commit: db7875928c5ee571ce8d9d162012937c24e9602b Component: cli --- components/cli/Makefile | 4 ++++ components/cli/docker.Makefile | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/cli/Makefile b/components/cli/Makefile index 51b168dcaa..5e4fad15b4 100644 --- a/components/cli/Makefile +++ b/components/cli/Makefile @@ -21,6 +21,10 @@ test: test-unit ## run tests test-coverage: ## run test coverage ./scripts/test/unit-with-coverage $(shell go list ./... | grep -vE '/vendor/|/e2e/') +.PHONY: fmt +fmt: + go list -f {{.Dir}} ./... | xargs gofmt -w -s -d + .PHONY: lint lint: ## run all the lint tools gometalinter --config gometalinter.json ./... diff --git a/components/cli/docker.Makefile b/components/cli/docker.Makefile index 628e989fb0..d57f7868e6 100644 --- a/components/cli/docker.Makefile +++ b/components/cli/docker.Makefile @@ -86,6 +86,10 @@ shell: dev ## alias for dev lint: build_linter_image ## run linters docker run -ti $(ENVVARS) $(MOUNTS) $(LINTER_IMAGE_NAME) +.PHONY: fmt +fmt: + docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make fmt + .PHONY: vendor vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor From 71c0f34060a25a9d98106156ae37ddaa47f04237 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 10 Dec 2018 11:30:52 +0000 Subject: [PATCH 08/28] Use a go build cache to speed up builds. With a docker build cache already primed with the build image I am seeing `time make build -f docker.Makefile DOCKER_BUILDKIT=1 GO_BUILD_CACHE=n` takes more than 1 minute. By contrast `time make build -f docker.Makefile DOCKER_BUILDKIT=1 GO_BUILD_CACHE=y` takes less than 10s with a hot cache irrespective of whether the source tree has changed Signed-off-by: Ian Campbell (cherry picked from commit d5de8358f0192551970965d8fabb9a967f0f51f1) Signed-off-by: Sebastiaan van Stijn Upstream-commit: c1c4b46f296adedfd530b7fc0e1662bbd5eac3e0 Component: cli --- components/cli/docker.Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/cli/docker.Makefile b/components/cli/docker.Makefile index d57f7868e6..5b266f5275 100644 --- a/components/cli/docker.Makefile +++ b/components/cli/docker.Makefile @@ -10,7 +10,12 @@ LINTER_IMAGE_NAME = docker-cli-lint$(IMAGE_TAG) CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG) VALIDATE_IMAGE_NAME = docker-cli-shell-validate$(IMAGE_TAG) E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG) +GO_BUILD_CACHE ?= y MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli +CACHE_VOLUME_NAME := docker-cli-dev-cache +ifeq ($(GO_BUILD_CACHE),y) +MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build" +endif VERSION = $(shell cat VERSION) ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM @@ -54,6 +59,7 @@ build: binary ## alias for binary .PHONY: clean clean: build_docker_image ## clean build artifacts docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean + docker volume rm -f $(CACHE_VOLUME_NAME) .PHONY: test-unit test-unit: build_docker_image # run unit tests (using go test) From f03dd88c90def232ad0a8a7925e6a3db89e628ca Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 30 Nov 2018 22:04:28 +0100 Subject: [PATCH 09/28] Bump Go to 1.11.2 go1.11.2 (released 2018/11/02) includes fixes to the compiler, linker, documentation, go command, and the database/sql and go/types packages. See the milestone on the issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.2 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 58f0bfcf51536312d896738ec6c6d1ec73bc2caf) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 534c774fab97a7da1884fbe04283d136456b1efa Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index e19aa0b6e3..fe16b3b438 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.1 + GOVERSION: 1.11.2 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index 8b97ef731b..2f7601904b 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.1-alpine +FROM golang:1.11.2-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 0f54c9f64a..9463a50f04 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.1@sha256:57ce59bec5445d27cc00f9e27fc171bea44eed7a9890df6eea6540f214300a01 +FROM dockercore/golang-cross:1.11.2@sha256:7e8945e30dae5d6455a3e75e5091e642f79110301a86d08f8c93991518e930b3 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index 69de827da8..f060dc260f 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.1-alpine +FROM golang:1.11.2-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index e884334128..722761055f 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.1 +ARG GO_VERSION=1.11.2 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 10be9db265..e0c8df3f39 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.1-alpine +FROM golang:1.11.2-alpine RUN apk add -U git From 73bc01b037c708165b33dae9a8b1a465a2ca9f99 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 19 Dec 2018 12:55:59 +0100 Subject: [PATCH 10/28] Bump Golang 1.11.4 (includes fix for CVE-2018-16875) go1.11.4 (released 2018/12/14) includes fixes to cgo, the compiler, linker, runtime, documentation, go command, and the net/http and go/types packages. It includes a fix to a bug introduced in Go 1.11.3 that broke go get for import path patterns containing "...". See the Go 1.11.4 milestone for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.4+label%3ACherryPickApproved go1.11.3 (released 2018/12/14) - crypto/x509: CPU denial of service in chain validation golang/go#29233 - cmd/go: directory traversal in "go get" via curly braces in import paths golang/go#29231 - cmd/go: remote command execution during "go get -u" golang/go#29230 See the Go 1.11.3 milestone on the issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.3 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit deaf6e13ab067e6794d20ec980b4ae216b65d07c) Signed-off-by: Sebastiaan van Stijn Upstream-commit: a378a009541cf2377e6410c28183d7710ad37ed6 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index fe16b3b438..b5a8da994f 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.2 + GOVERSION: 1.11.4 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index 2f7601904b..a8a1e4b845 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.2-alpine +FROM golang:1.11.4-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 9463a50f04..6eec5dc5e3 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.2@sha256:7e8945e30dae5d6455a3e75e5091e642f79110301a86d08f8c93991518e930b3 +FROM dockercore/golang-cross:1.11.4@sha256:9e5f0013a7dbc49b6726267577803202b403be1a560c0c03c4e215d7e2476b1b ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index f060dc260f..33e8d48042 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.2-alpine +FROM golang:1.11.4-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 722761055f..000c38561f 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.2 +ARG GO_VERSION=1.11.4 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index e0c8df3f39..46bc7db79c 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.2-alpine +FROM golang:1.11.4-alpine RUN apk add -U git From 7bdc68cd32ad858c189aa12be8f364345577fd8c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 24 Jan 2019 02:50:10 +0100 Subject: [PATCH 11/28] Bump Golang 1.11.5 (CVE-2019-6486) See the milestone for details; https://github.com/golang/go/issues?q=milestone%3AGo1.11.5+label%3ACherryPickApproved Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 0e9d1d3b071f09f96d800b55aa3c2fb715dc179b) Signed-off-by: Sebastiaan van Stijn Upstream-commit: dcc8f14cadf0dae4cc59c36e695507d63e8492d3 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index b5a8da994f..6b99457884 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.4 + GOVERSION: 1.11.5 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index a8a1e4b845..417916db70 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.4-alpine +FROM golang:1.11.5-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 6eec5dc5e3..970049d0b8 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.4@sha256:9e5f0013a7dbc49b6726267577803202b403be1a560c0c03c4e215d7e2476b1b +FROM dockercore/golang-cross:1.11.5@sha256:17a7e0f158521c50316a0d0c1ab1f6a75350b4d82e7ef03c98bcfbdf04feb4f3 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index 33e8d48042..af6da4b156 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.4-alpine +FROM golang:1.11.5-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 000c38561f..68368c0970 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.4 +ARG GO_VERSION=1.11.5 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 46bc7db79c..10c2fa2c3d 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.4-alpine +FROM golang:1.11.5-alpine RUN apk add -U git From 4e4eee19c9162848c999346012b820b728e623d7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 17 Mar 2019 16:01:58 +0100 Subject: [PATCH 12/28] Bump Golang 1.11.6 go1.11.6 (released 2019/03/14) includes fixes to cgo, the compiler, linker, runtime, go command, and the crypto/x509, encoding/json, net, and net/url packages. See the Go 1.11.6 milestone on our issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.6 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 1500105975b29beb9393c79fe5652e901cbd5966) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 9959062d9a0b8c76b9172869f11bd1e1cc6c95d2 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index 6b99457884..c1fd4ce790 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.5 + GOVERSION: 1.11.6 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index 417916db70..f2762562b6 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.5-alpine +FROM golang:1.11.6-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 970049d0b8..96a22b3cfa 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.5@sha256:17a7e0f158521c50316a0d0c1ab1f6a75350b4d82e7ef03c98bcfbdf04feb4f3 +FROM dockercore/golang-cross:1.11.6@sha256:fc07992ec18c0695fe748460cb3d599178d138ba2c762098283bc49334d7b072 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index af6da4b156..eb487c88e5 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.5-alpine +FROM golang:1.11.6-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 68368c0970..53da6a74c1 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.5 +ARG GO_VERSION=1.11.6 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 10c2fa2c3d..b99cd690bc 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.5-alpine +FROM golang:1.11.6-alpine RUN apk add -U git From 26819ff0fff356dd451d121773825d6e00e9b3cf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 8 Apr 2019 00:53:03 +0200 Subject: [PATCH 13/28] [18.09] Bump Golang 1.11.7 go1.11.7 (released 2019/04/05) includes fixes to the runtime and the net packages. See the Go 1.11.7 milestone on our issue tracker for details. https://github.com/golang/go/issues?q=milestone%3AGo1.11.7 Full diff: https://github.com/golang/go/compare/go1.11.6...go1.11.7 Signed-off-by: Sebastiaan van Stijn Upstream-commit: 85a73e440e1209104144cf8873427f0cb43b3334 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index c1fd4ce790..076020f617 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.6 + GOVERSION: 1.11.7 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index f2762562b6..fe2ea9a46c 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.6-alpine +FROM golang:1.11.7-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 96a22b3cfa..6cee5e2e5b 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.6@sha256:fc07992ec18c0695fe748460cb3d599178d138ba2c762098283bc49334d7b072 +FROM dockercore/golang-cross:1.11.7@sha256:8870db6720422be83bbba4509e7f20c62531aafccc9eb955ac9e8e554df3d7e9 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index eb487c88e5..f4f3112bf9 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.6-alpine +FROM golang:1.11.7-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 53da6a74c1..18d12111ab 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.6 +ARG GO_VERSION=1.11.7 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index b99cd690bc..64ee606a80 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.6-alpine +FROM golang:1.11.7-alpine RUN apk add -U git From 0e0ce7c2e999e9c21d6c3f851f26aedd9fc10a72 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 14 Apr 2019 02:24:45 +0200 Subject: [PATCH 14/28] Bump Golang 1.11.9 go1.11.9 (released 2019/04/11) fixes an issue where using the prebuilt binary releases on older versions of GNU/Linux led to failures when linking programs that used cgo. Only Linux users who hit this issue need to update. See golang/go#31293 for details Full diff: https://github.com/golang/go/compare/go1.11.8...go1.11.9 Signed-off-by: Sebastiaan van Stijn Upstream-commit: 1b3ed845356771307f8e6cc79923d94fa1155b17 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index 076020f617..9585b0b156 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.7 + GOVERSION: 1.11.9 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index fe2ea9a46c..e987b9966c 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.7-alpine +FROM golang:1.11.9-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 6cee5e2e5b..96ac7993c9 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.7@sha256:8870db6720422be83bbba4509e7f20c62531aafccc9eb955ac9e8e554df3d7e9 +FROM dockercore/golang-cross:1.11.9 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index f4f3112bf9..0f36b1e281 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.7-alpine +FROM golang:1.11.9-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 18d12111ab..118c7f73c5 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.7 +ARG GO_VERSION=1.11.9 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 64ee606a80..2407097f8d 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.7-alpine +FROM golang:1.11.9-alpine RUN apk add -U git From 692e7c8cb9b67946fa71fc30050c7b314df050b1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 20 May 2019 19:31:39 +0200 Subject: [PATCH 15/28] Bump Golang 1.11.10 go1.11.10 (released 2019/05/06) includes fixes to the runtime and the linker. See the Go 1.11.10 milestone on our issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.10 Full diff: https://github.com/golang/go/compare/go1.11.9...go1.11.10 Signed-off-by: Sebastiaan van Stijn Upstream-commit: b8fe5cea3d947392970722e8c7183e1c457b9423 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index 9585b0b156..8e5c832c1a 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.9 + GOVERSION: 1.11.10 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index e987b9966c..c5bac52ece 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.9-alpine +FROM golang:1.11.10-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 96ac7993c9..40370a601a 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.9 +FROM dockercore/golang-cross:1.11.10 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index 0f36b1e281..195b7d78f8 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.9-alpine +FROM golang:1.11.10-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 118c7f73c5..30266a8218 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.9 +ARG GO_VERSION=1.11.10 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index 2407097f8d..c0ba6177c3 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.9-alpine +FROM golang:1.11.10-alpine RUN apk add -U git From dd8eddb4df6a5cabd89ca124d2ba2ef8cc8e6b27 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 14 Jun 2019 12:55:09 +0200 Subject: [PATCH 16/28] Bump golang 1.11.11 go1.11.11 (released 2019/06/11) includes a fix to the crypto/x509 package. See the Go 1.11.11 milestone on the issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.11.11 full diff: https://github.com/golang/go/compare/go1.11.10...go1.11.11 Signed-off-by: Sebastiaan van Stijn Upstream-commit: 9bd840b2347b30376c89b385a8d3f0e1a8e753a4 Component: cli --- components/cli/appveyor.yml | 2 +- components/cli/dockerfiles/Dockerfile.binary-native | 2 +- components/cli/dockerfiles/Dockerfile.cross | 2 +- components/cli/dockerfiles/Dockerfile.dev | 2 +- components/cli/dockerfiles/Dockerfile.e2e | 2 +- components/cli/dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/cli/appveyor.yml b/components/cli/appveyor.yml index 8e5c832c1a..99157df193 100644 --- a/components/cli/appveyor.yml +++ b/components/cli/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.11.10 + GOVERSION: 1.11.11 DEPVERSION: v0.4.1 install: diff --git a/components/cli/dockerfiles/Dockerfile.binary-native b/components/cli/dockerfiles/Dockerfile.binary-native index c5bac52ece..b1f3ae82c2 100644 --- a/components/cli/dockerfiles/Dockerfile.binary-native +++ b/components/cli/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -FROM golang:1.11.10-alpine +FROM golang:1.11.11-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/components/cli/dockerfiles/Dockerfile.cross b/components/cli/dockerfiles/Dockerfile.cross index 40370a601a..bcca51857a 100644 --- a/components/cli/dockerfiles/Dockerfile.cross +++ b/components/cli/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -FROM dockercore/golang-cross:1.11.10 +FROM dockercore/golang-cross:1.11.11 ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/components/cli/dockerfiles/Dockerfile.dev b/components/cli/dockerfiles/Dockerfile.dev index 195b7d78f8..d7731fb2cb 100644 --- a/components/cli/dockerfiles/Dockerfile.dev +++ b/components/cli/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.11.10-alpine +FROM golang:1.11.11-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/components/cli/dockerfiles/Dockerfile.e2e b/components/cli/dockerfiles/Dockerfile.e2e index 30266a8218..e721b971a9 100644 --- a/components/cli/dockerfiles/Dockerfile.e2e +++ b/components/cli/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.11.10 +ARG GO_VERSION=1.11.11 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/components/cli/dockerfiles/Dockerfile.lint b/components/cli/dockerfiles/Dockerfile.lint index c0ba6177c3..7f0ecb8dd9 100644 --- a/components/cli/dockerfiles/Dockerfile.lint +++ b/components/cli/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -FROM golang:1.11.10-alpine +FROM golang:1.11.11-alpine RUN apk add -U git From f7c2b93be6673f92b7fc8fffd5f44175ee96e402 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 20 Mar 2019 18:52:19 +0100 Subject: [PATCH 17/28] bump docker/licensing to 9781369abdb5281cdc07a2a446c6df01347ec793 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 5ac07c795ffca586a891b57b1a05a31ff0b3178c) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 667aef15b02e17d7245fa6e198076109618afa1d Component: cli --- components/cli/vendor.conf | 4 +- .../docker/licensing/lib/go-auth/jwt/jwt.go | 4 +- .../docker/licensing/model/subscriptions.go | 16 +- .../github.com/docker/licensing/storage.go | 12 +- .../docker/licensing/types/types.go | 17 + .../cli/vendor/github.com/google/uuid/LICENSE | 27 ++ .../vendor/github.com/google/uuid/README.md | 19 + .../cli/vendor/github.com/google/uuid/dce.go | 80 ++++ .../cli/vendor/github.com/google/uuid/doc.go | 12 + .../cli/vendor/github.com/google/uuid/hash.go | 53 +++ .../vendor/github.com/google/uuid/marshal.go | 37 ++ .../cli/vendor/github.com/google/uuid/node.go | 90 ++++ .../vendor/github.com/google/uuid/node_js.go | 12 + .../vendor/github.com/google/uuid/node_net.go | 33 ++ .../cli/vendor/github.com/google/uuid/sql.go | 59 +++ .../cli/vendor/github.com/google/uuid/time.go | 123 +++++ .../cli/vendor/github.com/google/uuid/util.go | 43 ++ .../cli/vendor/github.com/google/uuid/uuid.go | 245 ++++++++++ .../vendor/github.com/google/uuid/version1.go | 44 ++ .../vendor/github.com/google/uuid/version4.go | 38 ++ .../vendor/github.com/satori/go.uuid/LICENSE | 20 - .../github.com/satori/go.uuid/README.md | 66 --- .../vendor/github.com/satori/go.uuid/uuid.go | 435 ------------------ 23 files changed, 951 insertions(+), 538 deletions(-) create mode 100644 components/cli/vendor/github.com/docker/licensing/types/types.go create mode 100644 components/cli/vendor/github.com/google/uuid/LICENSE create mode 100644 components/cli/vendor/github.com/google/uuid/README.md create mode 100644 components/cli/vendor/github.com/google/uuid/dce.go create mode 100644 components/cli/vendor/github.com/google/uuid/doc.go create mode 100644 components/cli/vendor/github.com/google/uuid/hash.go create mode 100644 components/cli/vendor/github.com/google/uuid/marshal.go create mode 100644 components/cli/vendor/github.com/google/uuid/node.go create mode 100644 components/cli/vendor/github.com/google/uuid/node_js.go create mode 100644 components/cli/vendor/github.com/google/uuid/node_net.go create mode 100644 components/cli/vendor/github.com/google/uuid/sql.go create mode 100644 components/cli/vendor/github.com/google/uuid/time.go create mode 100644 components/cli/vendor/github.com/google/uuid/util.go create mode 100644 components/cli/vendor/github.com/google/uuid/uuid.go create mode 100644 components/cli/vendor/github.com/google/uuid/version1.go create mode 100644 components/cli/vendor/github.com/google/uuid/version4.go delete mode 100644 components/cli/vendor/github.com/satori/go.uuid/LICENSE delete mode 100644 components/cli/vendor/github.com/satori/go.uuid/README.md delete mode 100644 components/cli/vendor/github.com/satori/go.uuid/uuid.go diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 45ba524a6c..5b5f04a675 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -22,7 +22,7 @@ github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a -github.com/docker/licensing 1c117a1720cb413dd6a101d36a6c567b1ccb90fe +github.com/docker/licensing 9781369abdb5281cdc07a2a446c6df01347ec793 github.com/docker/swarmkit cfa742c8abe6f8e922f6e4e920153c408e7d9c3b github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 # v1.0.0 @@ -34,6 +34,7 @@ github.com/google/btree e89373fe6b4a7413d7acd6da1725b83ef713e6e4 github.com/google/go-cmp v0.2.0 github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1 github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 +github.com/google/uuid v1.1.1 github.com/googleapis/gnostic 7c663266750e7d82587642f65e60bc4083f1f84e # v0.2.0 github.com/gorilla/context v1.1.1 github.com/gorilla/mux v1.6.2 @@ -68,7 +69,6 @@ github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 github.com/russross/blackfriday 1d6b8e9301e720b08a8938b8c25c018285885438 -github.com/satori/go.uuid d41af8bb6a7704f00bc3b7cba9355ae6a5a80048 github.com/shurcooL/sanitized_anchor_name 10ef21a441db47d8b13ebcc5fd2310f636973c77 github.com/sirupsen/logrus v1.0.6 github.com/spf13/cobra v0.0.3 diff --git a/components/cli/vendor/github.com/docker/licensing/lib/go-auth/jwt/jwt.go b/components/cli/vendor/github.com/docker/licensing/lib/go-auth/jwt/jwt.go index c696df27db..930afbe7ee 100644 --- a/components/cli/vendor/github.com/docker/licensing/lib/go-auth/jwt/jwt.go +++ b/components/cli/vendor/github.com/docker/licensing/lib/go-auth/jwt/jwt.go @@ -10,7 +10,7 @@ import ( "github.com/dgrijalva/jwt-go" "github.com/docker/licensing/lib/go-auth/identity" - "github.com/satori/go.uuid" + "github.com/google/uuid" ) const ( @@ -100,7 +100,7 @@ func Encode(identity identity.DockerIdentity, options EncodeOptions) (string, er jtiStr := options.Jti if len(jtiStr) == 0 { - jtiStr = "jti-" + uuid.NewV4().String() + jtiStr = "jti-" + uuid.New().String() } token.Claims[jti] = jtiStr diff --git a/components/cli/vendor/github.com/docker/licensing/model/subscriptions.go b/components/cli/vendor/github.com/docker/licensing/model/subscriptions.go index 95dadb8d48..a5ad8d85fb 100644 --- a/components/cli/vendor/github.com/docker/licensing/model/subscriptions.go +++ b/components/cli/vendor/github.com/docker/licensing/model/subscriptions.go @@ -2,11 +2,11 @@ package model import ( "fmt" + "strings" "time" - "strings" - validation "github.com/docker/licensing/lib/go-validation" + "github.com/docker/licensing/types" ) // PricingComponents represents a collection of pricing components @@ -37,20 +37,20 @@ func (s *Subscription) String() string { storeURL := "https://docker.com/licensing" var nameMsg, expirationMsg, statusMsg string - switch s.State { - case "cancelled": + switch types.State(s.State) { + case types.Cancelled: statusMsg = fmt.Sprintf("\tCancelled! You will no longer receive updates. To purchase go to %s", storeURL) expirationMsg = fmt.Sprintf("Expiration date: %s", s.Expires.Format("2006-01-02")) - case "expired": + case types.Expired: statusMsg = fmt.Sprintf("\tExpired! You will no longer receive updates. Please renew at %s", storeURL) expirationMsg = fmt.Sprintf("Expiration date: %s", s.Expires.Format("2006-01-02")) - case "preparing": + case types.Preparing: statusMsg = "\tYour subscription has not yet begun" expirationMsg = fmt.Sprintf("Activation date: %s", s.Start.Format("2006-01-02")) - case "failed": + case types.Failed: statusMsg = "\tOops, this subscription did not get setup properly!" expirationMsg = "" - case "active": + case types.Active: statusMsg = "\tLicense is currently active" expirationMsg = fmt.Sprintf("Expiration date: %s", s.Expires.Format("2006-01-02")) default: diff --git a/components/cli/vendor/github.com/docker/licensing/storage.go b/components/cli/vendor/github.com/docker/licensing/storage.go index 0358fad521..3f8a49d2d4 100644 --- a/components/cli/vendor/github.com/docker/licensing/storage.go +++ b/components/cli/vendor/github.com/docker/licensing/storage.go @@ -11,11 +11,10 @@ import ( "strings" "time" - "github.com/docker/licensing/model" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" + "github.com/docker/licensing/model" ) var ( @@ -88,11 +87,14 @@ func (c *client) LoadLocalLicense(ctx context.Context, clnt WrappedDockerClient) } else { // Load the latest license index var latestVersion int + + // check if node is swarm manager + if !info.Swarm.ControlAvailable { + return nil, ErrWorkerNode + } + latestVersion, err = getLatestNamedConfig(clnt, licenseNamePrefix) if err != nil { - if strings.Contains(err.Error(), "not a swarm manager.") { - return nil, ErrWorkerNode - } return nil, fmt.Errorf("unable to get latest license version: %s", err) } if latestVersion >= 0 { diff --git a/components/cli/vendor/github.com/docker/licensing/types/types.go b/components/cli/vendor/github.com/docker/licensing/types/types.go new file mode 100644 index 0000000000..fbf497021b --- /dev/null +++ b/components/cli/vendor/github.com/docker/licensing/types/types.go @@ -0,0 +1,17 @@ +package types + +// State represents a given subscription's current status +type State string + +const ( + // Active means a subscription is currently in a working, live state + Active State = "active" + // Expired means a subscription's end date is in the past + Expired State = "expired" + // Cancelled means the subscription has been cancelled + Cancelled State = "cancelled" + // Preparing means that the subscription's payment (if any) is being still processed + Preparing State = "preparing" + // Failed means that there was a problem creating the subscription + Failed State = "failed" +) diff --git a/components/cli/vendor/github.com/google/uuid/LICENSE b/components/cli/vendor/github.com/google/uuid/LICENSE new file mode 100644 index 0000000000..5dc68268d9 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009,2014 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/components/cli/vendor/github.com/google/uuid/README.md b/components/cli/vendor/github.com/google/uuid/README.md new file mode 100644 index 0000000000..9d92c11f16 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/README.md @@ -0,0 +1,19 @@ +# uuid ![build status](https://travis-ci.org/google/uuid.svg?branch=master) +The uuid package generates and inspects UUIDs based on +[RFC 4122](http://tools.ietf.org/html/rfc4122) +and DCE 1.1: Authentication and Security Services. + +This package is based on the github.com/pborman/uuid package (previously named +code.google.com/p/go-uuid). It differs from these earlier packages in that +a UUID is a 16 byte array rather than a byte slice. One loss due to this +change is the ability to represent an invalid UUID (vs a NIL UUID). + +###### Install +`go get github.com/google/uuid` + +###### Documentation +[![GoDoc](https://godoc.org/github.com/google/uuid?status.svg)](http://godoc.org/github.com/google/uuid) + +Full `go doc` style documentation for the package can be viewed online without +installing this package by using the GoDoc site here: +http://godoc.org/github.com/google/uuid diff --git a/components/cli/vendor/github.com/google/uuid/dce.go b/components/cli/vendor/github.com/google/uuid/dce.go new file mode 100644 index 0000000000..fa820b9d30 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/dce.go @@ -0,0 +1,80 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "fmt" + "os" +) + +// A Domain represents a Version 2 domain +type Domain byte + +// Domain constants for DCE Security (Version 2) UUIDs. +const ( + Person = Domain(0) + Group = Domain(1) + Org = Domain(2) +) + +// NewDCESecurity returns a DCE Security (Version 2) UUID. +// +// The domain should be one of Person, Group or Org. +// On a POSIX system the id should be the users UID for the Person +// domain and the users GID for the Group. The meaning of id for +// the domain Org or on non-POSIX systems is site defined. +// +// For a given domain/id pair the same token may be returned for up to +// 7 minutes and 10 seconds. +func NewDCESecurity(domain Domain, id uint32) (UUID, error) { + uuid, err := NewUUID() + if err == nil { + uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 + uuid[9] = byte(domain) + binary.BigEndian.PutUint32(uuid[0:], id) + } + return uuid, err +} + +// NewDCEPerson returns a DCE Security (Version 2) UUID in the person +// domain with the id returned by os.Getuid. +// +// NewDCESecurity(Person, uint32(os.Getuid())) +func NewDCEPerson() (UUID, error) { + return NewDCESecurity(Person, uint32(os.Getuid())) +} + +// NewDCEGroup returns a DCE Security (Version 2) UUID in the group +// domain with the id returned by os.Getgid. +// +// NewDCESecurity(Group, uint32(os.Getgid())) +func NewDCEGroup() (UUID, error) { + return NewDCESecurity(Group, uint32(os.Getgid())) +} + +// Domain returns the domain for a Version 2 UUID. Domains are only defined +// for Version 2 UUIDs. +func (uuid UUID) Domain() Domain { + return Domain(uuid[9]) +} + +// ID returns the id for a Version 2 UUID. IDs are only defined for Version 2 +// UUIDs. +func (uuid UUID) ID() uint32 { + return binary.BigEndian.Uint32(uuid[0:4]) +} + +func (d Domain) String() string { + switch d { + case Person: + return "Person" + case Group: + return "Group" + case Org: + return "Org" + } + return fmt.Sprintf("Domain%d", int(d)) +} diff --git a/components/cli/vendor/github.com/google/uuid/doc.go b/components/cli/vendor/github.com/google/uuid/doc.go new file mode 100644 index 0000000000..5b8a4b9af8 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/doc.go @@ -0,0 +1,12 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package uuid generates and inspects UUIDs. +// +// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security +// Services. +// +// A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to +// maps or compared directly. +package uuid diff --git a/components/cli/vendor/github.com/google/uuid/hash.go b/components/cli/vendor/github.com/google/uuid/hash.go new file mode 100644 index 0000000000..b174616315 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/hash.go @@ -0,0 +1,53 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "crypto/md5" + "crypto/sha1" + "hash" +) + +// Well known namespace IDs and UUIDs +var ( + NameSpaceDNS = Must(Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceURL = Must(Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) + Nil UUID // empty UUID, all zeros +) + +// NewHash returns a new UUID derived from the hash of space concatenated with +// data generated by h. The hash should be at least 16 byte in length. The +// first 16 bytes of the hash are used to form the UUID. The version of the +// UUID will be the lower 4 bits of version. NewHash is used to implement +// NewMD5 and NewSHA1. +func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { + h.Reset() + h.Write(space[:]) + h.Write(data) + s := h.Sum(nil) + var uuid UUID + copy(uuid[:], s) + uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) + uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant + return uuid +} + +// NewMD5 returns a new MD5 (Version 3) UUID based on the +// supplied name space and data. It is the same as calling: +// +// NewHash(md5.New(), space, data, 3) +func NewMD5(space UUID, data []byte) UUID { + return NewHash(md5.New(), space, data, 3) +} + +// NewSHA1 returns a new SHA1 (Version 5) UUID based on the +// supplied name space and data. It is the same as calling: +// +// NewHash(sha1.New(), space, data, 5) +func NewSHA1(space UUID, data []byte) UUID { + return NewHash(sha1.New(), space, data, 5) +} diff --git a/components/cli/vendor/github.com/google/uuid/marshal.go b/components/cli/vendor/github.com/google/uuid/marshal.go new file mode 100644 index 0000000000..7f9e0c6c0e --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/marshal.go @@ -0,0 +1,37 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "fmt" + +// MarshalText implements encoding.TextMarshaler. +func (uuid UUID) MarshalText() ([]byte, error) { + var js [36]byte + encodeHex(js[:], uuid) + return js[:], nil +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (uuid *UUID) UnmarshalText(data []byte) error { + id, err := ParseBytes(data) + if err == nil { + *uuid = id + } + return err +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (uuid UUID) MarshalBinary() ([]byte, error) { + return uuid[:], nil +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (uuid *UUID) UnmarshalBinary(data []byte) error { + if len(data) != 16 { + return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) + } + copy(uuid[:], data) + return nil +} diff --git a/components/cli/vendor/github.com/google/uuid/node.go b/components/cli/vendor/github.com/google/uuid/node.go new file mode 100644 index 0000000000..d651a2b061 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/node.go @@ -0,0 +1,90 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "sync" +) + +var ( + nodeMu sync.Mutex + ifname string // name of interface being used + nodeID [6]byte // hardware for version 1 UUIDs + zeroID [6]byte // nodeID with only 0's +) + +// NodeInterface returns the name of the interface from which the NodeID was +// derived. The interface "user" is returned if the NodeID was set by +// SetNodeID. +func NodeInterface() string { + defer nodeMu.Unlock() + nodeMu.Lock() + return ifname +} + +// SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. +// If name is "" then the first usable interface found will be used or a random +// Node ID will be generated. If a named interface cannot be found then false +// is returned. +// +// SetNodeInterface never fails when name is "". +func SetNodeInterface(name string) bool { + defer nodeMu.Unlock() + nodeMu.Lock() + return setNodeInterface(name) +} + +func setNodeInterface(name string) bool { + iname, addr := getHardwareInterface(name) // null implementation for js + if iname != "" && addr != nil { + ifname = iname + copy(nodeID[:], addr) + return true + } + + // We found no interfaces with a valid hardware address. If name + // does not specify a specific interface generate a random Node ID + // (section 4.1.6) + if name == "" { + ifname = "random" + randomBits(nodeID[:]) + return true + } + return false +} + +// NodeID returns a slice of a copy of the current Node ID, setting the Node ID +// if not already set. +func NodeID() []byte { + defer nodeMu.Unlock() + nodeMu.Lock() + if nodeID == zeroID { + setNodeInterface("") + } + nid := nodeID + return nid[:] +} + +// SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes +// of id are used. If id is less than 6 bytes then false is returned and the +// Node ID is not set. +func SetNodeID(id []byte) bool { + if len(id) < 6 { + return false + } + defer nodeMu.Unlock() + nodeMu.Lock() + copy(nodeID[:], id) + ifname = "user" + return true +} + +// NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is +// not valid. The NodeID is only well defined for version 1 and 2 UUIDs. +func (uuid UUID) NodeID() []byte { + var node [6]byte + copy(node[:], uuid[10:]) + return node[:] +} diff --git a/components/cli/vendor/github.com/google/uuid/node_js.go b/components/cli/vendor/github.com/google/uuid/node_js.go new file mode 100644 index 0000000000..24b78edc90 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/node_js.go @@ -0,0 +1,12 @@ +// Copyright 2017 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build js + +package uuid + +// getHardwareInterface returns nil values for the JS version of the code. +// This remvoves the "net" dependency, because it is not used in the browser. +// Using the "net" library inflates the size of the transpiled JS code by 673k bytes. +func getHardwareInterface(name string) (string, []byte) { return "", nil } diff --git a/components/cli/vendor/github.com/google/uuid/node_net.go b/components/cli/vendor/github.com/google/uuid/node_net.go new file mode 100644 index 0000000000..0cbbcddbd6 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/node_net.go @@ -0,0 +1,33 @@ +// Copyright 2017 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !js + +package uuid + +import "net" + +var interfaces []net.Interface // cached list of interfaces + +// getHardwareInterface returns the name and hardware address of interface name. +// If name is "" then the name and hardware address of one of the system's +// interfaces is returned. If no interfaces are found (name does not exist or +// there are no interfaces) then "", nil is returned. +// +// Only addresses of at least 6 bytes are returned. +func getHardwareInterface(name string) (string, []byte) { + if interfaces == nil { + var err error + interfaces, err = net.Interfaces() + if err != nil { + return "", nil + } + } + for _, ifs := range interfaces { + if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { + return ifs.Name, ifs.HardwareAddr + } + } + return "", nil +} diff --git a/components/cli/vendor/github.com/google/uuid/sql.go b/components/cli/vendor/github.com/google/uuid/sql.go new file mode 100644 index 0000000000..f326b54db3 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/sql.go @@ -0,0 +1,59 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "database/sql/driver" + "fmt" +) + +// Scan implements sql.Scanner so UUIDs can be read from databases transparently +// Currently, database types that map to string and []byte are supported. Please +// consult database-specific driver documentation for matching types. +func (uuid *UUID) Scan(src interface{}) error { + switch src := src.(type) { + case nil: + return nil + + case string: + // if an empty UUID comes from a table, we return a null UUID + if src == "" { + return nil + } + + // see Parse for required string format + u, err := Parse(src) + if err != nil { + return fmt.Errorf("Scan: %v", err) + } + + *uuid = u + + case []byte: + // if an empty UUID comes from a table, we return a null UUID + if len(src) == 0 { + return nil + } + + // assumes a simple slice of bytes if 16 bytes + // otherwise attempts to parse + if len(src) != 16 { + return uuid.Scan(string(src)) + } + copy((*uuid)[:], src) + + default: + return fmt.Errorf("Scan: unable to scan type %T into UUID", src) + } + + return nil +} + +// Value implements sql.Valuer so that UUIDs can be written to databases +// transparently. Currently, UUIDs map to strings. Please consult +// database-specific driver documentation for matching types. +func (uuid UUID) Value() (driver.Value, error) { + return uuid.String(), nil +} diff --git a/components/cli/vendor/github.com/google/uuid/time.go b/components/cli/vendor/github.com/google/uuid/time.go new file mode 100644 index 0000000000..e6ef06cdc8 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/time.go @@ -0,0 +1,123 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "sync" + "time" +) + +// A Time represents a time as the number of 100's of nanoseconds since 15 Oct +// 1582. +type Time int64 + +const ( + lillian = 2299160 // Julian day of 15 Oct 1582 + unix = 2440587 // Julian day of 1 Jan 1970 + epoch = unix - lillian // Days between epochs + g1582 = epoch * 86400 // seconds between epochs + g1582ns100 = g1582 * 10000000 // 100s of a nanoseconds between epochs +) + +var ( + timeMu sync.Mutex + lasttime uint64 // last time we returned + clockSeq uint16 // clock sequence for this run + + timeNow = time.Now // for testing +) + +// UnixTime converts t the number of seconds and nanoseconds using the Unix +// epoch of 1 Jan 1970. +func (t Time) UnixTime() (sec, nsec int64) { + sec = int64(t - g1582ns100) + nsec = (sec % 10000000) * 100 + sec /= 10000000 + return sec, nsec +} + +// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and +// clock sequence as well as adjusting the clock sequence as needed. An error +// is returned if the current time cannot be determined. +func GetTime() (Time, uint16, error) { + defer timeMu.Unlock() + timeMu.Lock() + return getTime() +} + +func getTime() (Time, uint16, error) { + t := timeNow() + + // If we don't have a clock sequence already, set one. + if clockSeq == 0 { + setClockSequence(-1) + } + now := uint64(t.UnixNano()/100) + g1582ns100 + + // If time has gone backwards with this clock sequence then we + // increment the clock sequence + if now <= lasttime { + clockSeq = ((clockSeq + 1) & 0x3fff) | 0x8000 + } + lasttime = now + return Time(now), clockSeq, nil +} + +// ClockSequence returns the current clock sequence, generating one if not +// already set. The clock sequence is only used for Version 1 UUIDs. +// +// The uuid package does not use global static storage for the clock sequence or +// the last time a UUID was generated. Unless SetClockSequence is used, a new +// random clock sequence is generated the first time a clock sequence is +// requested by ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) +func ClockSequence() int { + defer timeMu.Unlock() + timeMu.Lock() + return clockSequence() +} + +func clockSequence() int { + if clockSeq == 0 { + setClockSequence(-1) + } + return int(clockSeq & 0x3fff) +} + +// SetClockSequence sets the clock sequence to the lower 14 bits of seq. Setting to +// -1 causes a new sequence to be generated. +func SetClockSequence(seq int) { + defer timeMu.Unlock() + timeMu.Lock() + setClockSequence(seq) +} + +func setClockSequence(seq int) { + if seq == -1 { + var b [2]byte + randomBits(b[:]) // clock sequence + seq = int(b[0])<<8 | int(b[1]) + } + oldSeq := clockSeq + clockSeq = uint16(seq&0x3fff) | 0x8000 // Set our variant + if oldSeq != clockSeq { + lasttime = 0 + } +} + +// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in +// uuid. The time is only defined for version 1 and 2 UUIDs. +func (uuid UUID) Time() Time { + time := int64(binary.BigEndian.Uint32(uuid[0:4])) + time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 + time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 + return Time(time) +} + +// ClockSequence returns the clock sequence encoded in uuid. +// The clock sequence is only well defined for version 1 and 2 UUIDs. +func (uuid UUID) ClockSequence() int { + return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff +} diff --git a/components/cli/vendor/github.com/google/uuid/util.go b/components/cli/vendor/github.com/google/uuid/util.go new file mode 100644 index 0000000000..5ea6c73780 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/util.go @@ -0,0 +1,43 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "io" +) + +// randomBits completely fills slice b with random data. +func randomBits(b []byte) { + if _, err := io.ReadFull(rander, b); err != nil { + panic(err.Error()) // rand should never fail + } +} + +// xvalues returns the value of a byte as a hexadecimal digit or 255. +var xvalues = [256]byte{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +} + +// xtob converts hex characters x1 and x2 into a byte. +func xtob(x1, x2 byte) (byte, bool) { + b1 := xvalues[x1] + b2 := xvalues[x2] + return (b1 << 4) | b2, b1 != 255 && b2 != 255 +} diff --git a/components/cli/vendor/github.com/google/uuid/uuid.go b/components/cli/vendor/github.com/google/uuid/uuid.go new file mode 100644 index 0000000000..524404cc52 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/uuid.go @@ -0,0 +1,245 @@ +// Copyright 2018 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "bytes" + "crypto/rand" + "encoding/hex" + "errors" + "fmt" + "io" + "strings" +) + +// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC +// 4122. +type UUID [16]byte + +// A Version represents a UUID's version. +type Version byte + +// A Variant represents a UUID's variant. +type Variant byte + +// Constants returned by Variant. +const ( + Invalid = Variant(iota) // Invalid UUID + RFC4122 // The variant specified in RFC4122 + Reserved // Reserved, NCS backward compatibility. + Microsoft // Reserved, Microsoft Corporation backward compatibility. + Future // Reserved for future definition. +) + +var rander = rand.Reader // random function + +// Parse decodes s into a UUID or returns an error. Both the standard UUID +// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the +// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex +// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. +func Parse(s string) (UUID, error) { + var uuid UUID + switch len(s) { + // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36: + + // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36 + 9: + if strings.ToLower(s[:9]) != "urn:uuid:" { + return uuid, fmt.Errorf("invalid urn prefix: %q", s[:9]) + } + s = s[9:] + + // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} + case 36 + 2: + s = s[1:] + + // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + case 32: + var ok bool + for i := range uuid { + uuid[i], ok = xtob(s[i*2], s[i*2+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + } + return uuid, nil + default: + return uuid, fmt.Errorf("invalid UUID length: %d", len(s)) + } + // s is now at least 36 bytes long + // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { + return uuid, errors.New("invalid UUID format") + } + for i, x := range [16]int{ + 0, 2, 4, 6, + 9, 11, + 14, 16, + 19, 21, + 24, 26, 28, 30, 32, 34} { + v, ok := xtob(s[x], s[x+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + uuid[i] = v + } + return uuid, nil +} + +// ParseBytes is like Parse, except it parses a byte slice instead of a string. +func ParseBytes(b []byte) (UUID, error) { + var uuid UUID + switch len(b) { + case 36: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36 + 9: // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if !bytes.Equal(bytes.ToLower(b[:9]), []byte("urn:uuid:")) { + return uuid, fmt.Errorf("invalid urn prefix: %q", b[:9]) + } + b = b[9:] + case 36 + 2: // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} + b = b[1:] + case 32: // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + var ok bool + for i := 0; i < 32; i += 2 { + uuid[i/2], ok = xtob(b[i], b[i+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + } + return uuid, nil + default: + return uuid, fmt.Errorf("invalid UUID length: %d", len(b)) + } + // s is now at least 36 bytes long + // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' { + return uuid, errors.New("invalid UUID format") + } + for i, x := range [16]int{ + 0, 2, 4, 6, + 9, 11, + 14, 16, + 19, 21, + 24, 26, 28, 30, 32, 34} { + v, ok := xtob(b[x], b[x+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + uuid[i] = v + } + return uuid, nil +} + +// MustParse is like Parse but panics if the string cannot be parsed. +// It simplifies safe initialization of global variables holding compiled UUIDs. +func MustParse(s string) UUID { + uuid, err := Parse(s) + if err != nil { + panic(`uuid: Parse(` + s + `): ` + err.Error()) + } + return uuid +} + +// FromBytes creates a new UUID from a byte slice. Returns an error if the slice +// does not have a length of 16. The bytes are copied from the slice. +func FromBytes(b []byte) (uuid UUID, err error) { + err = uuid.UnmarshalBinary(b) + return uuid, err +} + +// Must returns uuid if err is nil and panics otherwise. +func Must(uuid UUID, err error) UUID { + if err != nil { + panic(err) + } + return uuid +} + +// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +// , or "" if uuid is invalid. +func (uuid UUID) String() string { + var buf [36]byte + encodeHex(buf[:], uuid) + return string(buf[:]) +} + +// URN returns the RFC 2141 URN form of uuid, +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid. +func (uuid UUID) URN() string { + var buf [36 + 9]byte + copy(buf[:], "urn:uuid:") + encodeHex(buf[9:], uuid) + return string(buf[:]) +} + +func encodeHex(dst []byte, uuid UUID) { + hex.Encode(dst, uuid[:4]) + dst[8] = '-' + hex.Encode(dst[9:13], uuid[4:6]) + dst[13] = '-' + hex.Encode(dst[14:18], uuid[6:8]) + dst[18] = '-' + hex.Encode(dst[19:23], uuid[8:10]) + dst[23] = '-' + hex.Encode(dst[24:], uuid[10:]) +} + +// Variant returns the variant encoded in uuid. +func (uuid UUID) Variant() Variant { + switch { + case (uuid[8] & 0xc0) == 0x80: + return RFC4122 + case (uuid[8] & 0xe0) == 0xc0: + return Microsoft + case (uuid[8] & 0xe0) == 0xe0: + return Future + default: + return Reserved + } +} + +// Version returns the version of uuid. +func (uuid UUID) Version() Version { + return Version(uuid[6] >> 4) +} + +func (v Version) String() string { + if v > 15 { + return fmt.Sprintf("BAD_VERSION_%d", v) + } + return fmt.Sprintf("VERSION_%d", v) +} + +func (v Variant) String() string { + switch v { + case RFC4122: + return "RFC4122" + case Reserved: + return "Reserved" + case Microsoft: + return "Microsoft" + case Future: + return "Future" + case Invalid: + return "Invalid" + } + return fmt.Sprintf("BadVariant%d", int(v)) +} + +// SetRand sets the random number generator to r, which implements io.Reader. +// If r.Read returns an error when the package requests random data then +// a panic will be issued. +// +// Calling SetRand with nil sets the random number generator to the default +// generator. +func SetRand(r io.Reader) { + if r == nil { + rander = rand.Reader + return + } + rander = r +} diff --git a/components/cli/vendor/github.com/google/uuid/version1.go b/components/cli/vendor/github.com/google/uuid/version1.go new file mode 100644 index 0000000000..199a1ac654 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/version1.go @@ -0,0 +1,44 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" +) + +// NewUUID returns a Version 1 UUID based on the current NodeID and clock +// sequence, and the current time. If the NodeID has not been set by SetNodeID +// or SetNodeInterface then it will be set automatically. If the NodeID cannot +// be set NewUUID returns nil. If clock sequence has not been set by +// SetClockSequence then it will be set automatically. If GetTime fails to +// return the current NewUUID returns nil and an error. +// +// In most cases, New should be used. +func NewUUID() (UUID, error) { + nodeMu.Lock() + if nodeID == zeroID { + setNodeInterface("") + } + nodeMu.Unlock() + + var uuid UUID + now, seq, err := GetTime() + if err != nil { + return uuid, err + } + + timeLow := uint32(now & 0xffffffff) + timeMid := uint16((now >> 32) & 0xffff) + timeHi := uint16((now >> 48) & 0x0fff) + timeHi |= 0x1000 // Version 1 + + binary.BigEndian.PutUint32(uuid[0:], timeLow) + binary.BigEndian.PutUint16(uuid[4:], timeMid) + binary.BigEndian.PutUint16(uuid[6:], timeHi) + binary.BigEndian.PutUint16(uuid[8:], seq) + copy(uuid[10:], nodeID[:]) + + return uuid, nil +} diff --git a/components/cli/vendor/github.com/google/uuid/version4.go b/components/cli/vendor/github.com/google/uuid/version4.go new file mode 100644 index 0000000000..84af91c9f5 --- /dev/null +++ b/components/cli/vendor/github.com/google/uuid/version4.go @@ -0,0 +1,38 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "io" + +// New creates a new random UUID or panics. New is equivalent to +// the expression +// +// uuid.Must(uuid.NewRandom()) +func New() UUID { + return Must(NewRandom()) +} + +// NewRandom returns a Random (Version 4) UUID. +// +// The strength of the UUIDs is based on the strength of the crypto/rand +// package. +// +// A note about uniqueness derived from the UUID Wikipedia entry: +// +// Randomly generated UUIDs have 122 random bits. One's annual risk of being +// hit by a meteorite is estimated to be one chance in 17 billion, that +// means the probability is about 0.00000000006 (6 × 10−11), +// equivalent to the odds of creating a few tens of trillions of UUIDs in a +// year and having one duplicate. +func NewRandom() (UUID, error) { + var uuid UUID + _, err := io.ReadFull(rander, uuid[:]) + if err != nil { + return Nil, err + } + uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 + uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 + return uuid, nil +} diff --git a/components/cli/vendor/github.com/satori/go.uuid/LICENSE b/components/cli/vendor/github.com/satori/go.uuid/LICENSE deleted file mode 100644 index 6a1fb910dd..0000000000 --- a/components/cli/vendor/github.com/satori/go.uuid/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (C) 2013-2015 by Maxim Bublis - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/components/cli/vendor/github.com/satori/go.uuid/README.md b/components/cli/vendor/github.com/satori/go.uuid/README.md deleted file mode 100644 index 48d4937f43..0000000000 --- a/components/cli/vendor/github.com/satori/go.uuid/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# UUID package for Go language - -[![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid) -[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid) - -This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. - -With 100% test coverage and benchmarks out of box. - -Supported versions: -* Version 1, based on timestamp and MAC address (RFC 4122) -* Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) -* Version 3, based on MD5 hashing (RFC 4122) -* Version 4, based on random numbers (RFC 4122) -* Version 5, based on SHA-1 hashing (RFC 4122) - -## Installation - -Use the `go` command: - - $ go get github.com/satori/go.uuid - -## Requirements - -UUID package requires any stable version of Go Programming Language. - -It is tested against following versions of Go: 1.0-1.5 - -## Example - -```go -package main - -import ( - "fmt" - "github.com/satori/go.uuid" -) - -func main() { - // Creating UUID Version 4 - u1 := uuid.NewV4() - fmt.Printf("UUIDv4: %s\n", u1) - - // Parsing UUID from string input - u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - if err != nil { - fmt.Printf("Something gone wrong: %s", err) - } - fmt.Printf("Successfully parsed: %s", u2) -} -``` - -## Documentation - -[Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. - -## Links -* [RFC 4122](http://tools.ietf.org/html/rfc4122) -* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) - -## Copyright - -Copyright (C) 2013-2015 by Maxim Bublis . - -UUID package released under MIT License. -See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. diff --git a/components/cli/vendor/github.com/satori/go.uuid/uuid.go b/components/cli/vendor/github.com/satori/go.uuid/uuid.go deleted file mode 100644 index 03841d86e0..0000000000 --- a/components/cli/vendor/github.com/satori/go.uuid/uuid.go +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright (C) 2013-2015 by Maxim Bublis -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -// Package uuid provides implementation of Universally Unique Identifier (UUID). -// Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and -// version 2 (as specified in DCE 1.1). -package uuid - -import ( - "bytes" - "crypto/md5" - "crypto/rand" - "crypto/sha1" - "database/sql/driver" - "encoding/binary" - "encoding/hex" - "fmt" - "hash" - "net" - "os" - "sync" - "time" -) - -// UUID layout variants. -const ( - VariantNCS = iota - VariantRFC4122 - VariantMicrosoft - VariantFuture -) - -// UUID DCE domains. -const ( - DomainPerson = iota - DomainGroup - DomainOrg -) - -// Difference in 100-nanosecond intervals between -// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). -const epochStart = 122192928000000000 - -// Used in string method conversion -const dash byte = '-' - -// UUID v1/v2 storage. -var ( - storageMutex sync.Mutex - storageOnce sync.Once - epochFunc = unixTimeFunc - clockSequence uint16 - lastTime uint64 - hardwareAddr [6]byte - posixUID = uint32(os.Getuid()) - posixGID = uint32(os.Getgid()) -) - -// String parse helpers. -var ( - urnPrefix = []byte("urn:uuid:") - byteGroups = []int{8, 4, 4, 4, 12} -) - -func initClockSequence() { - buf := make([]byte, 2) - safeRandom(buf) - clockSequence = binary.BigEndian.Uint16(buf) -} - -func initHardwareAddr() { - interfaces, err := net.Interfaces() - if err == nil { - for _, iface := range interfaces { - if len(iface.HardwareAddr) >= 6 { - copy(hardwareAddr[:], iface.HardwareAddr) - return - } - } - } - - // Initialize hardwareAddr randomly in case - // of real network interfaces absence - safeRandom(hardwareAddr[:]) - - // Set multicast bit as recommended in RFC 4122 - hardwareAddr[0] |= 0x01 -} - -func initStorage() { - initClockSequence() - initHardwareAddr() -} - -func safeRandom(dest []byte) { - if _, err := rand.Read(dest); err != nil { - panic(err) - } -} - -// Returns difference in 100-nanosecond intervals between -// UUID epoch (October 15, 1582) and current time. -// This is default epoch calculation function. -func unixTimeFunc() uint64 { - return epochStart + uint64(time.Now().UnixNano()/100) -} - -// UUID representation compliant with specification -// described in RFC 4122. -type UUID [16]byte - -// The nil UUID is special form of UUID that is specified to have all -// 128 bits set to zero. -var Nil = UUID{} - -// Predefined namespace UUIDs. -var ( - NamespaceDNS, _ = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - NamespaceURL, _ = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8") - NamespaceOID, _ = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8") - NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8") -) - -// And returns result of binary AND of two UUIDs. -func And(u1 UUID, u2 UUID) UUID { - u := UUID{} - for i := 0; i < 16; i++ { - u[i] = u1[i] & u2[i] - } - return u -} - -// Or returns result of binary OR of two UUIDs. -func Or(u1 UUID, u2 UUID) UUID { - u := UUID{} - for i := 0; i < 16; i++ { - u[i] = u1[i] | u2[i] - } - return u -} - -// Equal returns true if u1 and u2 equals, otherwise returns false. -func Equal(u1 UUID, u2 UUID) bool { - return bytes.Equal(u1[:], u2[:]) -} - -// Version returns algorithm version used to generate UUID. -func (u UUID) Version() uint { - return uint(u[6] >> 4) -} - -// Variant returns UUID layout variant. -func (u UUID) Variant() uint { - switch { - case (u[8] & 0x80) == 0x00: - return VariantNCS - case (u[8]&0xc0)|0x80 == 0x80: - return VariantRFC4122 - case (u[8]&0xe0)|0xc0 == 0xc0: - return VariantMicrosoft - } - return VariantFuture -} - -// Bytes returns bytes slice representation of UUID. -func (u UUID) Bytes() []byte { - return u[:] -} - -// Returns canonical string representation of UUID: -// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. -func (u UUID) String() string { - buf := make([]byte, 36) - - hex.Encode(buf[0:8], u[0:4]) - buf[8] = dash - hex.Encode(buf[9:13], u[4:6]) - buf[13] = dash - hex.Encode(buf[14:18], u[6:8]) - buf[18] = dash - hex.Encode(buf[19:23], u[8:10]) - buf[23] = dash - hex.Encode(buf[24:], u[10:]) - - return string(buf) -} - -// SetVersion sets version bits. -func (u *UUID) SetVersion(v byte) { - u[6] = (u[6] & 0x0f) | (v << 4) -} - -// SetVariant sets variant bits as described in RFC 4122. -func (u *UUID) SetVariant() { - u[8] = (u[8] & 0xbf) | 0x80 -} - -// MarshalText implements the encoding.TextMarshaler interface. -// The encoding is the same as returned by String. -func (u UUID) MarshalText() (text []byte, err error) { - text = []byte(u.String()) - return -} - -// UnmarshalText implements the encoding.TextUnmarshaler interface. -// Following formats are supported: -// "6ba7b810-9dad-11d1-80b4-00c04fd430c8", -// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", -// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" -func (u *UUID) UnmarshalText(text []byte) (err error) { - if len(text) < 32 { - err = fmt.Errorf("uuid: invalid UUID string: %s", text) - return - } - - if bytes.Equal(text[:9], urnPrefix) { - text = text[9:] - } else if text[0] == '{' { - text = text[1:] - } - - b := u[:] - - for _, byteGroup := range byteGroups { - if text[0] == '-' { - text = text[1:] - } - - _, err = hex.Decode(b[:byteGroup/2], text[:byteGroup]) - - if err != nil { - return - } - - text = text[byteGroup:] - b = b[byteGroup/2:] - } - - return -} - -// MarshalBinary implements the encoding.BinaryMarshaler interface. -func (u UUID) MarshalBinary() (data []byte, err error) { - data = u.Bytes() - return -} - -// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. -// It will return error if the slice isn't 16 bytes long. -func (u *UUID) UnmarshalBinary(data []byte) (err error) { - if len(data) != 16 { - err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) - return - } - copy(u[:], data) - - return -} - -// Value implements the driver.Valuer interface. -func (u UUID) Value() (driver.Value, error) { - return u.String(), nil -} - -// Scan implements the sql.Scanner interface. -// A 16-byte slice is handled by UnmarshalBinary, while -// a longer byte slice or a string is handled by UnmarshalText. -func (u *UUID) Scan(src interface{}) error { - switch src := src.(type) { - case []byte: - if len(src) == 16 { - return u.UnmarshalBinary(src) - } - return u.UnmarshalText(src) - - case string: - return u.UnmarshalText([]byte(src)) - } - - return fmt.Errorf("uuid: cannot convert %T to UUID", src) -} - -// FromBytes returns UUID converted from raw byte slice input. -// It will return error if the slice isn't 16 bytes long. -func FromBytes(input []byte) (u UUID, err error) { - err = u.UnmarshalBinary(input) - return -} - -// FromBytesOrNil returns UUID converted from raw byte slice input. -// Same behavior as FromBytes, but returns a Nil UUID on error. -func FromBytesOrNil(input []byte) UUID { - uuid, err := FromBytes(input) - if err != nil { - return Nil - } - return uuid -} - -// FromString returns UUID parsed from string input. -// Input is expected in a form accepted by UnmarshalText. -func FromString(input string) (u UUID, err error) { - err = u.UnmarshalText([]byte(input)) - return -} - -// FromStringOrNil returns UUID parsed from string input. -// Same behavior as FromString, but returns a Nil UUID on error. -func FromStringOrNil(input string) UUID { - uuid, err := FromString(input) - if err != nil { - return Nil - } - return uuid -} - -// Returns UUID v1/v2 storage state. -// Returns epoch timestamp, clock sequence, and hardware address. -func getStorage() (uint64, uint16, []byte) { - storageOnce.Do(initStorage) - - storageMutex.Lock() - defer storageMutex.Unlock() - - timeNow := epochFunc() - // Clock changed backwards since last UUID generation. - // Should increase clock sequence. - if timeNow <= lastTime { - clockSequence++ - } - lastTime = timeNow - - return timeNow, clockSequence, hardwareAddr[:] -} - -// NewV1 returns UUID based on current timestamp and MAC address. -func NewV1() UUID { - u := UUID{} - - timeNow, clockSeq, hardwareAddr := getStorage() - - binary.BigEndian.PutUint32(u[0:], uint32(timeNow)) - binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) - binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) - binary.BigEndian.PutUint16(u[8:], clockSeq) - - copy(u[10:], hardwareAddr) - - u.SetVersion(1) - u.SetVariant() - - return u -} - -// NewV2 returns DCE Security UUID based on POSIX UID/GID. -func NewV2(domain byte) UUID { - u := UUID{} - - timeNow, clockSeq, hardwareAddr := getStorage() - - switch domain { - case DomainPerson: - binary.BigEndian.PutUint32(u[0:], posixUID) - case DomainGroup: - binary.BigEndian.PutUint32(u[0:], posixGID) - } - - binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) - binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) - binary.BigEndian.PutUint16(u[8:], clockSeq) - u[9] = domain - - copy(u[10:], hardwareAddr) - - u.SetVersion(2) - u.SetVariant() - - return u -} - -// NewV3 returns UUID based on MD5 hash of namespace UUID and name. -func NewV3(ns UUID, name string) UUID { - u := newFromHash(md5.New(), ns, name) - u.SetVersion(3) - u.SetVariant() - - return u -} - -// NewV4 returns random generated UUID. -func NewV4() UUID { - u := UUID{} - safeRandom(u[:]) - u.SetVersion(4) - u.SetVariant() - - return u -} - -// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name. -func NewV5(ns UUID, name string) UUID { - u := newFromHash(sha1.New(), ns, name) - u.SetVersion(5) - u.SetVariant() - - return u -} - -// Returns UUID based on hashing of namespace UUID and name. -func newFromHash(h hash.Hash, ns UUID, name string) UUID { - u := UUID{} - h.Write(ns[:]) - h.Write([]byte(name)) - copy(u[:], h.Sum(nil)) - - return u -} From a0b40b8b45b3b0d2d40ab8e11d08e753b3cf6faf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 25 Jun 2019 00:12:01 +0200 Subject: [PATCH 18/28] Windows: skip permissions check on key This code was attempting to check Linux file permissions to determine if the key was accessible by other users, which doesn't work, and therefore prevented users on Windows to load keys. Skipping this check on Windows (correspinding tests were already skipped). Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 15d361fd77d69514aa544fbcb5cb7ce15c3184f4) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 6be8fce6f8c1f3b16b8b39f5e163839205bfe43d Component: cli --- components/cli/cli/command/trust/key_load.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/cli/cli/command/trust/key_load.go b/components/cli/cli/command/trust/key_load.go index 9263cbda47..3b2c04bac9 100644 --- a/components/cli/cli/command/trust/key_load.go +++ b/components/cli/cli/command/trust/key_load.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "os" + "runtime" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" @@ -69,12 +70,14 @@ func loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions } func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) { - fileInfo, err := os.Stat(keyPath) - if err != nil { - return nil, err - } - if fileInfo.Mode()&nonOwnerReadWriteMask != 0 { - return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath) + if runtime.GOOS != "windows" { + fileInfo, err := os.Stat(keyPath) + if err != nil { + return nil, err + } + if fileInfo.Mode()&nonOwnerReadWriteMask != 0 { + return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath) + } } from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms) From 45c60750ea647f3e6631c08368bb9531a600a0f9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 Jul 2019 22:13:19 +0200 Subject: [PATCH 19/28] Detect Windows absolute paths on non-Windows CLI When deploying a stack using a relative path as bind-mount source in the compose file, the CLI converts the relative path to an absolute path, relative to the location of the docker-compose file. This causes a problem when deploying a stack that uses an absolute Windows path, because a non-Windows client will fail to detect that the path (e.g. `C:\somedir`) is an absolute path (and not a relative directory named `C:\`). The existing code did already take Windows clients deploying a Linux stack into account (by checking if the path had a leading slash). This patch adds the reverse, and adds detection for Windows absolute paths on non-Windows clients. The code used to detect Windows absolute paths is copied from the Golang filepath package; https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_windows.go#L12-L65 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit d6dd08d568bb98bbee4a1767e67502832551794e) Signed-off-by: Sebastiaan van Stijn Upstream-commit: a757fad956a9b2a9198946a1d719ea8df0db909f Component: cli --- components/cli/cli/compose/loader/loader.go | 13 ++-- .../cli/cli/compose/loader/loader_test.go | 78 +++++++++++++++++++ .../cli/cli/compose/loader/windows_path.go | 66 ++++++++++++++++ .../cli/compose/loader/windows_path_test.go | 61 +++++++++++++++ 4 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 components/cli/cli/compose/loader/windows_path.go create mode 100644 components/cli/cli/compose/loader/windows_path_test.go diff --git a/components/cli/cli/compose/loader/loader.go b/components/cli/cli/compose/loader/loader.go index cea5d109c0..a89d48bedb 100644 --- a/components/cli/cli/compose/loader/loader.go +++ b/components/cli/cli/compose/loader/loader.go @@ -476,12 +476,13 @@ func resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string, } filePath := expandUser(volume.Source, lookupEnv) - // Check for a Unix absolute path first, to handle a Windows client - // with a Unix daemon. This handles a Windows client connecting to a - // Unix daemon. Note that this is not required for Docker for Windows - // when specifying a local Windows path, because Docker for Windows - // translates the Windows path into a valid path within the VM. - if !path.IsAbs(filePath) { + // Check if source is an absolute path (either Unix or Windows), to + // handle a Windows client with a Unix daemon or vice-versa. + // + // Note that this is not required for Docker for Windows when specifying + // a local Windows path, because Docker for Windows translates the Windows + // path into a valid path within the VM. + if !path.IsAbs(filePath) && !isAbs(filePath) { filePath = absPath(workingDir, filePath) } volume.Source = filePath diff --git a/components/cli/cli/compose/loader/loader_test.go b/components/cli/cli/compose/loader/loader_test.go index 42650c08b1..6059919c9f 100644 --- a/components/cli/cli/compose/loader/loader_test.go +++ b/components/cli/cli/compose/loader/loader_test.go @@ -909,6 +909,84 @@ services: assert.Error(t, err, `invalid mount config for type "bind": field Source must not be empty`) } +func TestLoadBindMountSourceIsWindowsAbsolute(t *testing.T) { + tests := []struct { + doc string + yaml string + expected types.ServiceVolumeConfig + }{ + { + doc: "Z-drive lowercase", + yaml: ` +version: '3.3' + +services: + windows: + image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 + volumes: + - type: bind + source: z:\ + target: c:\data +`, + expected: types.ServiceVolumeConfig{Type: "bind", Source: `z:\`, Target: `c:\data`}, + }, + { + doc: "Z-drive uppercase", + yaml: ` +version: '3.3' + +services: + windows: + image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 + volumes: + - type: bind + source: Z:\ + target: C:\data +`, + expected: types.ServiceVolumeConfig{Type: "bind", Source: `Z:\`, Target: `C:\data`}, + }, + { + doc: "Z-drive subdirectory", + yaml: ` +version: '3.3' + +services: + windows: + image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 + volumes: + - type: bind + source: Z:\some-dir + target: C:\data +`, + expected: types.ServiceVolumeConfig{Type: "bind", Source: `Z:\some-dir`, Target: `C:\data`}, + }, + { + doc: "forward-slashes", + yaml: ` +version: '3.3' + +services: + app: + image: app:latest + volumes: + - type: bind + source: /z/some-dir + target: /c/data +`, + expected: types.ServiceVolumeConfig{Type: "bind", Source: `/z/some-dir`, Target: `/c/data`}, + }, + } + + for _, tc := range tests { + t.Run(tc.doc, func(t *testing.T) { + config, err := loadYAML(tc.yaml) + assert.NilError(t, err) + assert.Check(t, is.Len(config.Services[0].Volumes, 1)) + assert.Check(t, is.DeepEqual(tc.expected, config.Services[0].Volumes[0])) + }) + } +} + func TestLoadBindMountWithSource(t *testing.T) { config, err := loadYAML(` version: "3.5" diff --git a/components/cli/cli/compose/loader/windows_path.go b/components/cli/cli/compose/loader/windows_path.go new file mode 100644 index 0000000000..eaf41bf72a --- /dev/null +++ b/components/cli/cli/compose/loader/windows_path.go @@ -0,0 +1,66 @@ +package loader + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// https://github.com/golang/go/blob/master/LICENSE + +// This file contains utilities to check for Windows absolute paths on Linux. +// The code in this file was largely copied from the Golang filepath package +// https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_windows.go#L12-L65 + +func isSlash(c uint8) bool { + return c == '\\' || c == '/' +} + +// isAbs reports whether the path is a Windows absolute path. +func isAbs(path string) (b bool) { + l := volumeNameLen(path) + if l == 0 { + return false + } + path = path[l:] + if path == "" { + return false + } + return isSlash(path[0]) +} + +// volumeNameLen returns length of the leading volume name on Windows. +// It returns 0 elsewhere. +// nolint: gocyclo +func volumeNameLen(path string) int { + if len(path) < 2 { + return 0 + } + // with drive letter + c := path[0] + if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') { + return 2 + } + // is it UNC? https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx + if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) && + !isSlash(path[2]) && path[2] != '.' { + // first, leading `\\` and next shouldn't be `\`. its server name. + for n := 3; n < l-1; n++ { + // second, next '\' shouldn't be repeated. + if isSlash(path[n]) { + n++ + // third, following something characters. its share name. + if !isSlash(path[n]) { + if path[n] == '.' { + break + } + for ; n < l; n++ { + if isSlash(path[n]) { + break + } + } + return n + } + break + } + } + } + return 0 +} diff --git a/components/cli/cli/compose/loader/windows_path_test.go b/components/cli/cli/compose/loader/windows_path_test.go new file mode 100644 index 0000000000..d612d41733 --- /dev/null +++ b/components/cli/cli/compose/loader/windows_path_test.go @@ -0,0 +1,61 @@ +package loader + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// https://github.com/golang/go/blob/master/LICENSE + +// The code in this file was copied from the Golang filepath package with some +// small modifications to run it on non-Windows platforms. +// https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_test.go#L711-L763 + +import "testing" + +type IsAbsTest struct { + path string + isAbs bool +} + +var isabstests = []IsAbsTest{ + {"", false}, + {"/", true}, + {"/usr/bin/gcc", true}, + {"..", false}, + {"/a/../bb", true}, + {".", false}, + {"./", false}, + {"lala", false}, +} + +var winisabstests = []IsAbsTest{ + {`C:\`, true}, + {`c\`, false}, + {`c::`, false}, + {`c:`, false}, + {`/`, false}, + {`\`, false}, + {`\Windows`, false}, + {`c:a\b`, false}, + {`c:\a\b`, true}, + {`c:/a/b`, true}, + {`\\host\share\foo`, true}, + {`//host/share/foo/bar`, true}, +} + +func TestIsAbs(t *testing.T) { + tests := append(isabstests, winisabstests...) + // All non-windows tests should fail, because they have no volume letter. + for _, test := range isabstests { + tests = append(tests, IsAbsTest{test.path, false}) + } + // All non-windows test should work as intended if prefixed with volume letter. + for _, test := range isabstests { + tests = append(tests, IsAbsTest{"c:" + test.path, test.isAbs}) + } + + for _, test := range winisabstests { + if r := isAbs(test.path); r != test.isAbs { + t.Errorf("IsAbs(%q) = %v, want %v", test.path, r, test.isAbs) + } + } +} From d352de241a6157a028a6d8e606989aabc84750c1 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Sun, 14 Jan 2018 01:08:23 -0500 Subject: [PATCH 20/28] docs: add info for events backlog and scope 1. Adds `docker events` description info on the two scope types of events. 2. Adds `docker events` note in two places about backlog limit of event log. Further info and background info in Issue 727 Signed-off-by: Bret Fisher Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 988b9a0d9646137e1582e5def62f6b7754498a19) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 74d51dc13b33e55c9c5ac121b198dbb94f21b4ea Component: cli --- components/cli/docs/reference/commandline/events.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/cli/docs/reference/commandline/events.md b/components/cli/docs/reference/commandline/events.md index 5c450aa0a9..eea1218c3a 100644 --- a/components/cli/docs/reference/commandline/events.md +++ b/components/cli/docs/reference/commandline/events.md @@ -31,7 +31,12 @@ Options: ## Description Use `docker events` to get real-time events from the server. These events differ -per Docker object type. +per Docker object type. Different event types have different scopes. Local +scoped events are only seen on the node they take place on, and swarm scoped +events are seen on all managers. + +Only the last 1000 log events are returned. You can use filters to further limit +the number of events returned. ### Object types @@ -160,6 +165,9 @@ that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long. +Only the last 1000 log events are returned. You can use filters to further limit +the number of events returned. + #### Filtering The filtering flag (`-f` or `--filter`) format is of "key=value". If you would From 87dd848fb9a82d2ab056ce62602fd1a1d7241e47 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 10 May 2019 22:14:39 +0200 Subject: [PATCH 21/28] Add bash completion for `events --filter node` Signed-off-by: Harald Albers (cherry picked from commit c1639e1e42903e008d75ac1454f13d9c1d3b0e3e) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 7ee8241f7165c4abaa00c08e82bf8b7b0a8ff772 Component: cli --- components/cli/contrib/completion/bash/docker | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/cli/contrib/completion/bash/docker b/components/cli/contrib/completion/bash/docker index 92d5740861..732750478a 100644 --- a/components/cli/contrib/completion/bash/docker +++ b/components/cli/contrib/completion/bash/docker @@ -4848,6 +4848,10 @@ _docker_system_events() { __docker_complete_networks --cur "${cur##*=}" return ;; + node) + __docker_complete_nodes --cur "${cur##*=}" + return + ;; scope) COMPREPLY=( $( compgen -W "local swarm" -- "${cur##*=}" ) ) return @@ -4864,7 +4868,7 @@ _docker_system_events() { case "$prev" in --filter|-f) - COMPREPLY=( $( compgen -S = -W "container daemon event image label network scope type volume" -- "$cur" ) ) + COMPREPLY=( $( compgen -S = -W "container daemon event image label network node scope type volume" -- "$cur" ) ) __docker_nospace return ;; From 025a808cd460aadbc0dde98c46cd3937cf256a4f Mon Sep 17 00:00:00 2001 From: Rohan Verma Date: Fri, 14 Jun 2019 13:20:14 +0530 Subject: [PATCH 22/28] fix: docker login autocomplete for zsh Changed `--user` to `--username` Signed-off-by: Rohan Verma (cherry picked from commit 1dc756e8dfcba59fb901092651f4e68210bdb580) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 048af5b37b2a7b02e2a4834c56c6eadc0d1dabb7 Component: cli --- components/cli/contrib/completion/zsh/_docker | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/cli/contrib/completion/zsh/_docker b/components/cli/contrib/completion/zsh/_docker index 94f042204d..ddc367d4d4 100644 --- a/components/cli/contrib/completion/zsh/_docker +++ b/components/cli/contrib/completion/zsh/_docker @@ -9,6 +9,7 @@ # - Felix Riedel # - Steve Durrheimer # - Vincent Bernat +# - Rohan Verma # # license: # @@ -2781,7 +2782,7 @@ __docker_subcommand() { $opts_help \ "($help -p --password)"{-p=,--password=}"[Password]:password: " \ "($help)--password-stdin[Read password from stdin]" \ - "($help -u --user)"{-u=,--user=}"[Username]:username: " \ + "($help -u --username)"{-u=,--username=}"[Username]:username: " \ "($help -)1:server: " && ret=0 ;; (logout) From 1a64b8a4d1b9543f0e4839f1be5d6e2ee0e1000c Mon Sep 17 00:00:00 2001 From: Matteo Orefice Date: Sun, 10 Feb 2019 14:04:45 +0000 Subject: [PATCH 23/28] Prevent bash process substitution error in cygwin Signed-off-by: Matteo Orefice (cherry picked from commit 0b49495b1d361efa72e3ef35ff000c863966bfe1) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 0dff33436c827787356927a1c5385f64f4c1a1a1 Component: cli --- components/cli/contrib/completion/bash/docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/cli/contrib/completion/bash/docker b/components/cli/contrib/completion/bash/docker index 732750478a..05c0c7401a 100644 --- a/components/cli/contrib/completion/bash/docker +++ b/components/cli/contrib/completion/bash/docker @@ -570,7 +570,7 @@ __docker_append_to_completions() { # The result is cached for the duration of one invocation of bash completion. __docker_fetch_info() { if [ -z "$info_fetched" ] ; then - read -r client_experimental server_experimental server_os < <(__docker_q version -f '{{.Client.Experimental}} {{.Server.Experimental}} {{.Server.Os}}') + read -r client_experimental server_experimental server_os <<< "$(__docker_q version -f '{{.Client.Experimental}} {{.Server.Experimental}} {{.Server.Os}}')" info_fetched=true fi } From 8d1fd8dfed8a3463a2ebd15f2600397faefcbdeb Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 14 Nov 2018 11:28:16 +0000 Subject: [PATCH 24/28] Bump to gotest.tools v2.2.0 I would like to use the regex matcher Signed-off-by: Ian Campbell (cherry picked from commit 986196e3e34bd80c6ed61d2f291214fcb1795940) Signed-off-by: Sebastiaan van Stijn Upstream-commit: c1c3add698bd65c35aea700cc1e488a57f584b1e Component: cli --- components/cli/vendor.conf | 2 +- components/cli/vendor/gotest.tools/LICENSE | 209 +----------------- components/cli/vendor/gotest.tools/README.md | 2 +- .../vendor/gotest.tools/assert/cmp/compare.go | 48 +++- .../cli/vendor/gotest.tools/assert/result.go | 1 - components/cli/vendor/gotest.tools/env/env.go | 3 + components/cli/vendor/gotest.tools/fs/file.go | 14 +- .../cli/vendor/gotest.tools/fs/manifest.go | 9 +- components/cli/vendor/gotest.tools/fs/ops.go | 28 ++- components/cli/vendor/gotest.tools/fs/path.go | 9 + .../cli/vendor/gotest.tools/fs/report.go | 18 +- .../cli/vendor/gotest.tools/golden/golden.go | 2 +- .../cli/vendor/gotest.tools/icmd/command.go | 9 +- .../cli/vendor/gotest.tools/icmd/ops.go | 34 +++ .../gotest.tools/internal/difflib/difflib.go | 25 ++- .../gotest.tools/internal/source/defers.go | 53 +++++ .../gotest.tools/internal/source/source.go | 203 ++++++++--------- 17 files changed, 338 insertions(+), 331 deletions(-) create mode 100644 components/cli/vendor/gotest.tools/internal/source/defers.go diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 5b5f04a675..98f107955a 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -91,7 +91,7 @@ google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e google.golang.org/grpc v1.12.0 gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools v2.1.0 +gotest.tools v2.2.0 k8s.io/api kubernetes-1.11.2 k8s.io/apimachinery kubernetes-1.11.2 k8s.io/client-go kubernetes-1.11.2 diff --git a/components/cli/vendor/gotest.tools/LICENSE b/components/cli/vendor/gotest.tools/LICENSE index d645695673..aeaa2fac3d 100644 --- a/components/cli/vendor/gotest.tools/LICENSE +++ b/components/cli/vendor/gotest.tools/LICENSE @@ -1,202 +1,13 @@ +Copyright 2018 gotest.tools authors - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + http://www.apache.org/licenses/LICENSE-2.0 - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/components/cli/vendor/gotest.tools/README.md b/components/cli/vendor/gotest.tools/README.md index f5df204315..26a2026de2 100644 --- a/components/cli/vendor/gotest.tools/README.md +++ b/components/cli/vendor/gotest.tools/README.md @@ -3,7 +3,7 @@ A collection of packages to augment `testing` and support common patterns. [![GoDoc](https://godoc.org/gotest.tools?status.svg)](https://godoc.org/gotest.tools) -[![CircleCI](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master) +[![CircleCI](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master) [![Go Reportcard](https://goreportcard.com/badge/gotest.tools)](https://goreportcard.com/report/gotest.tools) diff --git a/components/cli/vendor/gotest.tools/assert/cmp/compare.go b/components/cli/vendor/gotest.tools/assert/cmp/compare.go index ae03749e20..cf48d887ac 100644 --- a/components/cli/vendor/gotest.tools/assert/cmp/compare.go +++ b/components/cli/vendor/gotest.tools/assert/cmp/compare.go @@ -4,6 +4,7 @@ package cmp // import "gotest.tools/assert/cmp" import ( "fmt" "reflect" + "regexp" "strings" "github.com/google/go-cmp/cmp" @@ -58,6 +59,39 @@ func toResult(success bool, msg string) Result { return ResultFailure(msg) } +// RegexOrPattern may be either a *regexp.Regexp or a string that is a valid +// regexp pattern. +type RegexOrPattern interface{} + +// Regexp succeeds if value v matches regular expression re. +// +// Example: +// assert.Assert(t, cmp.Regexp("^[0-9a-f]{32}$", str)) +// r := regexp.MustCompile("^[0-9a-f]{32}$") +// assert.Assert(t, cmp.Regexp(r, str)) +func Regexp(re RegexOrPattern, v string) Comparison { + match := func(re *regexp.Regexp) Result { + return toResult( + re.MatchString(v), + fmt.Sprintf("value %q does not match regexp %q", v, re.String())) + } + + return func() Result { + switch regex := re.(type) { + case *regexp.Regexp: + return match(regex) + case string: + re, err := regexp.Compile(regex) + if err != nil { + return ResultFailure(err.Error()) + } + return match(re) + default: + return ResultFailure(fmt.Sprintf("invalid type %T for regex pattern", regex)) + } + } +} + // Equal succeeds if x == y. See assert.Equal for full documentation. func Equal(x, y interface{}) Comparison { return func() Result { @@ -186,7 +220,7 @@ func Error(err error, message string) Comparison { return ResultFailure("expected an error, got nil") case err.Error() != message: return ResultFailure(fmt.Sprintf( - "expected error %q, got %+v", message, err)) + "expected error %q, got %s", message, formatErrorMessage(err))) } return ResultSuccess } @@ -201,12 +235,22 @@ func ErrorContains(err error, substring string) Comparison { return ResultFailure("expected an error, got nil") case !strings.Contains(err.Error(), substring): return ResultFailure(fmt.Sprintf( - "expected error to contain %q, got %+v", substring, err)) + "expected error to contain %q, got %s", substring, formatErrorMessage(err))) } return ResultSuccess } } +func formatErrorMessage(err error) string { + if _, ok := err.(interface { + Cause() error + }); ok { + return fmt.Sprintf("%q\n%+v", err, err) + } + // This error was not wrapped with github.com/pkg/errors + return fmt.Sprintf("%q", err) +} + // Nil succeeds if obj is a nil interface, pointer, or function. // // Use NilError() for comparing errors. Use Len(obj, 0) for comparing slices, diff --git a/components/cli/vendor/gotest.tools/assert/result.go b/components/cli/vendor/gotest.tools/assert/result.go index 3900264d0b..949d939619 100644 --- a/components/cli/vendor/gotest.tools/assert/result.go +++ b/components/cli/vendor/gotest.tools/assert/result.go @@ -70,7 +70,6 @@ func filterPrintableExpr(args []ast.Expr) []ast.Expr { result[i] = starExpr.X continue } - result[i] = nil } return result } diff --git a/components/cli/vendor/gotest.tools/env/env.go b/components/cli/vendor/gotest.tools/env/env.go index ed0f189916..609d90e996 100644 --- a/components/cli/vendor/gotest.tools/env/env.go +++ b/components/cli/vendor/gotest.tools/env/env.go @@ -79,6 +79,9 @@ func ToMap(env []string) map[string]string { } func getParts(raw string) (string, string) { + if raw == "" { + return "", "" + } // Environment variables on windows can begin with = // http://blogs.msdn.com/b/oldnewthing/archive/2010/05/06/10008132.aspx parts := strings.SplitN(raw[1:], "=", 2) diff --git a/components/cli/vendor/gotest.tools/fs/file.go b/components/cli/vendor/gotest.tools/fs/file.go index 8bf0188d2f..8322c8f444 100644 --- a/components/cli/vendor/gotest.tools/fs/file.go +++ b/components/cli/vendor/gotest.tools/fs/file.go @@ -7,6 +7,8 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" + "strings" "gotest.tools/assert" "gotest.tools/x/subtest" @@ -40,7 +42,7 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { if ht, ok := t.(helperT); ok { ht.Helper() } - tempfile, err := ioutil.TempFile("", prefix+"-") + tempfile, err := ioutil.TempFile("", cleanPrefix(prefix)+"-") assert.NilError(t, err) file := &File{path: tempfile.Name()} assert.NilError(t, tempfile.Close()) @@ -54,6 +56,14 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { return file } +func cleanPrefix(prefix string) string { + // windows requires both / and \ are replaced + if runtime.GOOS == "windows" { + prefix = strings.Replace(prefix, string(os.PathSeparator), "-", -1) + } + return strings.Replace(prefix, "/", "-", -1) +} + // Path returns the full path to the file func (f *File) Path() string { return f.path @@ -76,7 +86,7 @@ func NewDir(t assert.TestingT, prefix string, ops ...PathOp) *Dir { if ht, ok := t.(helperT); ok { ht.Helper() } - path, err := ioutil.TempDir("", prefix+"-") + path, err := ioutil.TempDir("", cleanPrefix(prefix)+"-") assert.NilError(t, err) dir := &Dir{path: path} diff --git a/components/cli/vendor/gotest.tools/fs/manifest.go b/components/cli/vendor/gotest.tools/fs/manifest.go index 00976ef19c..a98a70aaf4 100644 --- a/components/cli/vendor/gotest.tools/fs/manifest.go +++ b/components/cli/vendor/gotest.tools/fs/manifest.go @@ -24,7 +24,8 @@ type resource struct { type file struct { resource - content io.ReadCloser + content io.ReadCloser + ignoreCariageReturn bool } func (f *file) Type() string { @@ -113,6 +114,9 @@ func getTypedResource(path string, info os.FileInfo) (dirEntry, error) { func newSymlink(path string, info os.FileInfo) (*symlink, error) { target, err := os.Readlink(path) + if err != nil { + return nil, err + } return &symlink{ resource: newResourceFromInfo(info), target: target, @@ -122,6 +126,9 @@ func newSymlink(path string, info os.FileInfo) (*symlink, error) { func newFile(path string, info os.FileInfo) (*file, error) { // TODO: defer file opening to reduce number of open FDs? readCloser, err := os.Open(path) + if err != nil { + return nil, err + } return &file{ resource: newResourceFromInfo(info), content: readCloser, diff --git a/components/cli/vendor/gotest.tools/fs/ops.go b/components/cli/vendor/gotest.tools/fs/ops.go index ec9d11c110..a8d087c832 100644 --- a/components/cli/vendor/gotest.tools/fs/ops.go +++ b/components/cli/vendor/gotest.tools/fs/ops.go @@ -172,23 +172,35 @@ func copyDirectory(source, dest string) error { for _, entry := range entries { sourcePath := filepath.Join(source, entry.Name()) destPath := filepath.Join(dest, entry.Name()) - if entry.IsDir() { + switch { + case entry.IsDir(): if err := os.Mkdir(destPath, 0755); err != nil { return err } if err := copyDirectory(sourcePath, destPath); err != nil { return err } - continue - } - // TODO: handle symlinks - if err := copyFile(sourcePath, destPath); err != nil { - return err + case entry.Mode()&os.ModeSymlink != 0: + if err := copySymLink(sourcePath, destPath); err != nil { + return err + } + default: + if err := copyFile(sourcePath, destPath); err != nil { + return err + } } } return nil } +func copySymLink(source, dest string) error { + link, err := os.Readlink(source) + if err != nil { + return err + } + return os.Symlink(link, dest) +} + func copyFile(source, dest string) error { content, err := ioutil.ReadFile(source) if err != nil { @@ -219,7 +231,7 @@ func WithSymlink(path, target string) PathOp { func WithHardlink(path, target string) PathOp { return func(root Path) error { if _, ok := root.(manifestDirectory); ok { - return errors.New("WithHardlink yet implemented for manifests") + return errors.New("WithHardlink not implemented for manifests") } return os.Link(filepath.Join(root.Path(), target), filepath.Join(root.Path(), path)) } @@ -230,7 +242,7 @@ func WithHardlink(path, target string) PathOp { func WithTimestamps(atime, mtime time.Time) PathOp { return func(root Path) error { if _, ok := root.(manifestDirectory); ok { - return errors.New("WithTimestamp yet implemented for manifests") + return errors.New("WithTimestamp not implemented for manifests") } return os.Chtimes(root.Path(), atime, mtime) } diff --git a/components/cli/vendor/gotest.tools/fs/path.go b/components/cli/vendor/gotest.tools/fs/path.go index baf777f0df..8ffa0a0f82 100644 --- a/components/cli/vendor/gotest.tools/fs/path.go +++ b/components/cli/vendor/gotest.tools/fs/path.go @@ -127,6 +127,15 @@ func MatchAnyFileContent(path Path) error { return nil } +// MatchContentIgnoreCarriageReturn is a PathOp that ignores cariage return +// discrepancies. +func MatchContentIgnoreCarriageReturn(path Path) error { + if m, ok := path.(*filePath); ok { + m.file.ignoreCariageReturn = true + } + return nil +} + const anyFile = "*" // MatchExtraFiles is a PathOp that updates a Manifest to allow a directory diff --git a/components/cli/vendor/gotest.tools/fs/report.go b/components/cli/vendor/gotest.tools/fs/report.go index 4de85a6ef7..b85bb09a75 100644 --- a/components/cli/vendor/gotest.tools/fs/report.go +++ b/components/cli/vendor/gotest.tools/fs/report.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "sort" "strings" @@ -67,6 +68,11 @@ func eqResource(x, y resource) []problem { return p } +func removeCarriageReturn(in []byte) []byte { + return bytes.Replace(in, []byte("\r\n"), []byte("\n"), -1) +} + +// nolint: gocyclo func eqFile(x, y *file) []problem { p := eqResource(x.resource, y.resource) @@ -95,6 +101,10 @@ func eqFile(x, y *file) []problem { if xErr != nil || yErr != nil { return p } + if x.ignoreCariageReturn || y.ignoreCariageReturn { + xContent = removeCarriageReturn(xContent) + yContent = removeCarriageReturn(yContent) + } if !bytes.Equal(xContent, yContent) { p = append(p, diffContent(xContent, yContent)) @@ -126,7 +136,13 @@ func indent(s, prefix string) string { func eqSymlink(x, y *symlink) []problem { p := eqResource(x.resource, y.resource) - if x.target != y.target { + xTarget := x.target + yTarget := y.target + if runtime.GOOS == "windows" { + xTarget = strings.ToLower(xTarget) + yTarget = strings.ToLower(yTarget) + } + if xTarget != yTarget { p = append(p, notEqual("target", x.target, y.target)) } return p diff --git a/components/cli/vendor/gotest.tools/golden/golden.go b/components/cli/vendor/gotest.tools/golden/golden.go index 1804b65931..7264529900 100644 --- a/components/cli/vendor/gotest.tools/golden/golden.go +++ b/components/cli/vendor/gotest.tools/golden/golden.go @@ -98,7 +98,7 @@ func String(actual string, filename string) cmp.Comparison { // AssertBytes compares the actual result to the expected result in the golden // file. If the `-test.update-golden` flag is set then the actual content is // written to the golden file. -// Returns whether the assertion was successful (true) or not (false) +// Returns whether the assertion was successful (true) or not (false). // This is equivalent to assert.Check(t, Bytes(actual, filename)) func AssertBytes( t assert.TestingT, diff --git a/components/cli/vendor/gotest.tools/icmd/command.go b/components/cli/vendor/gotest.tools/icmd/command.go index 901895991a..e931ccb928 100644 --- a/components/cli/vendor/gotest.tools/icmd/command.go +++ b/components/cli/vendor/gotest.tools/icmd/command.go @@ -132,18 +132,21 @@ func (r *Result) String() string { if r.Timeout { timeout = " (timeout)" } + var errString string + if r.Error != nil { + errString = "\nError: " + r.Error.Error() + } return fmt.Sprintf(` Command: %s -ExitCode: %d%s -Error: %v +ExitCode: %d%s%s Stdout: %v Stderr: %v `, strings.Join(r.Cmd.Args, " "), r.ExitCode, timeout, - r.Error, + errString, r.Stdout(), r.Stderr()) } diff --git a/components/cli/vendor/gotest.tools/icmd/ops.go b/components/cli/vendor/gotest.tools/icmd/ops.go index 02b1d84023..18176eead3 100644 --- a/components/cli/vendor/gotest.tools/icmd/ops.go +++ b/components/cli/vendor/gotest.tools/icmd/ops.go @@ -1,4 +1,38 @@ package icmd +import ( + "io" + "time" +) + // CmdOp is an operation which modified a Cmd structure used to execute commands type CmdOp func(*Cmd) + +// WithTimeout sets the timeout duration of the command +func WithTimeout(timeout time.Duration) CmdOp { + return func(c *Cmd) { + c.Timeout = timeout + } +} + +// WithEnv sets the environment variable of the command. +// Each arguments are in the form of KEY=VALUE +func WithEnv(env ...string) CmdOp { + return func(c *Cmd) { + c.Env = env + } +} + +// Dir sets the working directory of the command +func Dir(path string) CmdOp { + return func(c *Cmd) { + c.Dir = path + } +} + +// WithStdin sets the standard input of the command to the specified reader +func WithStdin(r io.Reader) CmdOp { + return func(c *Cmd) { + c.Stdin = r + } +} diff --git a/components/cli/vendor/gotest.tools/internal/difflib/difflib.go b/components/cli/vendor/gotest.tools/internal/difflib/difflib.go index 5efa99c1d4..b6f486b9c9 100644 --- a/components/cli/vendor/gotest.tools/internal/difflib/difflib.go +++ b/components/cli/vendor/gotest.tools/internal/difflib/difflib.go @@ -1,4 +1,4 @@ -/* Package difflib is a partial port of Python difflib module. +/*Package difflib is a partial port of Python difflib module. Original source: https://github.com/pmezard/go-difflib @@ -20,12 +20,14 @@ func max(a, b int) int { return b } +// Match stores line numbers of size of match type Match struct { A int B int Size int } +// OpCode identifies the type of diff type OpCode struct { Tag byte I1 int @@ -73,19 +75,20 @@ type SequenceMatcher struct { opCodes []OpCode } +// NewMatcher returns a new SequenceMatcher func NewMatcher(a, b []string) *SequenceMatcher { m := SequenceMatcher{autoJunk: true} m.SetSeqs(a, b) return &m } -// Set two sequences to be compared. +// SetSeqs sets two sequences to be compared. func (m *SequenceMatcher) SetSeqs(a, b []string) { m.SetSeq1(a) m.SetSeq2(b) } -// Set the first sequence to be compared. The second sequence to be compared is +// SetSeq1 sets the first sequence to be compared. The second sequence to be compared is // not changed. // // SequenceMatcher computes and caches detailed information about the second @@ -103,7 +106,7 @@ func (m *SequenceMatcher) SetSeq1(a []string) { m.opCodes = nil } -// Set the second sequence to be compared. The first sequence to be compared is +// SetSeq2 sets the second sequence to be compared. The first sequence to be compared is // not changed. func (m *SequenceMatcher) SetSeq2(b []string) { if &b == &m.b { @@ -129,12 +132,12 @@ func (m *SequenceMatcher) chainB() { m.bJunk = map[string]struct{}{} if m.IsJunk != nil { junk := m.bJunk - for s, _ := range b2j { + for s := range b2j { if m.IsJunk(s) { junk[s] = struct{}{} } } - for s, _ := range junk { + for s := range junk { delete(b2j, s) } } @@ -149,7 +152,7 @@ func (m *SequenceMatcher) chainB() { popular[s] = struct{}{} } } - for s, _ := range popular { + for s := range popular { delete(b2j, s) } } @@ -259,7 +262,7 @@ func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { return Match{A: besti, B: bestj, Size: bestsize} } -// Return list of triples describing matching subsequences. +// GetMatchingBlocks returns a list of triples describing matching subsequences. // // Each triple is of the form (i, j, n), and means that // a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in @@ -323,7 +326,7 @@ func (m *SequenceMatcher) GetMatchingBlocks() []Match { return m.matchingBlocks } -// Return list of 5-tuples describing how to turn a into b. +// GetOpCodes returns a list of 5-tuples describing how to turn a into b. // // Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple // has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the @@ -374,7 +377,7 @@ func (m *SequenceMatcher) GetOpCodes() []OpCode { return m.opCodes } -// Isolate change clusters by eliminating ranges with no changes. +// GetGroupedOpCodes isolates change clusters by eliminating ranges with no changes. // // Return a generator of groups with up to n lines of context. // Each group is in the same format as returned by GetOpCodes(). @@ -384,7 +387,7 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { } codes := m.GetOpCodes() if len(codes) == 0 { - codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} + codes = []OpCode{{'e', 0, 1, 0, 1}} } // Fixup leading and trailing groups if they show no changes. if codes[0].Tag == 'e' { diff --git a/components/cli/vendor/gotest.tools/internal/source/defers.go b/components/cli/vendor/gotest.tools/internal/source/defers.go new file mode 100644 index 0000000000..66cfafbb64 --- /dev/null +++ b/components/cli/vendor/gotest.tools/internal/source/defers.go @@ -0,0 +1,53 @@ +package source + +import ( + "go/ast" + "go/token" + + "github.com/pkg/errors" +) + +func scanToDeferLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { + var matchedNode ast.Node + ast.Inspect(node, func(node ast.Node) bool { + switch { + case node == nil || matchedNode != nil: + return false + case fileset.Position(node.End()).Line == lineNum: + if funcLit, ok := node.(*ast.FuncLit); ok { + matchedNode = funcLit + return false + } + } + return true + }) + debug("defer line node: %s", debugFormatNode{matchedNode}) + return matchedNode +} + +func guessDefer(node ast.Node) (ast.Node, error) { + defers := collectDefers(node) + switch len(defers) { + case 0: + return nil, errors.New("failed to expression in defer") + case 1: + return defers[0].Call, nil + default: + return nil, errors.Errorf( + "ambiguous call expression: multiple (%d) defers in call block", + len(defers)) + } +} + +func collectDefers(node ast.Node) []*ast.DeferStmt { + var defers []*ast.DeferStmt + ast.Inspect(node, func(node ast.Node) bool { + if d, ok := node.(*ast.DeferStmt); ok { + defers = append(defers, d) + debug("defer: %s", debugFormatNode{d}) + return false + } + return true + }) + return defers +} diff --git a/components/cli/vendor/gotest.tools/internal/source/source.go b/components/cli/vendor/gotest.tools/internal/source/source.go index a05933cc33..8a5d0e8d35 100644 --- a/components/cli/vendor/gotest.tools/internal/source/source.go +++ b/components/cli/vendor/gotest.tools/internal/source/source.go @@ -24,106 +24,12 @@ func FormattedCallExprArg(stackIndex int, argPos int) (string, error) { if err != nil { return "", err } + if argPos >= len(args) { + return "", errors.New("failed to find expression") + } return FormatNode(args[argPos]) } -func getNodeAtLine(filename string, lineNum int) (ast.Node, error) { - fileset := token.NewFileSet() - astFile, err := parser.ParseFile(fileset, filename, nil, parser.AllErrors) - if err != nil { - return nil, errors.Wrapf(err, "failed to parse source file: %s", filename) - } - - node := scanToLine(fileset, astFile, lineNum) - if node == nil { - return nil, errors.Errorf( - "failed to find an expression on line %d in %s", lineNum, filename) - } - return node, nil -} - -func scanToLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { - v := &scanToLineVisitor{lineNum: lineNum, fileset: fileset} - ast.Walk(v, node) - return v.matchedNode -} - -type scanToLineVisitor struct { - lineNum int - matchedNode ast.Node - fileset *token.FileSet -} - -func (v *scanToLineVisitor) Visit(node ast.Node) ast.Visitor { - if node == nil || v.matchedNode != nil { - return nil - } - if v.nodePosition(node).Line == v.lineNum { - v.matchedNode = node - return nil - } - return v -} - -// In golang 1.9 the line number changed from being the line where the statement -// ended to the line where the statement began. -func (v *scanToLineVisitor) nodePosition(node ast.Node) token.Position { - if goVersionBefore19 { - return v.fileset.Position(node.End()) - } - return v.fileset.Position(node.Pos()) -} - -var goVersionBefore19 = isGOVersionBefore19() - -func isGOVersionBefore19() bool { - version := runtime.Version() - // not a release version - if !strings.HasPrefix(version, "go") { - return false - } - version = strings.TrimPrefix(version, "go") - parts := strings.Split(version, ".") - if len(parts) < 2 { - return false - } - minor, err := strconv.ParseInt(parts[1], 10, 32) - return err == nil && parts[0] == "1" && minor < 9 -} - -func getCallExprArgs(node ast.Node) ([]ast.Expr, error) { - visitor := &callExprVisitor{} - ast.Walk(visitor, node) - if visitor.expr == nil { - return nil, errors.New("failed to find call expression") - } - return visitor.expr.Args, nil -} - -type callExprVisitor struct { - expr *ast.CallExpr -} - -func (v *callExprVisitor) Visit(node ast.Node) ast.Visitor { - if v.expr != nil || node == nil { - return nil - } - debug("visit (%T): %s", node, debugFormatNode{node}) - - if callExpr, ok := node.(*ast.CallExpr); ok { - v.expr = callExpr - return nil - } - return v -} - -// FormatNode using go/format.Node and return the result as a string -func FormatNode(node ast.Node) (string, error) { - buf := new(bytes.Buffer) - err := format.Node(buf, token.NewFileSet(), node) - return buf.String(), err -} - // CallExprArgs returns the ast.Expr slice for the args of an ast.CallExpr at // the index in the call stack. func CallExprArgs(stackIndex int) ([]ast.Expr, error) { @@ -137,12 +43,109 @@ func CallExprArgs(stackIndex int) ([]ast.Expr, error) { if err != nil { return nil, err } - debug("found node (%T): %s", node, debugFormatNode{node}) + debug("found node: %s", debugFormatNode{node}) return getCallExprArgs(node) } -var debugEnabled = os.Getenv("GOTESTYOURSELF_DEBUG") != "" +func getNodeAtLine(filename string, lineNum int) (ast.Node, error) { + fileset := token.NewFileSet() + astFile, err := parser.ParseFile(fileset, filename, nil, parser.AllErrors) + if err != nil { + return nil, errors.Wrapf(err, "failed to parse source file: %s", filename) + } + + if node := scanToLine(fileset, astFile, lineNum); node != nil { + return node, nil + } + if node := scanToDeferLine(fileset, astFile, lineNum); node != nil { + node, err := guessDefer(node) + if err != nil || node != nil { + return node, err + } + } + return nil, errors.Errorf( + "failed to find an expression on line %d in %s", lineNum, filename) +} + +func scanToLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { + var matchedNode ast.Node + ast.Inspect(node, func(node ast.Node) bool { + switch { + case node == nil || matchedNode != nil: + return false + case nodePosition(fileset, node).Line == lineNum: + matchedNode = node + return false + } + return true + }) + return matchedNode +} + +// In golang 1.9 the line number changed from being the line where the statement +// ended to the line where the statement began. +func nodePosition(fileset *token.FileSet, node ast.Node) token.Position { + if goVersionBefore19 { + return fileset.Position(node.End()) + } + return fileset.Position(node.Pos()) +} + +var goVersionBefore19 = func() bool { + version := runtime.Version() + // not a release version + if !strings.HasPrefix(version, "go") { + return false + } + version = strings.TrimPrefix(version, "go") + parts := strings.Split(version, ".") + if len(parts) < 2 { + return false + } + minor, err := strconv.ParseInt(parts[1], 10, 32) + return err == nil && parts[0] == "1" && minor < 9 +}() + +func getCallExprArgs(node ast.Node) ([]ast.Expr, error) { + visitor := &callExprVisitor{} + ast.Walk(visitor, node) + if visitor.expr == nil { + return nil, errors.New("failed to find call expression") + } + debug("callExpr: %s", debugFormatNode{visitor.expr}) + return visitor.expr.Args, nil +} + +type callExprVisitor struct { + expr *ast.CallExpr +} + +func (v *callExprVisitor) Visit(node ast.Node) ast.Visitor { + if v.expr != nil || node == nil { + return nil + } + debug("visit: %s", debugFormatNode{node}) + + switch typed := node.(type) { + case *ast.CallExpr: + v.expr = typed + return nil + case *ast.DeferStmt: + ast.Walk(v, typed.Call.Fun) + return nil + } + return v +} + +// FormatNode using go/format.Node and return the result as a string +func FormatNode(node ast.Node) (string, error) { + buf := new(bytes.Buffer) + err := format.Node(buf, token.NewFileSet(), node) + return buf.String(), err +} + +var debugEnabled = os.Getenv("GOTESTTOOLS_DEBUG") != "" func debug(format string, args ...interface{}) { if debugEnabled { @@ -159,5 +162,5 @@ func (n debugFormatNode) String() string { if err != nil { return fmt.Sprintf("failed to format %s: %s", n.Node, err) } - return out + return fmt.Sprintf("(%T) %s", n.Node, out) } From a77c898b5dd72cc862bd2480f863481804f4d0da Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 20 Jun 2019 16:30:39 +0200 Subject: [PATCH 25/28] Reformat vendor.conf and pin all deps by git-sha To make it better readable, and to encourage pinning by sha, but "align" to a tagged release. similar to 6026ce4a8bf0f8ff4ec89c1165d57858a0088eb7 (#1822) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 1764ffafca6986e2de93eb3b627757a3a11bdecf Component: cli --- components/cli/vendor.conf | 197 ++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 100 deletions(-) diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 98f107955a..4a3693536d 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -1,100 +1,97 @@ -github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 -github.com/asaskevich/govalidator f9ffefc3facfbe0caee3fea233cbb6e8208f4541 -github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 -github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceafb -github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 -github.com/containerd/containerd bb0f83ab6eec47c3316bb763d5c20a82c7750c31 -github.com/containerd/continuity d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371 -github.com/containerd/fifo 3d5202a -github.com/containerd/typeurl f694355 -github.com/coreos/etcd v3.3.9 -github.com/cpuguy83/go-md2man v1.0.8 -github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0 -github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae93629a1530af -github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5 -github.com/docker/docker 200b524eff60a9c95a22bc2518042ac2ff617d07 https://github.com/docker/engine # 18.09 branch -github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962 -# the docker/go package contains a customized version of canonical/json -# and is used by Notary. The package is periodically rebased on current Go versions. -github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 -github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0 -github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 -github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 -github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 -github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a -github.com/docker/licensing 9781369abdb5281cdc07a2a446c6df01347ec793 -github.com/docker/swarmkit cfa742c8abe6f8e922f6e4e920153c408e7d9c3b -github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff -github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 # v1.0.0 -github.com/gogo/googleapis b23578765ee54ff6bceff57f397d833bf4ca6869 -github.com/gogo/protobuf v1.1.1 -github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 -github.com/golang/protobuf v1.1.0 -github.com/google/btree e89373fe6b4a7413d7acd6da1725b83ef713e6e4 -github.com/google/go-cmp v0.2.0 -github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1 -github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 -github.com/google/uuid v1.1.1 -github.com/googleapis/gnostic 7c663266750e7d82587642f65e60bc4083f1f84e # v0.2.0 -github.com/gorilla/context v1.1.1 -github.com/gorilla/mux v1.6.2 -github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 -github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b -github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 -github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 -github.com/hashicorp/go-version 23480c0 -github.com/imdario/mergo v0.3.6 -github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0 -github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 -github.com/mattn/go-shellwords v1.0.3 -github.com/matttproud/golang_protobuf_extensions v1.0.1 -github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 -github.com/Microsoft/go-winio v0.4.10 -github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed -github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac -github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 -github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 -github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 -github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b -github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty -github.com/opencontainers/go-digest v1.0.0-rc1 -github.com/opencontainers/image-spec v1.0.1 -github.com/opencontainers/runc 20aff4f0488c6d4b8df4d85b4f63f1f704c11abd -github.com/opencontainers/runtime-spec v1.0.1 -github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 -github.com/peterbourgon/diskv 5f041e8faa004a95c88a202771f4cc3e991971e6 # v2.0.1 -github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 -github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e -github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 -github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 -github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 -github.com/russross/blackfriday 1d6b8e9301e720b08a8938b8c25c018285885438 -github.com/shurcooL/sanitized_anchor_name 10ef21a441db47d8b13ebcc5fd2310f636973c77 -github.com/sirupsen/logrus v1.0.6 -github.com/spf13/cobra v0.0.3 -# temporary fork with https://github.com/spf13/pflag/pull/170 applied, which isn't merged yet upstream -github.com/spf13/pflag 4cb166e4f25ac4e8016a3595bbf7ea2e9aa85a2c https://github.com/thaJeztah/pflag.git -github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 -github.com/theupdateframework/notary v0.6.1 -github.com/tonistiigi/fsutil 2862f6bc5ac9b97124e552a5c108230b38a1b0ca -github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 -github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6 -github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b -github.com/xeipuuv/gojsonschema 93e72a773fade158921402d6a24c819b48aba29d -golang.org/x/crypto 0709b304e793a5edb4a2c0145f281ecdc20838a4 -golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1 -golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca -golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 -golang.org/x/text f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0 -golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650 -google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e -google.golang.org/grpc v1.12.0 -gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 -gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools v2.2.0 -k8s.io/api kubernetes-1.11.2 -k8s.io/apimachinery kubernetes-1.11.2 -k8s.io/client-go kubernetes-1.11.2 -k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb -k8s.io/kubernetes v1.11.2 -vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 +github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 +github.com/asaskevich/govalidator f9ffefc3facfbe0caee3fea233cbb6e8208f4541 +github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 +github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceafb +github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 +github.com/containerd/containerd bb0f83ab6eec47c3316bb763d5c20a82c7750c31 +github.com/containerd/continuity d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371 +github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c +github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 +github.com/coreos/etcd fca8add78a9d926166eb739b8e4a124434025ba3 # v3.3.9 +github.com/cpuguy83/go-md2man 20f5889cbdc3c73dbd2862796665e7c465ade7d1 # v1.0.8 +github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0 +github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae93629a1530af +github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5 +github.com/docker/docker 200b524eff60a9c95a22bc2518042ac2ff617d07 https://github.com/docker/engine # 18.09 branch +github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962 +github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 # Contains a customized version of canonical/json and is used by Notary. The package is periodically rebased on current Go versions. +github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0 +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 +github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 +github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 +github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a +github.com/docker/licensing 9781369abdb5281cdc07a2a446c6df01347ec793 +github.com/docker/swarmkit cfa742c8abe6f8e922f6e4e920153c408e7d9c3b +github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff +github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 # v1.0.0 +github.com/gogo/googleapis b23578765ee54ff6bceff57f397d833bf4ca6869 +github.com/gogo/protobuf 636bf0302bc95575d69441b25a2603156ffdddf1 # v1.1.1 +github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 +github.com/golang/protobuf b4deda0973fb4c70b50d226b1af49f3da59f5265 # v1.1.0 +github.com/google/btree e89373fe6b4a7413d7acd6da1725b83ef713e6e4 +github.com/google/go-cmp 3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0 +github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1 +github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 +github.com/google/uuid 0cd6bf5da1e1c83f8b45653022c74f71af0538a4 # v1.1.1 +github.com/googleapis/gnostic 7c663266750e7d82587642f65e60bc4083f1f84e # v0.2.0 +github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 # v1.1.1 +github.com/gorilla/mux e3702bed27f0d39777b0b37b664b6280e8ef8fbf # v1.6.2 +github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 +github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b +github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 +github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 +github.com/hashicorp/go-version 23480c0665776210b5fbbac6eaaee40e3e6a96b7 +github.com/imdario/mergo 9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4 # v0.3.6 +github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0.0 +github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 +github.com/mattn/go-shellwords 02e3cf038dcea8290e44424da473dd12be796a8a # v1.0.3 +github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1 +github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 +github.com/Microsoft/go-winio 78a084671df137c2acfcacaa730d7e7dc285ac39 # v0.4.10 +github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed +github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac +github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 +github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 +github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 +github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b +github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty +github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf # v1.0.0-rc1 +github.com/opencontainers/image-spec d60099175f88c47cd379c4738d158884749ed235 # v1.0.1 +github.com/opencontainers/runc 20aff4f0488c6d4b8df4d85b4f63f1f704c11abd +github.com/opencontainers/runtime-spec 4e3b9264a330d094b0386c3703c5f379119711e8 # v1.0.1 +github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 +github.com/peterbourgon/diskv 5f041e8faa004a95c88a202771f4cc3e991971e6 # v2.0.1 +github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 +github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e +github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 +github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 +github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 +github.com/russross/blackfriday 1d6b8e9301e720b08a8938b8c25c018285885438 +github.com/shurcooL/sanitized_anchor_name 10ef21a441db47d8b13ebcc5fd2310f636973c77 +github.com/sirupsen/logrus 3e01752db0189b9157070a0e1668a620f9a85da2 # v1.0.6 +github.com/spf13/cobra ef82de70bb3f60c65fb8eebacbb2d122ef517385 # v0.0.3 +github.com/spf13/pflag 4cb166e4f25ac4e8016a3595bbf7ea2e9aa85a2c https://github.com/thaJeztah/pflag.git # temporary fork with https://github.com/spf13/pflag/pull/170 applied, which isn't merged yet upstream +github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 +github.com/theupdateframework/notary d6e1431feb32348e0650bf7551ac5cffd01d857b # v0.6.1 +github.com/tonistiigi/fsutil 2862f6bc5ac9b97124e552a5c108230b38a1b0ca +github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 +github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6 +github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b +github.com/xeipuuv/gojsonschema 93e72a773fade158921402d6a24c819b48aba29d +golang.org/x/crypto 0709b304e793a5edb4a2c0145f281ecdc20838a4 +golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1 +golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca +golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 +golang.org/x/text f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0 +golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650 +google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e +google.golang.org/grpc 41344da2231b913fa3d983840a57a6b1b7b631a1 # v1.12.0 +gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 +gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 +gotest.tools 7c797b5133e5460410dbb22ba779bf35e6975dea # v2.2.0 +k8s.io/api 2d6f90ab1293a1fb871cf149423ebb72aa7423aa # kubernetes-1.11.2 +k8s.io/apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae # kubernetes-1.11.2 +k8s.io/client-go 1f13a808da65775f22cbf47862c4e5898d8f4ca1 # kubernetes-1.11.2 +k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb +k8s.io/kubernetes bb9ffb1654d4a729bb4cec18ff088eacc153c239 # v1.11.2 +vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 From 59f528c71726009ccecaf2b3af7a555e19f976fc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 20 Jun 2019 16:44:18 +0200 Subject: [PATCH 26/28] Sort vendor.conf alphabetically Signed-off-by: Sebastiaan van Stijn Upstream-commit: 773a91f9e95b669e1e48b4d19ff5369c7f0dad2c Component: cli --- components/cli/vendor.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 4a3693536d..5e9cdeffdc 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -39,15 +39,15 @@ github.com/gorilla/mux e3702bed27f0d39777b0b37b664b github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 -github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 github.com/hashicorp/go-version 23480c0665776210b5fbbac6eaaee40e3e6a96b7 +github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 github.com/imdario/mergo 9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4 # v0.3.6 github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0.0 github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 github.com/mattn/go-shellwords 02e3cf038dcea8290e44424da473dd12be796a8a # v1.0.3 github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1 -github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 github.com/Microsoft/go-winio 78a084671df137c2acfcacaa730d7e7dc285ac39 # v0.4.10 +github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 From f3bbdf63ec9b11d4bee6a01f9ada052b9a8066d6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 13 Apr 2019 01:47:37 +0200 Subject: [PATCH 27/28] bump gotest.tools v2.3.0 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c8d685457b3adf36fe52147b9a5629b32fe7637d) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 32c4d8c40fae3cd229eaf6ed08139c45d0692625 Component: cli --- components/cli/vendor.conf | 2 +- components/cli/vendor/gotest.tools/README.md | 4 ++ .../vendor/gotest.tools/assert/cmp/result.go | 20 +++--- components/cli/vendor/gotest.tools/fs/file.go | 10 +-- .../cli/vendor/gotest.tools/fs/manifest.go | 9 ++- components/cli/vendor/gotest.tools/fs/ops.go | 9 +++ components/cli/vendor/gotest.tools/fs/path.go | 43 ++++++++++++- .../cli/vendor/gotest.tools/fs/report.go | 62 ++++++++++++++++--- .../cli/vendor/gotest.tools/poll/check.go | 39 ++++++++++++ .../cli/vendor/gotest.tools/poll/poll.go | 2 +- .../cli/vendor/gotest.tools/skip/skip.go | 28 +++++++-- 11 files changed, 193 insertions(+), 35 deletions(-) create mode 100644 components/cli/vendor/gotest.tools/poll/check.go diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 5e9cdeffdc..6158134b41 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -88,7 +88,7 @@ google.golang.org/genproto 02b4e95473316948020af0b7a4f0 google.golang.org/grpc 41344da2231b913fa3d983840a57a6b1b7b631a1 # v1.12.0 gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools 7c797b5133e5460410dbb22ba779bf35e6975dea # v2.2.0 +gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0 k8s.io/api 2d6f90ab1293a1fb871cf149423ebb72aa7423aa # kubernetes-1.11.2 k8s.io/apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae # kubernetes-1.11.2 k8s.io/client-go 1f13a808da65775f22cbf47862c4e5898d8f4ca1 # kubernetes-1.11.2 diff --git a/components/cli/vendor/gotest.tools/README.md b/components/cli/vendor/gotest.tools/README.md index 26a2026de2..3155723dd7 100644 --- a/components/cli/vendor/gotest.tools/README.md +++ b/components/cli/vendor/gotest.tools/README.md @@ -29,3 +29,7 @@ A collection of packages to augment `testing` and support common patterns. * [gotest.tools/gotestsum](https://github.com/gotestyourself/gotestsum) - go test runner with custom output * [maxbrunsfeld/counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) - generate fakes for interfaces * [jonboulle/clockwork](https://github.com/jonboulle/clockwork) - a fake clock for testing code that uses `time` + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/components/cli/vendor/gotest.tools/assert/cmp/result.go b/components/cli/vendor/gotest.tools/assert/cmp/result.go index 7c3c37dd72..204edda4bc 100644 --- a/components/cli/vendor/gotest.tools/assert/cmp/result.go +++ b/components/cli/vendor/gotest.tools/assert/cmp/result.go @@ -9,31 +9,37 @@ import ( "gotest.tools/internal/source" ) -// Result of a Comparison. +// A Result of a Comparison. type Result interface { Success() bool } -type result struct { +// StringResult is an implementation of Result that reports the error message +// string verbatim and does not provide any templating or formatting of the +// message. +type StringResult struct { success bool message string } -func (r result) Success() bool { +// Success returns true if the comparison was successful. +func (r StringResult) Success() bool { return r.success } -func (r result) FailureMessage() string { +// FailureMessage returns the message used to provide additional information +// about the failure. +func (r StringResult) FailureMessage() string { return r.message } // ResultSuccess is a constant which is returned by a ComparisonWithResult to // indicate success. -var ResultSuccess = result{success: true} +var ResultSuccess = StringResult{success: true} // ResultFailure returns a failed Result with a failure message. -func ResultFailure(message string) Result { - return result{message: message} +func ResultFailure(message string) StringResult { + return StringResult{message: message} } // ResultFromError returns ResultSuccess if err is nil. Otherwise ResultFailure diff --git a/components/cli/vendor/gotest.tools/fs/file.go b/components/cli/vendor/gotest.tools/fs/file.go index 8322c8f444..7d0cab363b 100644 --- a/components/cli/vendor/gotest.tools/fs/file.go +++ b/components/cli/vendor/gotest.tools/fs/file.go @@ -46,10 +46,7 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { assert.NilError(t, err) file := &File{path: tempfile.Name()} assert.NilError(t, tempfile.Close()) - - for _, op := range ops { - assert.NilError(t, op(file)) - } + assert.NilError(t, applyPathOps(file, ops)) if tc, ok := t.(subtest.TestContext); ok { tc.AddCleanup(file.Remove) } @@ -89,10 +86,7 @@ func NewDir(t assert.TestingT, prefix string, ops ...PathOp) *Dir { path, err := ioutil.TempDir("", cleanPrefix(prefix)+"-") assert.NilError(t, err) dir := &Dir{path: path} - - for _, op := range ops { - assert.NilError(t, op(dir)) - } + assert.NilError(t, applyPathOps(dir, ops)) if tc, ok := t.(subtest.TestContext); ok { tc.AddCleanup(dir.Remove) } diff --git a/components/cli/vendor/gotest.tools/fs/manifest.go b/components/cli/vendor/gotest.tools/fs/manifest.go index a98a70aaf4..e5e693e6c5 100644 --- a/components/cli/vendor/gotest.tools/fs/manifest.go +++ b/components/cli/vendor/gotest.tools/fs/manifest.go @@ -26,6 +26,7 @@ type file struct { resource content io.ReadCloser ignoreCariageReturn bool + compareContentFunc func(b []byte) CompareResult } func (f *file) Type() string { @@ -43,7 +44,8 @@ func (f *symlink) Type() string { type directory struct { resource - items map[string]dirEntry + items map[string]dirEntry + filepathGlobs map[string]*filePath } func (f *directory) Type() string { @@ -95,8 +97,9 @@ func newDirectory(path string, info os.FileInfo) (*directory, error) { } return &directory{ - resource: newResourceFromInfo(info), - items: items, + resource: newResourceFromInfo(info), + items: items, + filepathGlobs: make(map[string]*filePath), }, nil } diff --git a/components/cli/vendor/gotest.tools/fs/ops.go b/components/cli/vendor/gotest.tools/fs/ops.go index a8d087c832..c3c33587b6 100644 --- a/components/cli/vendor/gotest.tools/fs/ops.go +++ b/components/cli/vendor/gotest.tools/fs/ops.go @@ -10,6 +10,7 @@ import ( "time" "github.com/pkg/errors" + "gotest.tools/assert" ) const defaultFileMode = 0644 @@ -144,6 +145,14 @@ func WithDir(name string, ops ...PathOp) PathOp { } } +// Apply the PathOps to the File +func Apply(t assert.TestingT, path Path, ops ...PathOp) { + if ht, ok := t.(helperT); ok { + ht.Helper() + } + assert.NilError(t, applyPathOps(path, ops)) +} + func applyPathOps(path Path, ops []PathOp) error { for _, op := range ops { if err := op(path); err != nil { diff --git a/components/cli/vendor/gotest.tools/fs/path.go b/components/cli/vendor/gotest.tools/fs/path.go index 8ffa0a0f82..4bb38774bc 100644 --- a/components/cli/vendor/gotest.tools/fs/path.go +++ b/components/cli/vendor/gotest.tools/fs/path.go @@ -64,6 +64,13 @@ func (p *directoryPath) AddFile(path string, ops ...PathOp) error { return applyPathOps(exp, ops) } +func (p *directoryPath) AddGlobFiles(glob string, ops ...PathOp) error { + newFile := &file{resource: newResource(0)} + newFilePath := &filePath{file: newFile} + p.directory.filepathGlobs[glob] = newFilePath + return applyPathOps(newFilePath, ops) +} + func (p *directoryPath) AddDirectory(path string, ops ...PathOp) error { newDir := newDirectoryWithDefaults() p.directory.items[path] = newDir @@ -87,8 +94,9 @@ func Expected(t assert.TestingT, ops ...PathOp) Manifest { func newDirectoryWithDefaults() *directory { return &directory{ - resource: newResource(defaultRootDirMode), - items: make(map[string]dirEntry), + resource: newResource(defaultRootDirMode), + items: make(map[string]dirEntry), + filepathGlobs: make(map[string]*filePath), } } @@ -147,6 +155,37 @@ func MatchExtraFiles(path Path) error { return nil } +// CompareResult is the result of comparison. +// +// See gotest.tools/assert/cmp.StringResult for a convenient implementation of +// this interface. +type CompareResult interface { + Success() bool + FailureMessage() string +} + +// MatchFileContent is a PathOp that updates a Manifest to use the provided +// function to determine if a file's content matches the expectation. +func MatchFileContent(f func([]byte) CompareResult) PathOp { + return func(path Path) error { + if m, ok := path.(*filePath); ok { + m.file.compareContentFunc = f + } + return nil + } +} + +// MatchFilesWithGlob is a PathOp that updates a Manifest to match files using +// glob pattern, and check them using the ops. +func MatchFilesWithGlob(glob string, ops ...PathOp) PathOp { + return func(path Path) error { + if m, ok := path.(*directoryPath); ok { + m.AddGlobFiles(glob, ops...) + } + return nil + } +} + // anyFileMode is represented by uint32_max const anyFileMode os.FileMode = 4294967295 diff --git a/components/cli/vendor/gotest.tools/fs/report.go b/components/cli/vendor/gotest.tools/fs/report.go index b85bb09a75..adc5a5f1bc 100644 --- a/components/cli/vendor/gotest.tools/fs/report.go +++ b/components/cli/vendor/gotest.tools/fs/report.go @@ -101,6 +101,15 @@ func eqFile(x, y *file) []problem { if xErr != nil || yErr != nil { return p } + + if x.compareContentFunc != nil { + r := x.compareContentFunc(yContent) + if !r.Success() { + p = append(p, existenceProblem("content", r.FailureMessage())) + } + return p + } + if x.ignoreCariageReturn || y.ignoreCariageReturn { xContent = removeCarriageReturn(xContent) yContent = removeCarriageReturn(yContent) @@ -151,11 +160,13 @@ func eqSymlink(x, y *symlink) []problem { func eqDirectory(path string, x, y *directory) []failure { p := eqResource(x.resource, y.resource) var f []failure + matchedFiles := make(map[string]bool) for _, name := range sortedKeys(x.items) { if name == anyFile { continue } + matchedFiles[name] = true xEntry := x.items[name] yEntry, ok := y.items[name] if !ok { @@ -171,19 +182,30 @@ func eqDirectory(path string, x, y *directory) []failure { f = append(f, eqEntry(filepath.Join(path, name), xEntry, yEntry)...) } - if _, ok := x.items[anyFile]; !ok { + if len(x.filepathGlobs) != 0 { for _, name := range sortedKeys(y.items) { - if _, ok := x.items[name]; !ok { - yEntry := y.items[name] - p = append(p, existenceProblem(name, "unexpected %s", yEntry.Type())) - } + m := matchGlob(name, y.items[name], x.filepathGlobs) + matchedFiles[name] = m.match + f = append(f, m.failures...) } } - if len(p) > 0 { - f = append(f, failure{path: path, problems: p}) + if _, ok := x.items[anyFile]; ok { + return maybeAppendFailure(f, path, p) } - return f + for _, name := range sortedKeys(y.items) { + if !matchedFiles[name] { + p = append(p, existenceProblem(name, "unexpected %s", y.items[name].Type())) + } + } + return maybeAppendFailure(f, path, p) +} + +func maybeAppendFailure(failures []failure, path string, problems []problem) []failure { + if len(problems) > 0 { + return append(failures, failure{path: path, problems: problems}) + } + return failures } func sortedKeys(items map[string]dirEntry) []string { @@ -215,6 +237,30 @@ func eqEntry(path string, x, y dirEntry) []failure { return nil } +type globMatch struct { + match bool + failures []failure +} + +func matchGlob(name string, yEntry dirEntry, globs map[string]*filePath) globMatch { + m := globMatch{} + + for glob, expectedFile := range globs { + ok, err := filepath.Match(glob, name) + if err != nil { + p := errProblem("failed to match glob pattern", err) + f := failure{path: name, problems: []problem{p}} + m.failures = append(m.failures, f) + } + if ok { + m.match = true + m.failures = eqEntry(name, expectedFile.file, yEntry) + return m + } + } + return m +} + func formatFailures(failures []failure) string { sort.Slice(failures, func(i, j int) bool { return failures[i].path < failures[j].path diff --git a/components/cli/vendor/gotest.tools/poll/check.go b/components/cli/vendor/gotest.tools/poll/check.go new file mode 100644 index 0000000000..060b099890 --- /dev/null +++ b/components/cli/vendor/gotest.tools/poll/check.go @@ -0,0 +1,39 @@ +package poll + +import ( + "net" + "os" +) + +// Check is a function which will be used as check for the WaitOn method. +type Check func(t LogT) Result + +// FileExists looks on filesystem and check that path exists. +func FileExists(path string) Check { + return func(t LogT) Result { + _, err := os.Stat(path) + if os.IsNotExist(err) { + t.Logf("waiting on file %s to exist", path) + return Continue("file %s does not exist", path) + } + if err != nil { + return Error(err) + } + + return Success() + } +} + +// Connection try to open a connection to the address on the +// named network. See net.Dial for a description of the network and +// address parameters. +func Connection(network, address string) Check { + return func(t LogT) Result { + _, err := net.Dial(network, address) + if err != nil { + t.Logf("waiting on socket %s://%s to be available...", network, address) + return Continue("socket %s://%s not available", network, address) + } + return Success() + } +} diff --git a/components/cli/vendor/gotest.tools/poll/poll.go b/components/cli/vendor/gotest.tools/poll/poll.go index 3e3dd7f58a..5e238dca42 100644 --- a/components/cli/vendor/gotest.tools/poll/poll.go +++ b/components/cli/vendor/gotest.tools/poll/poll.go @@ -104,7 +104,7 @@ func Error(err error) Result { // WaitOn a condition or until a timeout. Poll by calling check and exit when // check returns a done Result. To fail a test and exit polling with an error // return a error result. -func WaitOn(t TestingT, check func(t LogT) Result, pollOps ...SettingOp) { +func WaitOn(t TestingT, check Check, pollOps ...SettingOp) { if ht, ok := t.(helperT); ok { ht.Helper() } diff --git a/components/cli/vendor/gotest.tools/skip/skip.go b/components/cli/vendor/gotest.tools/skip/skip.go index 4bfc9a11c2..d27ca53c3d 100644 --- a/components/cli/vendor/gotest.tools/skip/skip.go +++ b/components/cli/vendor/gotest.tools/skip/skip.go @@ -19,17 +19,29 @@ type skipT interface { Log(args ...interface{}) } +// Result of skip function +type Result interface { + Skip() bool + Message() string +} + type helperT interface { Helper() } -// BoolOrCheckFunc can be a bool or func() bool, other types will panic +// BoolOrCheckFunc can be a bool, func() bool, or func() Result. Other types will panic type BoolOrCheckFunc interface{} -// If the condition expression evaluates to true, or the condition function returns -// true, skip the test. +// If the condition expression evaluates to true, skip the test. +// +// The condition argument may be one of three types: bool, func() bool, or +// func() SkipResult. +// When called with a bool, the test will be skip if the condition evaluates to true. +// When called with a func() bool, the test will be skip if the function returns true. +// When called with a func() Result, the test will be skip if the Skip method +// of the result returns true. // The skip message will contain the source code of the expression. -// Extra message text can be passed as a format string with args +// Extra message text can be passed as a format string with args. func If(t skipT, condition BoolOrCheckFunc, msgAndArgs ...interface{}) { if ht, ok := t.(helperT); ok { ht.Helper() @@ -41,12 +53,18 @@ func If(t skipT, condition BoolOrCheckFunc, msgAndArgs ...interface{}) { if check() { t.Skip(format.WithCustomMessage(getFunctionName(check), msgAndArgs...)) } + case func() Result: + result := check() + if result.Skip() { + msg := getFunctionName(check) + ": " + result.Message() + t.Skip(format.WithCustomMessage(msg, msgAndArgs...)) + } default: panic(fmt.Sprintf("invalid type for condition arg: %T", check)) } } -func getFunctionName(function func() bool) string { +func getFunctionName(function interface{}) string { funcPath := runtime.FuncForPC(reflect.ValueOf(function).Pointer()).Name() return strings.SplitN(path.Base(funcPath), ".", 2)[1] } From fda0f4da053dfc90c383ae3230f68e5f0b48c30d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 14 Apr 2019 16:21:12 +0200 Subject: [PATCH 28/28] vendor.conf: reserve space for downstream projects This helps merge conflicts in situations where downstream projects have additional dependencies. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 8c5460a2cc92e47bc7d085f42d2b66dca0876b8b) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 7b3d0231637b730a95ff3a44e22673c8bd64bf9f Component: cli --- components/cli/vendor.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/cli/vendor.conf b/components/cli/vendor.conf index 6158134b41..abec83309d 100755 --- a/components/cli/vendor.conf +++ b/components/cli/vendor.conf @@ -95,3 +95,5 @@ k8s.io/client-go 1f13a808da65775f22cbf47862c4 k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb k8s.io/kubernetes bb9ffb1654d4a729bb4cec18ff088eacc153c239 # v1.11.2 vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 + +# DO NOT EDIT BELOW THIS LINE -------- reserved for downstream projects --------