mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Compare commits
106 Commits
v28.0.0-rc
...
v18.03.1-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20afdcca5b | ||
|
|
013d32fbb4 | ||
|
|
c2cd49a8c5 | ||
|
|
542579765f | ||
|
|
a67faac16c | ||
|
|
4539f775e6 | ||
|
|
c32b5dfc1d | ||
|
|
06fd90daf2 | ||
|
|
6713f305bb | ||
|
|
00f955e7a6 | ||
|
|
c7b1f41608 | ||
|
|
e1b115372b | ||
|
|
b265f7730a | ||
|
|
fef9c5a3b3 | ||
|
|
0e948a6988 | ||
|
|
c206c134f2 | ||
|
|
015cf3b51e | ||
|
|
ecd848d6ad | ||
|
|
e5289cabed | ||
|
|
1ded34ecfb | ||
|
|
c97859ba2d | ||
|
|
98e2aa7a1a | ||
|
|
420caf9e77 | ||
|
|
29ed6af411 | ||
|
|
30dd3df96b | ||
|
|
a80a0c0fb3 | ||
|
|
85baafcd37 | ||
|
|
1606abcc04 | ||
|
|
a4d9a8057d | ||
|
|
19a50e0ff1 | ||
|
|
410ef229e1 | ||
|
|
ada463fc91 | ||
|
|
1c542223b5 | ||
|
|
a86457fd08 | ||
|
|
c41fd93e23 | ||
|
|
187d6c03fb | ||
|
|
0a5c5b0fb0 | ||
|
|
a2d5fb894d | ||
|
|
819f792322 | ||
|
|
276322ad7c | ||
|
|
b91e896939 | ||
|
|
92de621938 | ||
|
|
1f2cae94cc | ||
|
|
58765fee80 | ||
|
|
c1d80ca005 | ||
|
|
d8581145e8 | ||
|
|
e09841e3bd | ||
|
|
e0e988afd6 | ||
|
|
c6fc9160f8 | ||
|
|
c8293365c8 | ||
|
|
1666d8e917 | ||
|
|
26fb91afed | ||
|
|
3881020096 | ||
|
|
e477c3b311 | ||
|
|
c444c69278 | ||
|
|
54625971f8 | ||
|
|
e385bd3cf0 | ||
|
|
a0a0951153 | ||
|
|
f5ab52a7a9 | ||
|
|
2ca48b4ae4 | ||
|
|
3b15c04042 | ||
|
|
fe3da58ea4 | ||
|
|
51603e1335 | ||
|
|
8224054799 | ||
|
|
a5f94a4d78 | ||
|
|
6d5f418116 | ||
|
|
a42e8b93b6 | ||
|
|
240cb224a5 | ||
|
|
84c0cd331b | ||
|
|
ba88a29514 | ||
|
|
1ec5530cd4 | ||
|
|
b3b4787dfd | ||
|
|
fdfa6f9ad2 | ||
|
|
d33d5100e0 | ||
|
|
a03d87f0dc | ||
|
|
61e39588a8 | ||
|
|
3df2c022ac | ||
|
|
055dc953e3 | ||
|
|
840a743fb3 | ||
|
|
560682a2d3 | ||
|
|
230da9c20d | ||
|
|
a390fb3030 | ||
|
|
e7007a958e | ||
|
|
451fa9a644 | ||
|
|
56c18c6d94 | ||
|
|
9cfa94b327 | ||
|
|
172d8cfb0f | ||
|
|
bde862d11e | ||
|
|
49d487808f | ||
|
|
dba33b041a | ||
|
|
3db5356b58 | ||
|
|
f833d6ccb1 | ||
|
|
b8ae001c8f | ||
|
|
9c23db048a | ||
|
|
cc19775363 | ||
|
|
aa334bf751 | ||
|
|
22482c7de4 | ||
|
|
99e9effcaf | ||
|
|
c76f748e62 | ||
|
|
120ae64d02 | ||
|
|
8232dc173d | ||
|
|
8bdf5fc525 | ||
|
|
385a42156c | ||
|
|
b61d45bb41 | ||
|
|
766fcb992c | ||
|
|
27c443f09c |
18
Dockerfile
18
Dockerfile
@@ -97,7 +97,7 @@ RUN apt-get update && apt-get install -y \
|
||||
# will need updating, to avoid errors. Ping #docker-maintainers on IRC
|
||||
# with a heads-up.
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
@@ -142,7 +142,7 @@ RUN set -x \
|
||||
&& rm -rf "$GOPATH"
|
||||
|
||||
# Get the "docker-py" source so we can run their integration tests
|
||||
ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
|
||||
ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
|
||||
# To run integration tests docker-pycreds is required.
|
||||
RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||
&& cd /docker-py \
|
||||
@@ -182,16 +182,18 @@ RUN echo "source $PWD/hack/make/.integration-test-helpers" >> /etc/bash.bashrc
|
||||
COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
# See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
|
||||
|
||||
# Install tomlv, vndr, runc, containerd, tini, docker-proxy dockercli
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter
|
||||
# Install tomlv, vndr, runc, containerd, tini, proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in tomlv vndr tini gometalinter proxy dockercli runc containerd; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
# Activate bash completion and include Docker's completion if mounted with DOCKER_BASH_COMPLETION_PATH
|
||||
|
||||
@@ -74,7 +74,7 @@ RUN apt-get update && apt-get install -y \
|
||||
|
||||
# Install Go
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-arm64.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
@@ -106,7 +106,7 @@ RUN set -x \
|
||||
&& rm -rf "$GOPATH"
|
||||
|
||||
# Get the "docker-py" source so we can run their integration tests
|
||||
ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
|
||||
ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
|
||||
# To run integration tests docker-pycreds is required.
|
||||
RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||
&& cd /docker-py \
|
||||
@@ -147,18 +147,22 @@ RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
|
||||
COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
# See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
|
||||
#
|
||||
|
||||
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter
|
||||
# Install tomlv, vndr, runc, containerd, tini, proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in tomlv vndr tini gometalinter proxy dockercli runc containerd; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
|
||||
# Wrap all commands in the "docker-in-docker" script to allow nested containers
|
||||
ENTRYPOINT ["hack/dind"]
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ RUN apt-get update && apt-get install -y \
|
||||
|
||||
# Install Go
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||
@@ -104,7 +104,7 @@ RUN set -x \
|
||||
&& rm -rf "$GOPATH"
|
||||
|
||||
# Get the "docker-py" source so we can run their integration tests
|
||||
ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
|
||||
ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
|
||||
# To run integration tests docker-pycreds is required.
|
||||
RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||
&& cd /docker-py \
|
||||
@@ -133,16 +133,18 @@ RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
|
||||
COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
# See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
|
||||
|
||||
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter
|
||||
# Install tomlv, vndr, runc, containerd, tini, proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in tomlv vndr tini gometalinter proxy dockercli runc containerd; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
ENTRYPOINT ["hack/dind"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## Step 1: Build tests
|
||||
FROM golang:1.9.4-alpine3.6 as builder
|
||||
FROM golang:1.9.5-alpine3.6 as builder
|
||||
|
||||
RUN apk add --update \
|
||||
bash \
|
||||
@@ -17,13 +17,14 @@ WORKDIR /go/src/github.com/docker/docker/
|
||||
COPY contrib/download-frozen-image-v2.sh contrib/download-frozen-image-v2.sh
|
||||
RUN contrib/download-frozen-image-v2.sh /output/docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
|
||||
# Download Docker CLI binary
|
||||
COPY hack/dockerfile hack/dockerfile
|
||||
RUN hack/dockerfile/install-binaries.sh dockercli
|
||||
RUN hack/dockerfile/install.sh dockercli
|
||||
|
||||
# Set tag and add sources
|
||||
ARG DOCKER_GITCOMMIT
|
||||
|
||||
@@ -65,7 +65,7 @@ RUN apt-get update && apt-get install -y \
|
||||
# Install Go
|
||||
# NOTE: official ppc64le go binaries weren't available until go 1.6.4 and 1.7.4
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
@@ -102,7 +102,7 @@ RUN set -x \
|
||||
&& rm -rf "$GOPATH"
|
||||
|
||||
# Get the "docker-py" source so we can run their integration tests
|
||||
ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
|
||||
ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
|
||||
# To run integration tests docker-pycreds is required.
|
||||
RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||
&& cd /docker-py \
|
||||
@@ -131,16 +131,18 @@ RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
|
||||
COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
# See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
|
||||
|
||||
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter
|
||||
# Install tomlv, vndr, runc, containerd, tini, proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in tomlv vndr tini gometalinter proxy dockercli runc containerd; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
# Wrap all commands in the "docker-in-docker" script to allow nested containers
|
||||
|
||||
@@ -59,7 +59,7 @@ RUN apt-get update && apt-get install -y \
|
||||
--no-install-recommends
|
||||
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
@@ -96,7 +96,7 @@ RUN set -x \
|
||||
&& rm -rf "$GOPATH"
|
||||
|
||||
# Get the "docker-py" source so we can run their integration tests
|
||||
ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
|
||||
ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
|
||||
# To run integration tests docker-pycreds is required.
|
||||
RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||
&& cd /docker-py \
|
||||
@@ -125,16 +125,18 @@ RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
|
||||
COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
|
||||
buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \
|
||||
busybox:1.27-glibc@sha256:8c8f261a462eead45ab8e610d3e8f7a1e4fd1cd9bed5bc0a0c386784ab105d8e \
|
||||
busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \
|
||||
busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
# See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
|
||||
|
||||
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy dockercli gometalinter
|
||||
# Install tomlv, vndr, runc, containerd, tini, proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in tomlv vndr tini gometalinter proxy dockercli runc containerd; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
# Wrap all commands in the "docker-in-docker" script to allow nested containers
|
||||
|
||||
@@ -42,7 +42,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# will need updating, to avoid errors. Ping #docker-maintainers on IRC
|
||||
# with a heads-up.
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||
@@ -50,10 +50,11 @@ ENV GOPATH /go
|
||||
ENV CGO_LDFLAGS -L/lib
|
||||
|
||||
# Install runc, containerd, tini and docker-proxy
|
||||
# Please edit hack/dockerfile/install-binaries.sh to update them.
|
||||
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
|
||||
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
|
||||
RUN /tmp/install-binaries.sh runc containerd tini proxy dockercli
|
||||
# Please edit hack/dockerfile/install/<name>.installer to update them.
|
||||
COPY hack/dockerfile/install hack/dockerfile/install
|
||||
RUN for i in runc containerd tini proxy dockercli; \
|
||||
do hack/dockerfile/install/install.sh $i; \
|
||||
done
|
||||
ENV PATH=/usr/local/cli:$PATH
|
||||
|
||||
ENV AUTO_GOPATH 1
|
||||
|
||||
@@ -161,7 +161,7 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref
|
||||
# Environment variable notes:
|
||||
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
|
||||
# - FROM_DOCKERFILE is used for detection of building within a container.
|
||||
ENV GO_VERSION=1.9.4 `
|
||||
ENV GO_VERSION=1.9.5 `
|
||||
GIT_VERSION=2.11.1 `
|
||||
GOPATH=C:\go `
|
||||
FROM_DOCKERFILE=1
|
||||
|
||||
@@ -8,11 +8,11 @@ questions you may have as an aspiring Moby contributor.
|
||||
Moby has two test suites (and one legacy test suite):
|
||||
|
||||
* Unit tests - use standard `go test` and
|
||||
[testify](https://github.com/stretchr/testify) assertions. They are located in
|
||||
[gotestyourself/assert](https://godoc.org/github.com/gotestyourself/gotestyourself/assert) assertions. They are located in
|
||||
the package they test. Unit tests should be fast and test only their own
|
||||
package.
|
||||
* API integration tests - use standard `go test` and
|
||||
[testify](https://github.com/stretchr/testify) assertions. They are located in
|
||||
[gotestyourself/assert](https://godoc.org/github.com/gotestyourself/gotestyourself/assert) assertions. They are located in
|
||||
`./integration/<component>` directories, where `component` is: container,
|
||||
image, volume, etc. These tests perform HTTP requests to an API endpoint and
|
||||
check the HTTP response and daemon state after the call.
|
||||
|
||||
@@ -3,7 +3,8 @@ package middleware // import "github.com/docker/docker/api/server/middleware"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestMaskSecretKeys(t *testing.T) {
|
||||
@@ -53,6 +54,6 @@ func TestMaskSecretKeys(t *testing.T) {
|
||||
|
||||
for _, testcase := range tests {
|
||||
maskSecretKeys(testcase.input, testcase.path)
|
||||
assert.Equal(t, testcase.expected, testcase.input)
|
||||
assert.Check(t, is.DeepEqual(testcase.expected, testcase.input))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/server/httputils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -17,7 +18,7 @@ func TestVersionMiddlewareVersion(t *testing.T) {
|
||||
expectedVersion := defaultVersion
|
||||
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
v := httputils.VersionFromContext(ctx)
|
||||
assert.Equal(t, expectedVersion, v)
|
||||
assert.Check(t, is.Equal(expectedVersion, v))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -56,9 +57,9 @@ func TestVersionMiddlewareVersion(t *testing.T) {
|
||||
err := h(ctx, resp, req, map[string]string{"version": test.reqVersion})
|
||||
|
||||
if test.errString != "" {
|
||||
assert.EqualError(t, err, test.errString)
|
||||
assert.Check(t, is.Error(err, test.errString))
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +67,7 @@ func TestVersionMiddlewareVersion(t *testing.T) {
|
||||
func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
|
||||
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
v := httputils.VersionFromContext(ctx)
|
||||
assert.NotEmpty(t, v)
|
||||
assert.Check(t, len(v) != 0)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -81,11 +82,11 @@ func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
|
||||
|
||||
vars := map[string]string{"version": "0.1"}
|
||||
err := h(ctx, resp, req, vars)
|
||||
assert.Error(t, err)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
|
||||
hdr := resp.Result().Header
|
||||
assert.Contains(t, hdr.Get("Server"), "Docker/"+defaultVersion)
|
||||
assert.Contains(t, hdr.Get("Server"), runtime.GOOS)
|
||||
assert.Equal(t, hdr.Get("API-Version"), defaultVersion)
|
||||
assert.Equal(t, hdr.Get("OSType"), runtime.GOOS)
|
||||
assert.Check(t, is.Contains(hdr.Get("Server"), "Docker/"+defaultVersion))
|
||||
assert.Check(t, is.Contains(hdr.Get("Server"), runtime.GOOS))
|
||||
assert.Check(t, is.Equal(hdr.Get("API-Version"), defaultVersion))
|
||||
assert.Check(t, is.Equal(hdr.Get("OSType"), runtime.GOOS))
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestParseArgs(t *testing.T) {
|
||||
@@ -22,10 +22,10 @@ func TestParseArgs(t *testing.T) {
|
||||
|
||||
for i := range flagArgs {
|
||||
args, err = ParseFlag(flagArgs[i], args)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
assert.Len(t, args.Get("created"), 1)
|
||||
assert.Len(t, args.Get("image.name"), 2)
|
||||
assert.Check(t, is.Len(args.Get("created"), 1))
|
||||
assert.Check(t, is.Len(args.Get("image.name"), 2))
|
||||
}
|
||||
|
||||
func TestParseArgsEdgeCase(t *testing.T) {
|
||||
@@ -231,7 +231,7 @@ func TestArgsMatch(t *testing.T) {
|
||||
}
|
||||
|
||||
for args, field := range matches {
|
||||
assert.True(t, args.Match(field, source),
|
||||
assert.Check(t, args.Match(field, source),
|
||||
"Expected field %s to match %s", field, source)
|
||||
}
|
||||
|
||||
@@ -255,8 +255,7 @@ func TestArgsMatch(t *testing.T) {
|
||||
}
|
||||
|
||||
for args, field := range differs {
|
||||
assert.False(t, args.Match(field, source),
|
||||
"Expected field %s to not match %s", field, source)
|
||||
assert.Check(t, !args.Match(field, source), "Expected field %s to not match %s", field, source)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ type Backend interface {
|
||||
|
||||
// ImageBackend are the interface methods required from an image component
|
||||
type ImageBackend interface {
|
||||
GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (Image, ReleaseableLayer, error)
|
||||
GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (Image, ROLayer, error)
|
||||
}
|
||||
|
||||
// ExecBackend contains the interface methods required for executing containers
|
||||
@@ -100,10 +100,16 @@ type Image interface {
|
||||
OperatingSystem() string
|
||||
}
|
||||
|
||||
// ReleaseableLayer is an image layer that can be mounted and released
|
||||
type ReleaseableLayer interface {
|
||||
// ROLayer is a reference to image rootfs layer
|
||||
type ROLayer interface {
|
||||
Release() error
|
||||
Mount() (containerfs.ContainerFS, error)
|
||||
Commit() (ReleaseableLayer, error)
|
||||
NewRWLayer() (RWLayer, error)
|
||||
DiffID() layer.DiffID
|
||||
}
|
||||
|
||||
// RWLayer is active layer that can be read/modified
|
||||
type RWLayer interface {
|
||||
Release() error
|
||||
Root() containerfs.ContainerFS
|
||||
Commit() (ROLayer, error)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func strPtr(source string) *string {
|
||||
@@ -39,7 +41,7 @@ func TestGetAllAllowed(t *testing.T) {
|
||||
"ArgFromMeta": "frommeta1",
|
||||
"ArgFromMetaOverridden": "fromdockerfile3",
|
||||
}
|
||||
assert.Equal(t, expected, all)
|
||||
assert.Check(t, is.DeepEqual(expected, all))
|
||||
}
|
||||
|
||||
func TestGetAllMeta(t *testing.T) {
|
||||
@@ -61,7 +63,7 @@ func TestGetAllMeta(t *testing.T) {
|
||||
"ArgOverriddenByOptions": "fromopt2",
|
||||
"ArgNoDefaultInMetaFromOptions": "fromopt3",
|
||||
}
|
||||
assert.Equal(t, expected, all)
|
||||
assert.Check(t, is.DeepEqual(expected, all))
|
||||
}
|
||||
|
||||
func TestWarnOnUnusedBuildArgs(t *testing.T) {
|
||||
@@ -77,10 +79,10 @@ func TestWarnOnUnusedBuildArgs(t *testing.T) {
|
||||
buffer := new(bytes.Buffer)
|
||||
buildArgs.WarnOnUnusedBuildArgs(buffer)
|
||||
out := buffer.String()
|
||||
assert.NotContains(t, out, "ThisArgIsUsed")
|
||||
assert.NotContains(t, out, "HTTPS_PROXY")
|
||||
assert.NotContains(t, out, "HTTP_PROXY")
|
||||
assert.Contains(t, out, "ThisArgIsNotUsed")
|
||||
assert.Assert(t, !strings.Contains(out, "ThisArgIsUsed"), out)
|
||||
assert.Assert(t, !strings.Contains(out, "HTTPS_PROXY"), out)
|
||||
assert.Assert(t, !strings.Contains(out, "HTTP_PROXY"), out)
|
||||
assert.Check(t, is.Contains(out, "ThisArgIsNotUsed"))
|
||||
}
|
||||
|
||||
func TestIsUnreferencedBuiltin(t *testing.T) {
|
||||
@@ -93,8 +95,8 @@ func TestIsUnreferencedBuiltin(t *testing.T) {
|
||||
buildArgs.AddArg("ThisArgIsUsed", nil)
|
||||
buildArgs.AddArg("HTTPS_PROXY", nil)
|
||||
|
||||
assert.True(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsUsed"))
|
||||
assert.True(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsNotUsed"))
|
||||
assert.True(t, buildArgs.IsReferencedOrNotBuiltin("HTTPS_PROXY"))
|
||||
assert.False(t, buildArgs.IsReferencedOrNotBuiltin("HTTP_PROXY"))
|
||||
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsUsed"))
|
||||
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsNotUsed"))
|
||||
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("HTTPS_PROXY"))
|
||||
assert.Check(t, !buildArgs.IsReferencedOrNotBuiltin("HTTP_PROXY"))
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/builder/dockerfile/parser"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestAddNodesForLabelOption(t *testing.T) {
|
||||
dockerfile := "FROM scratch"
|
||||
result, err := parser.Parse(strings.NewReader(dockerfile))
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
labels := map[string]string{
|
||||
"org.e": "cli-e",
|
||||
@@ -27,8 +28,8 @@ func TestAddNodesForLabelOption(t *testing.T) {
|
||||
"FROM scratch",
|
||||
`LABEL "org.a"='cli-a' "org.b"='cli-b' "org.c"='cli-c' "org.d"='cli-d' "org.e"='cli-e'`,
|
||||
}
|
||||
assert.Len(t, nodes.Children, 2)
|
||||
assert.Check(t, is.Len(nodes.Children, 2))
|
||||
for i, v := range nodes.Children {
|
||||
assert.Equal(t, expected[i], v.Original)
|
||||
assert.Check(t, is.Equal(expected[i], v.Original))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,12 @@ type copier struct {
|
||||
source builder.Source
|
||||
pathCache pathCache
|
||||
download sourceDownloader
|
||||
tmpPaths []string
|
||||
platform string
|
||||
// for cleanup. TODO: having copier.cleanup() is error prone and hard to
|
||||
// follow. Code calling performCopy should manage the lifecycle of its params.
|
||||
// Copier should take override source as input, not imageMount.
|
||||
activeLayer builder.RWLayer
|
||||
tmpPaths []string
|
||||
}
|
||||
|
||||
func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, imageSource *imageMount) copier {
|
||||
@@ -155,6 +159,10 @@ func (o *copier) Cleanup() {
|
||||
os.RemoveAll(path)
|
||||
}
|
||||
o.tmpPaths = []string{}
|
||||
if o.activeLayer != nil {
|
||||
o.activeLayer.Release()
|
||||
o.activeLayer = nil
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: allowWildcards can probably be removed by refactoring this function further.
|
||||
@@ -166,9 +174,15 @@ func (o *copier) calcCopyInfo(origPath string, allowWildcards bool) ([]copyInfo,
|
||||
// done on image Source?
|
||||
if imageSource != nil {
|
||||
var err error
|
||||
o.source, err = imageSource.Source()
|
||||
rwLayer, err := imageSource.NewRWLayer()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to copy from %s", imageSource.ImageID())
|
||||
return nil, err
|
||||
}
|
||||
o.activeLayer = rwLayer
|
||||
|
||||
o.source, err = remotecontext.NewLazySource(rwLayer.Root())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create context for copy from %s", rwLayer.Root().Path())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/containerfs"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsExistingDirectory(t *testing.T) {
|
||||
@@ -39,10 +40,10 @@ func TestIsExistingDirectory(t *testing.T) {
|
||||
|
||||
for _, testcase := range testcases {
|
||||
result, err := isExistingDirectory(©Endpoint{driver: containerfs.NewLocalDriver(), path: testcase.path})
|
||||
if !assert.NoError(t, err) {
|
||||
if !assert.Check(t, err) {
|
||||
continue
|
||||
}
|
||||
assert.Equal(t, testcase.expected, result, testcase.doc)
|
||||
assert.Check(t, is.Equal(testcase.expected, result), testcase.doc)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +143,6 @@ func TestGetFilenameForDownload(t *testing.T) {
|
||||
resp.Header.Add("Content-Disposition", testcase.disposition)
|
||||
}
|
||||
filename := getFilenameForDownload(testcase.path, &resp)
|
||||
assert.Equal(t, testcase.expected, filename)
|
||||
assert.Check(t, is.Equal(testcase.expected, filename))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func newBuilderWithMockBackend() *Builder {
|
||||
@@ -49,13 +49,13 @@ func TestEnv2Variables(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, envCommand)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := []string{
|
||||
"var1=val1",
|
||||
"var2=val2",
|
||||
}
|
||||
assert.Equal(t, expected, sb.state.runConfig.Env)
|
||||
assert.Check(t, is.DeepEqual(expected, sb.state.runConfig.Env))
|
||||
}
|
||||
|
||||
func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
|
||||
@@ -68,12 +68,12 @@ func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, envCommand)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
expected := []string{
|
||||
"var1=val1",
|
||||
"var2=fromenv",
|
||||
}
|
||||
assert.Equal(t, expected, sb.state.runConfig.Env)
|
||||
assert.Check(t, is.DeepEqual(expected, sb.state.runConfig.Env))
|
||||
}
|
||||
|
||||
func TestMaintainer(t *testing.T) {
|
||||
@@ -82,8 +82,8 @@ func TestMaintainer(t *testing.T) {
|
||||
sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
|
||||
cmd := &instructions.MaintainerCommand{Maintainer: maintainerEntry}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, maintainerEntry, sb.state.maintainer)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(maintainerEntry, sb.state.maintainer))
|
||||
}
|
||||
|
||||
func TestLabel(t *testing.T) {
|
||||
@@ -98,10 +98,10 @@ func TestLabel(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
require.Contains(t, sb.state.runConfig.Labels, labelName)
|
||||
assert.Equal(t, sb.state.runConfig.Labels[labelName], labelValue)
|
||||
assert.Assert(t, is.Contains(sb.state.runConfig.Labels, labelName))
|
||||
assert.Check(t, is.Equal(sb.state.runConfig.Labels[labelName], labelValue))
|
||||
}
|
||||
|
||||
func TestFromScratch(t *testing.T) {
|
||||
@@ -113,22 +113,22 @@ func TestFromScratch(t *testing.T) {
|
||||
err := initializeStage(sb, cmd)
|
||||
|
||||
if runtime.GOOS == "windows" && !system.LCOWSupported() {
|
||||
assert.EqualError(t, err, "Windows does not support FROM scratch")
|
||||
assert.Check(t, is.Error(err, "Windows does not support FROM scratch"))
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.True(t, sb.state.hasFromImage())
|
||||
assert.Equal(t, "", sb.state.imageID)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, sb.state.hasFromImage())
|
||||
assert.Check(t, is.Equal("", sb.state.imageID))
|
||||
expected := "PATH=" + system.DefaultPathEnv(runtime.GOOS)
|
||||
assert.Equal(t, []string{expected}, sb.state.runConfig.Env)
|
||||
assert.Check(t, is.DeepEqual([]string{expected}, sb.state.runConfig.Env))
|
||||
}
|
||||
|
||||
func TestFromWithArg(t *testing.T) {
|
||||
tag, expected := ":sometag", "expectedthisid"
|
||||
|
||||
getImage := func(name string) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
assert.Equal(t, "alpine"+tag, name)
|
||||
getImage := func(name string) (builder.Image, builder.ROLayer, error) {
|
||||
assert.Check(t, is.Equal("alpine"+tag, name))
|
||||
return &mockImage{id: "expectedthisid"}, nil, nil
|
||||
}
|
||||
b := newBuilderWithMockBackend()
|
||||
@@ -146,21 +146,21 @@ func TestFromWithArg(t *testing.T) {
|
||||
err := processMetaArg(metaArg, shell.NewLex('\\'), args)
|
||||
|
||||
sb := newDispatchRequest(b, '\\', nil, args, newStagesBuildResults())
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
err = initializeStage(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Equal(t, expected, sb.state.imageID)
|
||||
assert.Equal(t, expected, sb.state.baseImage.ImageID())
|
||||
assert.Len(t, sb.state.buildArgs.GetAllAllowed(), 0)
|
||||
assert.Len(t, sb.state.buildArgs.GetAllMeta(), 1)
|
||||
assert.Check(t, is.Equal(expected, sb.state.imageID))
|
||||
assert.Check(t, is.Equal(expected, sb.state.baseImage.ImageID()))
|
||||
assert.Check(t, is.Len(sb.state.buildArgs.GetAllAllowed(), 0))
|
||||
assert.Check(t, is.Len(sb.state.buildArgs.GetAllMeta(), 1))
|
||||
}
|
||||
|
||||
func TestFromWithUndefinedArg(t *testing.T) {
|
||||
tag, expected := "sometag", "expectedthisid"
|
||||
|
||||
getImage := func(name string) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
assert.Equal(t, "alpine", name)
|
||||
getImage := func(name string) (builder.Image, builder.ROLayer, error) {
|
||||
assert.Check(t, is.Equal("alpine", name))
|
||||
return &mockImage{id: "expectedthisid"}, nil, nil
|
||||
}
|
||||
b := newBuilderWithMockBackend()
|
||||
@@ -173,8 +173,8 @@ func TestFromWithUndefinedArg(t *testing.T) {
|
||||
BaseName: "alpine${THETAG}",
|
||||
}
|
||||
err := initializeStage(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expected, sb.state.imageID)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(expected, sb.state.imageID))
|
||||
}
|
||||
|
||||
func TestFromMultiStageWithNamedStage(t *testing.T) {
|
||||
@@ -185,13 +185,13 @@ func TestFromMultiStageWithNamedStage(t *testing.T) {
|
||||
firstSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults)
|
||||
secondSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults)
|
||||
err := initializeStage(firstSB, firstFrom)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, firstSB.state.hasFromImage())
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, firstSB.state.hasFromImage())
|
||||
previousResults.indexed["base"] = firstSB.state.runConfig
|
||||
previousResults.flat = append(previousResults.flat, firstSB.state.runConfig)
|
||||
err = initializeStage(secondSB, secondFrom)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, secondSB.state.hasFromImage())
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, secondSB.state.hasFromImage())
|
||||
}
|
||||
|
||||
func TestOnbuild(t *testing.T) {
|
||||
@@ -201,8 +201,8 @@ func TestOnbuild(t *testing.T) {
|
||||
Expression: "ADD . /app/src",
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "ADD . /app/src", sb.state.runConfig.OnBuild[0])
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("ADD . /app/src", sb.state.runConfig.OnBuild[0]))
|
||||
}
|
||||
|
||||
func TestWorkdir(t *testing.T) {
|
||||
@@ -217,8 +217,8 @@ func TestWorkdir(t *testing.T) {
|
||||
}
|
||||
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, workingDir, sb.state.runConfig.WorkingDir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(workingDir, sb.state.runConfig.WorkingDir))
|
||||
}
|
||||
|
||||
func TestCmd(t *testing.T) {
|
||||
@@ -233,7 +233,7 @@ func TestCmd(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
var expectedCommand strslice.StrSlice
|
||||
if runtime.GOOS == "windows" {
|
||||
@@ -242,8 +242,8 @@ func TestCmd(t *testing.T) {
|
||||
expectedCommand = strslice.StrSlice(append([]string{"/bin/sh"}, "-c", command))
|
||||
}
|
||||
|
||||
assert.Equal(t, expectedCommand, sb.state.runConfig.Cmd)
|
||||
assert.True(t, sb.state.cmdSet)
|
||||
assert.Check(t, is.DeepEqual(expectedCommand, sb.state.runConfig.Cmd))
|
||||
assert.Check(t, sb.state.cmdSet)
|
||||
}
|
||||
|
||||
func TestHealthcheckNone(t *testing.T) {
|
||||
@@ -255,10 +255,10 @@ func TestHealthcheckNone(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
require.NotNil(t, sb.state.runConfig.Healthcheck)
|
||||
assert.Equal(t, []string{"NONE"}, sb.state.runConfig.Healthcheck.Test)
|
||||
assert.Assert(t, sb.state.runConfig.Healthcheck != nil)
|
||||
assert.Check(t, is.DeepEqual([]string{"NONE"}, sb.state.runConfig.Healthcheck.Test))
|
||||
}
|
||||
|
||||
func TestHealthcheckCmd(t *testing.T) {
|
||||
@@ -272,10 +272,10 @@ func TestHealthcheckCmd(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
require.NotNil(t, sb.state.runConfig.Healthcheck)
|
||||
assert.Equal(t, expectedTest, sb.state.runConfig.Healthcheck.Test)
|
||||
assert.Assert(t, sb.state.runConfig.Healthcheck != nil)
|
||||
assert.Check(t, is.DeepEqual(expectedTest, sb.state.runConfig.Healthcheck.Test))
|
||||
}
|
||||
|
||||
func TestEntrypoint(t *testing.T) {
|
||||
@@ -290,8 +290,8 @@ func TestEntrypoint(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sb.state.runConfig.Entrypoint)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, sb.state.runConfig.Entrypoint != nil)
|
||||
|
||||
var expectedEntrypoint strslice.StrSlice
|
||||
if runtime.GOOS == "windows" {
|
||||
@@ -299,7 +299,7 @@ func TestEntrypoint(t *testing.T) {
|
||||
} else {
|
||||
expectedEntrypoint = strslice.StrSlice(append([]string{"/bin/sh"}, "-c", entrypointCmd))
|
||||
}
|
||||
assert.Equal(t, expectedEntrypoint, sb.state.runConfig.Entrypoint)
|
||||
assert.Check(t, is.DeepEqual(expectedEntrypoint, sb.state.runConfig.Entrypoint))
|
||||
}
|
||||
|
||||
func TestExpose(t *testing.T) {
|
||||
@@ -311,14 +311,14 @@ func TestExpose(t *testing.T) {
|
||||
Ports: []string{exposedPort},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
require.NotNil(t, sb.state.runConfig.ExposedPorts)
|
||||
require.Len(t, sb.state.runConfig.ExposedPorts, 1)
|
||||
assert.Assert(t, sb.state.runConfig.ExposedPorts != nil)
|
||||
assert.Assert(t, is.Len(sb.state.runConfig.ExposedPorts, 1))
|
||||
|
||||
portsMapping, err := nat.ParsePortSpec(exposedPort)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, sb.state.runConfig.ExposedPorts, portsMapping[0].Port)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Contains(sb.state.runConfig.ExposedPorts, portsMapping[0].Port))
|
||||
}
|
||||
|
||||
func TestUser(t *testing.T) {
|
||||
@@ -329,8 +329,8 @@ func TestUser(t *testing.T) {
|
||||
User: "test",
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "test", sb.state.runConfig.User)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("test", sb.state.runConfig.User))
|
||||
}
|
||||
|
||||
func TestVolume(t *testing.T) {
|
||||
@@ -343,10 +343,10 @@ func TestVolume(t *testing.T) {
|
||||
Volumes: []string{exposedVolume},
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sb.state.runConfig.Volumes)
|
||||
assert.Len(t, sb.state.runConfig.Volumes, 1)
|
||||
assert.Contains(t, sb.state.runConfig.Volumes, exposedVolume)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, sb.state.runConfig.Volumes != nil)
|
||||
assert.Check(t, is.Len(sb.state.runConfig.Volumes, 1))
|
||||
assert.Check(t, is.Contains(sb.state.runConfig.Volumes, exposedVolume))
|
||||
}
|
||||
|
||||
func TestStopSignal(t *testing.T) {
|
||||
@@ -362,8 +362,8 @@ func TestStopSignal(t *testing.T) {
|
||||
Signal: signal,
|
||||
}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, signal, sb.state.runConfig.StopSignal)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(signal, sb.state.runConfig.StopSignal))
|
||||
}
|
||||
|
||||
func TestArg(t *testing.T) {
|
||||
@@ -374,10 +374,10 @@ func TestArg(t *testing.T) {
|
||||
argVal := "bar"
|
||||
cmd := &instructions.ArgCommand{Key: argName, Value: &argVal}
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := map[string]string{argName: argVal}
|
||||
assert.Equal(t, expected, sb.state.buildArgs.GetAllAllowed())
|
||||
assert.Check(t, is.DeepEqual(expected, sb.state.buildArgs.GetAllAllowed()))
|
||||
}
|
||||
|
||||
func TestShell(t *testing.T) {
|
||||
@@ -388,10 +388,10 @@ func TestShell(t *testing.T) {
|
||||
cmd := &instructions.ShellCommand{Shell: strslice.StrSlice{shellCmd}}
|
||||
|
||||
err := dispatch(sb, cmd)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expectedShell := strslice.StrSlice([]string{shellCmd})
|
||||
assert.Equal(t, expectedShell, sb.state.runConfig.Shell)
|
||||
assert.Check(t, is.DeepEqual(expectedShell, sb.state.runConfig.Shell))
|
||||
}
|
||||
|
||||
func TestPrependEnvOnCmd(t *testing.T) {
|
||||
@@ -403,7 +403,7 @@ func TestPrependEnvOnCmd(t *testing.T) {
|
||||
cmdWithEnv := prependEnvOnCmd(buildArgs, args, cmd)
|
||||
expected := strslice.StrSlice([]string{
|
||||
"|3", "NO_PROXY=YA", "args=not", "sorted=nope", "foo", "bar"})
|
||||
assert.Equal(t, expected, cmdWithEnv)
|
||||
assert.Check(t, is.DeepEqual(expected, cmdWithEnv))
|
||||
}
|
||||
|
||||
func TestRunWithBuildArgs(t *testing.T) {
|
||||
@@ -422,8 +422,8 @@ func TestRunWithBuildArgs(t *testing.T) {
|
||||
imageCache := &mockImageCache{
|
||||
getCacheFunc: func(parentID string, cfg *container.Config) (string, error) {
|
||||
// Check the runConfig.Cmd sent to probeCache()
|
||||
assert.Equal(t, cachedCmd, cfg.Cmd)
|
||||
assert.Equal(t, strslice.StrSlice(nil), cfg.Entrypoint)
|
||||
assert.Check(t, is.DeepEqual(cachedCmd, cfg.Cmd))
|
||||
assert.Check(t, is.DeepEqual(strslice.StrSlice(nil), cfg.Entrypoint))
|
||||
return "", nil
|
||||
},
|
||||
}
|
||||
@@ -433,7 +433,7 @@ func TestRunWithBuildArgs(t *testing.T) {
|
||||
return imageCache
|
||||
}
|
||||
b.imageProber = newImageProber(mockBackend, nil, false)
|
||||
mockBackend.getImageFunc = func(_ string) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
mockBackend.getImageFunc = func(_ string) (builder.Image, builder.ROLayer, error) {
|
||||
return &mockImage{
|
||||
id: "abcdef",
|
||||
config: &container.Config{Cmd: origCmd},
|
||||
@@ -441,21 +441,21 @@ func TestRunWithBuildArgs(t *testing.T) {
|
||||
}
|
||||
mockBackend.containerCreateFunc = func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) {
|
||||
// Check the runConfig.Cmd sent to create()
|
||||
assert.Equal(t, cmdWithShell, config.Config.Cmd)
|
||||
assert.Contains(t, config.Config.Env, "one=two")
|
||||
assert.Equal(t, strslice.StrSlice{""}, config.Config.Entrypoint)
|
||||
assert.Check(t, is.DeepEqual(cmdWithShell, config.Config.Cmd))
|
||||
assert.Check(t, is.Contains(config.Config.Env, "one=two"))
|
||||
assert.Check(t, is.DeepEqual(strslice.StrSlice{""}, config.Config.Entrypoint))
|
||||
return container.ContainerCreateCreatedBody{ID: "12345"}, nil
|
||||
}
|
||||
mockBackend.commitFunc = func(cfg backend.CommitConfig) (image.ID, error) {
|
||||
// Check the runConfig.Cmd sent to commit()
|
||||
assert.Equal(t, origCmd, cfg.Config.Cmd)
|
||||
assert.Equal(t, cachedCmd, cfg.ContainerConfig.Cmd)
|
||||
assert.Equal(t, strslice.StrSlice(nil), cfg.Config.Entrypoint)
|
||||
assert.Check(t, is.DeepEqual(origCmd, cfg.Config.Cmd))
|
||||
assert.Check(t, is.DeepEqual(cachedCmd, cfg.ContainerConfig.Cmd))
|
||||
assert.Check(t, is.DeepEqual(strslice.StrSlice(nil), cfg.Config.Entrypoint))
|
||||
return "", nil
|
||||
}
|
||||
from := &instructions.Stage{BaseName: "abcdef"}
|
||||
err := initializeStage(sb, from)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
sb.state.buildArgs.AddArg("one", strPtr("two"))
|
||||
run := &instructions.RunCommand{
|
||||
ShellDependantCmdLine: instructions.ShellDependantCmdLine{
|
||||
@@ -463,8 +463,8 @@ func TestRunWithBuildArgs(t *testing.T) {
|
||||
PrependShell: true,
|
||||
},
|
||||
}
|
||||
require.NoError(t, dispatch(sb, run))
|
||||
assert.NilError(t, dispatch(sb, run))
|
||||
|
||||
// Check that runConfig.Cmd has not been modified by run
|
||||
assert.Equal(t, origCmd, sb.state.runConfig.Cmd)
|
||||
assert.Check(t, is.DeepEqual(origCmd, sb.state.runConfig.Cmd))
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types/backend"
|
||||
"github.com/docker/docker/builder"
|
||||
"github.com/docker/docker/builder/remotecontext"
|
||||
dockerimage "github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
@@ -13,7 +12,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type getAndMountFunc func(string, bool) (builder.Image, builder.ReleaseableLayer, error)
|
||||
type getAndMountFunc func(string, bool) (builder.Image, builder.ROLayer, error)
|
||||
|
||||
// imageSources mounts images and provides a cache for mounted images. It tracks
|
||||
// all images so they can be unmounted at the end of the build.
|
||||
@@ -24,7 +23,7 @@ type imageSources struct {
|
||||
}
|
||||
|
||||
func newImageSources(ctx context.Context, options builderOptions) *imageSources {
|
||||
getAndMount := func(idOrRef string, localOnly bool) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
getAndMount := func(idOrRef string, localOnly bool) (builder.Image, builder.ROLayer, error) {
|
||||
pullOption := backend.PullOptionNoPull
|
||||
if !localOnly {
|
||||
if options.Options.PullParent {
|
||||
@@ -92,32 +91,14 @@ func (m *imageSources) Add(im *imageMount) {
|
||||
type imageMount struct {
|
||||
image builder.Image
|
||||
source builder.Source
|
||||
layer builder.ReleaseableLayer
|
||||
layer builder.ROLayer
|
||||
}
|
||||
|
||||
func newImageMount(image builder.Image, layer builder.ReleaseableLayer) *imageMount {
|
||||
func newImageMount(image builder.Image, layer builder.ROLayer) *imageMount {
|
||||
im := &imageMount{image: image, layer: layer}
|
||||
return im
|
||||
}
|
||||
|
||||
func (im *imageMount) Source() (builder.Source, error) {
|
||||
if im.source == nil {
|
||||
if im.layer == nil {
|
||||
return nil, errors.Errorf("empty context")
|
||||
}
|
||||
mountPath, err := im.layer.Mount()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to mount %s", im.image.ImageID())
|
||||
}
|
||||
source, err := remotecontext.NewLazySource(mountPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create lazycontext for %s", mountPath)
|
||||
}
|
||||
im.source = source
|
||||
}
|
||||
return im.source, nil
|
||||
}
|
||||
|
||||
func (im *imageMount) unmount() error {
|
||||
if im.layer == nil {
|
||||
return nil
|
||||
@@ -133,8 +114,8 @@ func (im *imageMount) Image() builder.Image {
|
||||
return im.image
|
||||
}
|
||||
|
||||
func (im *imageMount) Layer() builder.ReleaseableLayer {
|
||||
return im.layer
|
||||
func (im *imageMount) NewRWLayer() (builder.RWLayer, error) {
|
||||
return im.layer.NewRWLayer()
|
||||
}
|
||||
|
||||
func (im *imageMount) ImageID() string {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/docker/docker/builder/dockerfile/command"
|
||||
"github.com/docker/docker/builder/dockerfile/parser"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestCommandsExactlyOneArgument(t *testing.T) {
|
||||
@@ -21,9 +21,9 @@ func TestCommandsExactlyOneArgument(t *testing.T) {
|
||||
|
||||
for _, command := range commands {
|
||||
ast, err := parser.Parse(strings.NewReader(command))
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
_, err = ParseInstruction(ast.AST.Children[0])
|
||||
assert.EqualError(t, err, errExactlyOneArgument(command).Error())
|
||||
assert.Check(t, is.Error(err, errExactlyOneArgument(command).Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ func TestCommandsAtLeastOneArgument(t *testing.T) {
|
||||
|
||||
for _, command := range commands {
|
||||
ast, err := parser.Parse(strings.NewReader(command))
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
_, err = ParseInstruction(ast.AST.Children[0])
|
||||
assert.EqualError(t, err, errAtLeastOneArgument(command).Error())
|
||||
assert.Check(t, is.Error(err, errAtLeastOneArgument(command).Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ func TestCommandsNoDestinationArgument(t *testing.T) {
|
||||
|
||||
for _, command := range commands {
|
||||
ast, err := parser.Parse(strings.NewReader(command + " arg1"))
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
_, err = ParseInstruction(ast.AST.Children[0])
|
||||
assert.EqualError(t, err, errNoDestinationArgument(command).Error())
|
||||
assert.Check(t, is.Error(err, errNoDestinationArgument(command).Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestCommandsTooManyArguments(t *testing.T) {
|
||||
},
|
||||
}
|
||||
_, err := ParseInstruction(node)
|
||||
assert.EqualError(t, err, errTooManyArguments(command).Error())
|
||||
assert.Check(t, is.Error(err, errTooManyArguments(command).Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestCommandsBlankNames(t *testing.T) {
|
||||
},
|
||||
}
|
||||
_, err := ParseInstruction(node)
|
||||
assert.EqualError(t, err, errBlankCommandNames(command).Error())
|
||||
assert.Check(t, is.Error(err, errBlankCommandNames(command).Error()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +120,11 @@ func TestHealthCheckCmd(t *testing.T) {
|
||||
},
|
||||
}
|
||||
cmd, err := ParseInstruction(node)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
hc, ok := cmd.(*HealthCheckCommand)
|
||||
assert.True(t, ok)
|
||||
assert.Check(t, ok)
|
||||
expected := []string{"CMD-SHELL", "hello world"}
|
||||
assert.Equal(t, expected, hc.Health.Test)
|
||||
assert.Check(t, is.DeepEqual(expected, hc.Health.Test))
|
||||
}
|
||||
|
||||
func TestParseOptInterval(t *testing.T) {
|
||||
@@ -138,7 +138,7 @@ func TestParseOptInterval(t *testing.T) {
|
||||
|
||||
flInterval.Value = "1ms"
|
||||
_, err = parseOptInterval(flInterval)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
func TestErrorCases(t *testing.T) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/backend"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/builder"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/chrootarchive"
|
||||
@@ -114,8 +115,8 @@ func (b *Builder) commitContainer(dispatchState *dispatchState, id string, conta
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *Builder) exportImage(state *dispatchState, imageMount *imageMount, runConfig *container.Config) error {
|
||||
newLayer, err := imageMount.Layer().Commit()
|
||||
func (b *Builder) exportImage(state *dispatchState, layer builder.RWLayer, parent builder.Image, runConfig *container.Config) error {
|
||||
newLayer, err := layer.Commit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -124,7 +125,7 @@ func (b *Builder) exportImage(state *dispatchState, imageMount *imageMount, runC
|
||||
// if there is an error before we can add the full mount with image
|
||||
b.imageSources.Add(newImageMount(nil, newLayer))
|
||||
|
||||
parentImage, ok := imageMount.Image().(*image.Image)
|
||||
parentImage, ok := parent.(*image.Image)
|
||||
if !ok {
|
||||
return errors.Errorf("unexpected image type")
|
||||
}
|
||||
@@ -177,7 +178,13 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
|
||||
return errors.Wrapf(err, "failed to get destination image %q", state.imageID)
|
||||
}
|
||||
|
||||
destInfo, err := createDestInfo(state.runConfig.WorkingDir, inst, imageMount, b.options.Platform)
|
||||
rwLayer, err := imageMount.NewRWLayer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rwLayer.Release()
|
||||
|
||||
destInfo, err := createDestInfo(state.runConfig.WorkingDir, inst, rwLayer, b.options.Platform)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -203,10 +210,10 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
|
||||
return errors.Wrapf(err, "failed to copy files")
|
||||
}
|
||||
}
|
||||
return b.exportImage(state, imageMount, runConfigWithCommentCmd)
|
||||
return b.exportImage(state, rwLayer, imageMount.Image(), runConfigWithCommentCmd)
|
||||
}
|
||||
|
||||
func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMount, platform string) (copyInfo, error) {
|
||||
func createDestInfo(workingDir string, inst copyInstruction, rwLayer builder.RWLayer, platform string) (copyInfo, error) {
|
||||
// Twiddle the destination when it's a relative path - meaning, make it
|
||||
// relative to the WORKINGDIR
|
||||
dest, err := normalizeDest(workingDir, inst.dest, platform)
|
||||
@@ -214,12 +221,7 @@ func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMo
|
||||
return copyInfo{}, errors.Wrapf(err, "invalid %s", inst.cmdName)
|
||||
}
|
||||
|
||||
destMount, err := imageMount.Source()
|
||||
if err != nil {
|
||||
return copyInfo{}, errors.Wrapf(err, "failed to mount copy source")
|
||||
}
|
||||
|
||||
return newCopyInfoFromSource(destMount, dest, ""), nil
|
||||
return copyInfo{root: rwLayer.Root(), path: dest}, nil
|
||||
}
|
||||
|
||||
// normalizeDest normalises the destination of a COPY/ADD command in a
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestChownFlagParsing(t *testing.T) {
|
||||
@@ -99,8 +99,8 @@ othergrp:x:6666:
|
||||
} {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
idPair, err := parseChownFlag(testcase.chownStr, contextDir, testcase.idMapping)
|
||||
require.NoError(t, err, "Failed to parse chown flag: %q", testcase.chownStr)
|
||||
assert.Equal(t, testcase.expected, idPair, "chown flag mapping failure")
|
||||
assert.NilError(t, err, "Failed to parse chown flag: %q", testcase.chownStr)
|
||||
assert.Check(t, is.DeepEqual(testcase.expected, idPair), "chown flag mapping failure")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ othergrp:x:6666:
|
||||
} {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
_, err := parseChownFlag(testcase.chownStr, contextDir, testcase.idMapping)
|
||||
assert.EqualError(t, err, testcase.descr, "Expected error string doesn't match")
|
||||
assert.Check(t, is.Error(err, testcase.descr), "Expected error string doesn't match")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/docker/docker/builder/remotecontext"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestEmptyDockerfile(t *testing.T) {
|
||||
@@ -60,7 +60,7 @@ func TestNonExistingDockerfile(t *testing.T) {
|
||||
|
||||
func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath, expectedError string) {
|
||||
tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
defer func() {
|
||||
if err = tarStream.Close(); err != nil {
|
||||
@@ -77,7 +77,7 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath,
|
||||
Source: tarStream,
|
||||
}
|
||||
_, _, err = remotecontext.Detect(config)
|
||||
assert.EqualError(t, err, expectedError)
|
||||
assert.Check(t, is.Error(err, expectedError))
|
||||
}
|
||||
|
||||
func TestCopyRunConfig(t *testing.T) {
|
||||
@@ -124,9 +124,9 @@ func TestCopyRunConfig(t *testing.T) {
|
||||
Env: defaultEnv,
|
||||
}
|
||||
runConfigCopy := copyRunConfig(runConfig, testcase.modifiers...)
|
||||
assert.Equal(t, testcase.expected, runConfigCopy, testcase.doc)
|
||||
assert.Check(t, is.DeepEqual(testcase.expected, runConfigCopy), testcase.doc)
|
||||
// Assert the original was not modified
|
||||
assert.NotEqual(t, runConfig, runConfigCopy, testcase.doc)
|
||||
assert.Check(t, runConfig != runConfigCopy, testcase.doc)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func fullMutableRunConfig() *container.Config {
|
||||
func TestDeepCopyRunConfig(t *testing.T) {
|
||||
runConfig := fullMutableRunConfig()
|
||||
copy := copyRunConfig(runConfig)
|
||||
assert.Equal(t, fullMutableRunConfig(), copy)
|
||||
assert.Check(t, is.DeepEqual(fullMutableRunConfig(), copy))
|
||||
|
||||
copy.Cmd[1] = "arg2"
|
||||
copy.Env[1] = "env2=new"
|
||||
@@ -166,5 +166,5 @@ func TestDeepCopyRunConfig(t *testing.T) {
|
||||
copy.OnBuild[0] = "start"
|
||||
copy.Labels["label3"] = "value3"
|
||||
copy.Shell[0] = "sh"
|
||||
assert.Equal(t, fullMutableRunConfig(), runConfig)
|
||||
assert.Check(t, is.DeepEqual(fullMutableRunConfig(), runConfig))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestNormalizeDest(t *testing.T) {
|
||||
@@ -42,10 +43,10 @@ func TestNormalizeDest(t *testing.T) {
|
||||
msg := fmt.Sprintf("Input: %s, %s", testcase.current, testcase.requested)
|
||||
actual, err := normalizeDest(testcase.current, testcase.requested, "windows")
|
||||
if testcase.etext == "" {
|
||||
if !assert.NoError(t, err, msg) {
|
||||
if !assert.Check(t, err, msg) {
|
||||
continue
|
||||
}
|
||||
assert.Equal(t, testcase.expected, actual, msg)
|
||||
assert.Check(t, is.Equal(testcase.expected, actual), msg)
|
||||
} else {
|
||||
testutil.ErrorContains(t, err, testcase.etext)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
type MockBackend struct {
|
||||
containerCreateFunc func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
|
||||
commitFunc func(backend.CommitConfig) (image.ID, error)
|
||||
getImageFunc func(string) (builder.Image, builder.ReleaseableLayer, error)
|
||||
getImageFunc func(string) (builder.Image, builder.ROLayer, error)
|
||||
makeImageCacheFunc func(cacheFrom []string) builder.ImageCache
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (m *MockBackend) CopyOnBuild(containerID string, destPath string, srcRoot s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockBackend) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
func (m *MockBackend) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
|
||||
if m.getImageFunc != nil {
|
||||
return m.getImageFunc(refOrID)
|
||||
}
|
||||
@@ -124,14 +124,25 @@ func (l *mockLayer) Release() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *mockLayer) Mount() (containerfs.ContainerFS, error) {
|
||||
return containerfs.NewLocalContainerFS("mountPath"), nil
|
||||
}
|
||||
|
||||
func (l *mockLayer) Commit() (builder.ReleaseableLayer, error) {
|
||||
return nil, nil
|
||||
func (l *mockLayer) NewRWLayer() (builder.RWLayer, error) {
|
||||
return &mockRWLayer{}, nil
|
||||
}
|
||||
|
||||
func (l *mockLayer) DiffID() layer.DiffID {
|
||||
return layer.DiffID("abcdef")
|
||||
}
|
||||
|
||||
type mockRWLayer struct {
|
||||
}
|
||||
|
||||
func (l *mockRWLayer) Release() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *mockRWLayer) Commit() (builder.ROLayer, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (l *mockRWLayer) Root() containerfs.ContainerFS {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,25 +3,29 @@ package parser // import "github.com/docker/docker/builder/dockerfile/parser"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestParseNameValOldFormat(t *testing.T) {
|
||||
directive := Directive{}
|
||||
node, err := parseNameVal("foo bar", "LABEL", &directive)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
expected := &Node{
|
||||
Value: "foo",
|
||||
Next: &Node{Value: "bar"},
|
||||
}
|
||||
assert.Equal(t, expected, node)
|
||||
assert.DeepEqual(t, expected, node, cmpNodeOpt)
|
||||
}
|
||||
|
||||
var cmpNodeOpt = cmp.AllowUnexported(Node{})
|
||||
|
||||
func TestParseNameValNewFormat(t *testing.T) {
|
||||
directive := Directive{}
|
||||
node, err := parseNameVal("foo=bar thing=star", "LABEL", &directive)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
expected := &Node{
|
||||
Value: "foo",
|
||||
@@ -35,7 +39,7 @@ func TestParseNameValNewFormat(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, expected, node)
|
||||
assert.DeepEqual(t, expected, node, cmpNodeOpt)
|
||||
}
|
||||
|
||||
func TestNodeFromLabels(t *testing.T) {
|
||||
@@ -61,8 +65,7 @@ func TestNodeFromLabels(t *testing.T) {
|
||||
}
|
||||
|
||||
node := NodeFromLabels(labels)
|
||||
assert.Equal(t, expected, node)
|
||||
|
||||
assert.DeepEqual(t, expected, node, cmpNodeOpt)
|
||||
}
|
||||
|
||||
func TestParseNameValWithoutVal(t *testing.T) {
|
||||
@@ -70,5 +73,5 @@ func TestParseNameValWithoutVal(t *testing.T) {
|
||||
// In Config.Env, a variable without `=` is removed from the environment. (#31634)
|
||||
// However, in Dockerfile, we don't allow "unsetting" an environment variable. (#11922)
|
||||
_, err := parseNameVal("foo", "ENV", &directive)
|
||||
assert.Error(t, err, "ENV must have two arguments")
|
||||
assert.Check(t, is.ErrorContains(err, ""), "ENV must have two arguments")
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
const testDir = "testfiles"
|
||||
@@ -21,11 +21,11 @@ const testFileLineInfo = "testfile-line/Dockerfile"
|
||||
|
||||
func getDirs(t *testing.T, dir string) []string {
|
||||
f, err := os.Open(dir)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer f.Close()
|
||||
|
||||
dirs, err := f.Readdirnames(0)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
return dirs
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ func TestParseErrorCases(t *testing.T) {
|
||||
dockerfile := filepath.Join(negativeTestDir, dir, "Dockerfile")
|
||||
|
||||
df, err := os.Open(dockerfile)
|
||||
require.NoError(t, err, dockerfile)
|
||||
assert.NilError(t, err, dockerfile)
|
||||
defer df.Close()
|
||||
|
||||
_, err = Parse(df)
|
||||
assert.Error(t, err, dockerfile)
|
||||
assert.Check(t, is.ErrorContains(err, ""), dockerfile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,20 +48,20 @@ func TestParseCases(t *testing.T) {
|
||||
resultfile := filepath.Join(testDir, dir, "result")
|
||||
|
||||
df, err := os.Open(dockerfile)
|
||||
require.NoError(t, err, dockerfile)
|
||||
assert.NilError(t, err, dockerfile)
|
||||
defer df.Close()
|
||||
|
||||
result, err := Parse(df)
|
||||
require.NoError(t, err, dockerfile)
|
||||
assert.NilError(t, err, dockerfile)
|
||||
|
||||
content, err := ioutil.ReadFile(resultfile)
|
||||
require.NoError(t, err, resultfile)
|
||||
assert.NilError(t, err, resultfile)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
// CRLF --> CR to match Unix behavior
|
||||
content = bytes.Replace(content, []byte{'\x0d', '\x0a'}, []byte{'\x0a'}, -1)
|
||||
}
|
||||
assert.Equal(t, result.AST.Dump()+"\n", string(content), "In "+dockerfile)
|
||||
assert.Check(t, is.Equal(result.AST.Dump()+"\n", string(content)), "In "+dockerfile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,22 +103,22 @@ func TestParseWords(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
words := parseWords(test["input"][0], NewDefaultDirective())
|
||||
assert.Equal(t, test["expect"], words)
|
||||
assert.Check(t, is.DeepEqual(test["expect"], words))
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseIncludesLineNumbers(t *testing.T) {
|
||||
df, err := os.Open(testFileLineInfo)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer df.Close()
|
||||
|
||||
result, err := Parse(df)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ast := result.AST
|
||||
assert.Equal(t, 5, ast.StartLine)
|
||||
assert.Equal(t, 31, ast.endLine)
|
||||
assert.Len(t, ast.Children, 3)
|
||||
assert.Check(t, is.Equal(5, ast.StartLine))
|
||||
assert.Check(t, is.Equal(31, ast.endLine))
|
||||
assert.Check(t, is.Len(ast.Children, 3))
|
||||
expected := [][]int{
|
||||
{5, 5},
|
||||
{11, 12},
|
||||
@@ -126,7 +126,7 @@ func TestParseIncludesLineNumbers(t *testing.T) {
|
||||
}
|
||||
for i, child := range ast.Children {
|
||||
msg := fmt.Sprintf("Child %d", i)
|
||||
assert.Equal(t, expected[i], []int{child.StartLine, child.endLine}, msg)
|
||||
assert.Check(t, is.DeepEqual(expected[i], []int{child.StartLine, child.endLine}), msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,13 +153,13 @@ RUN indented \
|
||||
`)
|
||||
|
||||
result, err := Parse(dockerfile)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
warnings := result.Warnings
|
||||
assert.Len(t, warnings, 3)
|
||||
assert.Contains(t, warnings[0], "Empty continuation line found in")
|
||||
assert.Contains(t, warnings[0], "RUN something following more")
|
||||
assert.Contains(t, warnings[1], "RUN another thing")
|
||||
assert.Contains(t, warnings[2], "will become errors in a future release")
|
||||
assert.Check(t, is.Len(warnings, 3))
|
||||
assert.Check(t, is.Contains(warnings[0], "Empty continuation line found in"))
|
||||
assert.Check(t, is.Contains(warnings[0], "RUN something following more"))
|
||||
assert.Check(t, is.Contains(warnings[1], "RUN another thing"))
|
||||
assert.Check(t, is.Contains(warnings[2], "will become errors in a future release"))
|
||||
}
|
||||
|
||||
func TestParseReturnsScannerErrors(t *testing.T) {
|
||||
@@ -170,5 +170,5 @@ func TestParseReturnsScannerErrors(t *testing.T) {
|
||||
LABEL test=%s
|
||||
`, label))
|
||||
_, err := Parse(dockerfile)
|
||||
assert.EqualError(t, err, "dockerfile line greater than max allowed size of 65535")
|
||||
assert.Check(t, is.Error(err, "dockerfile line greater than max allowed size of 65535"))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestShellParser4EnvVars(t *testing.T) {
|
||||
@@ -15,7 +16,7 @@ func TestShellParser4EnvVars(t *testing.T) {
|
||||
lineCount := 0
|
||||
|
||||
file, err := os.Open(fn)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
defer file.Close()
|
||||
|
||||
shlex := NewLex('\\')
|
||||
@@ -37,7 +38,7 @@ func TestShellParser4EnvVars(t *testing.T) {
|
||||
}
|
||||
|
||||
words := strings.Split(line, "|")
|
||||
assert.Len(t, words, 3)
|
||||
assert.Check(t, is.Len(words, 3))
|
||||
|
||||
platform := strings.TrimSpace(words[0])
|
||||
source := strings.TrimSpace(words[1])
|
||||
@@ -52,10 +53,10 @@ func TestShellParser4EnvVars(t *testing.T) {
|
||||
((platform == "U" || platform == "A") && runtime.GOOS != "windows") {
|
||||
newWord, err := shlex.ProcessWord(source, envs)
|
||||
if expected == "error" {
|
||||
assert.Error(t, err)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, newWord, expected)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(newWord, expected))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/moby/buildkit/session/filesync"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestFSCache(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "fscache")
|
||||
assert.Nil(t, err)
|
||||
assert.Check(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
backend := NewNaiveCacheBackend(filepath.Join(tmpDir, "backend"))
|
||||
@@ -26,84 +27,84 @@ func TestFSCache(t *testing.T) {
|
||||
}
|
||||
|
||||
fscache, err := NewFSCache(opt)
|
||||
assert.Nil(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
defer fscache.Close()
|
||||
|
||||
err = fscache.RegisterTransport("test", &testTransport{})
|
||||
assert.Nil(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
src1, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo", "data", "bar"})
|
||||
assert.Nil(t, err)
|
||||
assert.Check(t, err)
|
||||
|
||||
dt, err := ioutil.ReadFile(filepath.Join(src1.Root().Path(), "foo"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, string(dt), "data")
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(string(dt), "data"))
|
||||
|
||||
// same id doesn't recalculate anything
|
||||
src2, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo", "data2", "bar"})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, src1.Root().Path(), src2.Root().Path())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(src1.Root().Path(), src2.Root().Path()))
|
||||
|
||||
dt, err = ioutil.ReadFile(filepath.Join(src1.Root().Path(), "foo"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, string(dt), "data")
|
||||
assert.Nil(t, src2.Close())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(string(dt), "data"))
|
||||
assert.Check(t, src2.Close())
|
||||
|
||||
src3, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo2", "data2", "bar"})
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, src1.Root().Path(), src3.Root().Path())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, src1.Root().Path() != src3.Root().Path())
|
||||
|
||||
dt, err = ioutil.ReadFile(filepath.Join(src3.Root().Path(), "foo2"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, string(dt), "data2")
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(string(dt), "data2"))
|
||||
|
||||
s, err := fscache.DiskUsage()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s, int64(0))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(s, int64(0)))
|
||||
|
||||
assert.Nil(t, src3.Close())
|
||||
assert.Check(t, src3.Close())
|
||||
|
||||
s, err = fscache.DiskUsage()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s, int64(5))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(s, int64(5)))
|
||||
|
||||
// new upload with the same shared key shoutl overwrite
|
||||
src4, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo3", "data3", "bar"})
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, src1.Root().Path(), src3.Root().Path())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, src1.Root().Path() != src3.Root().Path())
|
||||
|
||||
dt, err = ioutil.ReadFile(filepath.Join(src3.Root().Path(), "foo3"))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, string(dt), "data3")
|
||||
assert.Equal(t, src4.Root().Path(), src3.Root().Path())
|
||||
assert.Nil(t, src4.Close())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(string(dt), "data3"))
|
||||
assert.Check(t, is.Equal(src4.Root().Path(), src3.Root().Path()))
|
||||
assert.Check(t, src4.Close())
|
||||
|
||||
s, err = fscache.DiskUsage()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s, int64(10))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(s, int64(10)))
|
||||
|
||||
// this one goes over the GC limit
|
||||
src5, err := fscache.SyncFrom(context.TODO(), &testIdentifier{"foo4", "datadata", "baz"})
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, src5.Close())
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, src5.Close())
|
||||
|
||||
// GC happens async
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
// only last insertion after GC
|
||||
s, err = fscache.DiskUsage()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s, int64(8))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(s, int64(8)))
|
||||
|
||||
// prune deletes everything
|
||||
released, err := fscache.Prune(context.TODO())
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, released, uint64(8))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(released, uint64(8)))
|
||||
|
||||
s, err = fscache.DiskUsage()
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, s, int64(0))
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(s, int64(0)))
|
||||
}
|
||||
|
||||
type testTransport struct {
|
||||
|
||||
@@ -13,42 +13,39 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestParseRemoteURL(t *testing.T) {
|
||||
dir, err := parseRemoteURL("git://github.com/user/repo.git")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"git://github.com/user/repo.git", "master", ""}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
||||
|
||||
dir, err = parseRemoteURL("git://github.com/user/repo.git#mybranch:mydir/mysubdir/")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"git://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
||||
|
||||
dir, err = parseRemoteURL("https://github.com/user/repo.git")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"https://github.com/user/repo.git", "master", ""}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
||||
|
||||
dir, err = parseRemoteURL("https://github.com/user/repo.git#mybranch:mydir/mysubdir/")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"https://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
||||
|
||||
dir, err = parseRemoteURL("git@github.com:user/repo.git")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"git@github.com:user/repo.git", "master", ""}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
||||
|
||||
dir, err = parseRemoteURL("git@github.com:user/repo.git#mybranch:mydir/mysubdir/")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, dir)
|
||||
assert.Equal(t, gitRepo{"git@github.com:user/repo.git", "mybranch", "mydir/mysubdir/"}, dir)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
||||
}
|
||||
|
||||
var cmpGitRepoOpt = cmp.AllowUnexported(gitRepo{})
|
||||
|
||||
func TestCloneArgsSmartHttp(t *testing.T) {
|
||||
mux := http.NewServeMux()
|
||||
server := httptest.NewServer(mux)
|
||||
@@ -63,7 +60,7 @@ func TestCloneArgsSmartHttp(t *testing.T) {
|
||||
|
||||
args := fetchArgs(serverURL.String(), "master")
|
||||
exp := []string{"fetch", "--depth", "1", "origin", "master"}
|
||||
assert.Equal(t, exp, args)
|
||||
assert.Check(t, is.DeepEqual(exp, args))
|
||||
}
|
||||
|
||||
func TestCloneArgsDumbHttp(t *testing.T) {
|
||||
@@ -79,13 +76,13 @@ func TestCloneArgsDumbHttp(t *testing.T) {
|
||||
|
||||
args := fetchArgs(serverURL.String(), "master")
|
||||
exp := []string{"fetch", "origin", "master"}
|
||||
assert.Equal(t, exp, args)
|
||||
assert.Check(t, is.DeepEqual(exp, args))
|
||||
}
|
||||
|
||||
func TestCloneArgsGit(t *testing.T) {
|
||||
args := fetchArgs("git://github.com/docker/docker", "master")
|
||||
exp := []string{"fetch", "--depth", "1", "origin", "master"}
|
||||
assert.Equal(t, exp, args)
|
||||
assert.Check(t, is.DeepEqual(exp, args))
|
||||
}
|
||||
|
||||
func gitGetConfig(name string) string {
|
||||
@@ -100,7 +97,7 @@ func gitGetConfig(name string) string {
|
||||
|
||||
func TestCheckoutGit(t *testing.T) {
|
||||
root, err := ioutil.TempDir("", "docker-build-git-checkout")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
autocrlf := gitGetConfig("core.autocrlf")
|
||||
@@ -115,22 +112,22 @@ func TestCheckoutGit(t *testing.T) {
|
||||
|
||||
gitDir := filepath.Join(root, "repo")
|
||||
_, err = git("init", gitDir)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "config", "user.email", "test@docker.com")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "config", "user.name", "Docker test")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch"), 0644)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
subDir := filepath.Join(gitDir, "subdir")
|
||||
require.NoError(t, os.Mkdir(subDir, 0755))
|
||||
assert.NilError(t, os.Mkdir(subDir, 0755))
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 5000"), 0644)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
if err = os.Symlink("../subdir", filepath.Join(gitDir, "parentlink")); err != nil {
|
||||
@@ -143,58 +140,58 @@ func TestCheckoutGit(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err = gitWithinDir(gitDir, "add", "-A")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "commit", "-am", "First commit")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "checkout", "-b", "test")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 3000"), 0644)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM busybox\nEXPOSE 5000"), 0644)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "add", "-A")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "commit", "-am", "Branch commit")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "checkout", "master")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// set up submodule
|
||||
subrepoDir := filepath.Join(root, "subrepo")
|
||||
_, err = git("init", subrepoDir)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(subrepoDir, "config", "user.email", "test@docker.com")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(subrepoDir, "config", "user.name", "Docker test")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(subrepoDir, "subfile"), []byte("subcontents"), 0644)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(subrepoDir, "add", "-A")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(subrepoDir, "commit", "-am", "Subrepo initial")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
cmd := exec.Command("git", "submodule", "add", subrepoDir, "sub") // this command doesn't work with --work-tree
|
||||
cmd.Dir = gitDir
|
||||
require.NoError(t, cmd.Run())
|
||||
assert.NilError(t, cmd.Run())
|
||||
|
||||
_, err = gitWithinDir(gitDir, "add", "-A")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = gitWithinDir(gitDir, "commit", "-am", "With submodule")
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
type singleCase struct {
|
||||
frag string
|
||||
@@ -232,24 +229,24 @@ func TestCheckoutGit(t *testing.T) {
|
||||
r, err := cloneGitRepo(gitRepo{remote: gitDir, ref: ref, subdir: subdir})
|
||||
|
||||
if c.fail {
|
||||
assert.Error(t, err)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
continue
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(r)
|
||||
if c.submodule {
|
||||
b, err := ioutil.ReadFile(filepath.Join(r, "sub/subfile"))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "subcontents", string(b))
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("subcontents", string(b)))
|
||||
} else {
|
||||
_, err := os.Stat(filepath.Join(r, "sub/subfile"))
|
||||
require.Error(t, err)
|
||||
require.True(t, os.IsNotExist(err))
|
||||
assert.Assert(t, is.ErrorContains(err, ""))
|
||||
assert.Assert(t, os.IsNotExist(err))
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(filepath.Join(r, "Dockerfile"))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, c.exp, string(b))
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(c.exp, string(b)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package remotecontext // import "github.com/docker/docker/builder/remotecontext"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
)
|
||||
|
||||
func TestDetectContentType(t *testing.T) {
|
||||
input := []byte("That is just a plain text")
|
||||
|
||||
contentType, _, err := detectContentType(input)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "text/plain", contentType)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("text/plain", contentType))
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
"github.com/docker/docker/builder"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var binaryContext = []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00} //xz magic
|
||||
@@ -189,12 +189,12 @@ func TestDownloadRemote(t *testing.T) {
|
||||
mux.Handle("/", http.FileServer(http.Dir(contextDir.Path())))
|
||||
|
||||
contentType, content, err := downloadRemote(remoteURL)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Equal(t, mimeTypes.TextPlain, contentType)
|
||||
assert.Check(t, is.Equal(mimeTypes.TextPlain, contentType))
|
||||
raw, err := ioutil.ReadAll(content)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, dockerfileContents, string(raw))
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(dockerfileContents, string(raw)))
|
||||
}
|
||||
|
||||
func TestGetWithStatusError(t *testing.T) {
|
||||
@@ -226,11 +226,11 @@ func TestGetWithStatusError(t *testing.T) {
|
||||
response, err := GetWithStatusError(ts.URL)
|
||||
|
||||
if testcase.expectedErr == "" {
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
body, err := readBody(response.Body)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(body), testcase.expectedBody)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Contains(string(body), testcase.expectedBody))
|
||||
} else {
|
||||
testutil.ErrorContains(t, err, testcase.expectedErr)
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/env"
|
||||
"github.com/gotestyourself/gotestyourself/skip"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewEnvClient(t *testing.T) {
|
||||
@@ -89,19 +89,18 @@ func TestNewEnvClient(t *testing.T) {
|
||||
env.PatchAll(t, c.envs)
|
||||
apiclient, err := NewEnvClient()
|
||||
if c.expectedError != "" {
|
||||
assert.Error(t, err, c.doc)
|
||||
assert.Equal(t, c.expectedError, err.Error(), c.doc)
|
||||
assert.Check(t, is.Error(err, c.expectedError), c.doc)
|
||||
} else {
|
||||
assert.NoError(t, err, c.doc)
|
||||
assert.Check(t, err, c.doc)
|
||||
version := apiclient.ClientVersion()
|
||||
assert.Equal(t, c.expectedVersion, version, c.doc)
|
||||
assert.Check(t, is.Equal(c.expectedVersion, version), c.doc)
|
||||
}
|
||||
|
||||
if c.envs["DOCKER_TLS_VERIFY"] != "" {
|
||||
// pedantic checking that this is handled correctly
|
||||
tr := apiclient.client.Transport.(*http.Transport)
|
||||
assert.NotNil(t, tr.TLSClientConfig, c.doc)
|
||||
assert.Equal(t, tr.TLSClientConfig.InsecureSkipVerify, false, c.doc)
|
||||
assert.Assert(t, tr.TLSClientConfig != nil, c.doc)
|
||||
assert.Check(t, is.Equal(tr.TLSClientConfig.InsecureSkipVerify, false), c.doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +127,7 @@ func TestGetAPIPath(t *testing.T) {
|
||||
for _, testcase := range testcases {
|
||||
c := Client{version: testcase.version, basePath: "/"}
|
||||
actual := c.getAPIPath(testcase.path, testcase.query)
|
||||
assert.Equal(t, actual, testcase.expected)
|
||||
assert.Check(t, is.Equal(actual, testcase.expected))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +164,7 @@ func TestParseHostURL(t *testing.T) {
|
||||
if testcase.expectedErr != "" {
|
||||
testutil.ErrorContains(t, err, testcase.expectedErr)
|
||||
}
|
||||
assert.Equal(t, testcase.expected, actual)
|
||||
assert.Check(t, is.DeepEqual(testcase.expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, client.version, api.DefaultVersion)
|
||||
assert.Check(t, is.Equal(client.version, api.DefaultVersion))
|
||||
|
||||
expected := "1.22"
|
||||
os.Setenv("DOCKER_API_VERSION", expected)
|
||||
@@ -189,7 +188,7 @@ func TestNewEnvClientSetsDefaultVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, expected, client.version)
|
||||
assert.Check(t, is.Equal(expected, client.version))
|
||||
}
|
||||
|
||||
// TestNegotiateAPIVersionEmpty asserts that client.Client can
|
||||
@@ -198,7 +197,7 @@ func TestNegotiateAPIVersionEmpty(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": ""})
|
||||
|
||||
client, err := NewEnvClient()
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ping := types.Ping{
|
||||
APIVersion: "",
|
||||
@@ -215,14 +214,14 @@ func TestNegotiateAPIVersionEmpty(t *testing.T) {
|
||||
|
||||
// test downgrade
|
||||
client.NegotiateAPIVersionPing(ping)
|
||||
assert.Equal(t, expected, client.version)
|
||||
assert.Check(t, is.Equal(expected, client.version))
|
||||
}
|
||||
|
||||
// TestNegotiateAPIVersion asserts that client.Client can
|
||||
// negotiate a compatible APIVersion with the server
|
||||
func TestNegotiateAPIVersion(t *testing.T) {
|
||||
client, err := NewEnvClient()
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
expected := "1.21"
|
||||
ping := types.Ping{
|
||||
@@ -236,14 +235,14 @@ func TestNegotiateAPIVersion(t *testing.T) {
|
||||
|
||||
// test downgrade
|
||||
client.NegotiateAPIVersionPing(ping)
|
||||
assert.Equal(t, expected, client.version)
|
||||
assert.Check(t, is.Equal(expected, client.version))
|
||||
|
||||
// set the client version to something older, and verify that we keep the
|
||||
// original setting.
|
||||
expected = "1.20"
|
||||
client.version = expected
|
||||
client.NegotiateAPIVersionPing(ping)
|
||||
assert.Equal(t, expected, client.version)
|
||||
assert.Check(t, is.Equal(expected, client.version))
|
||||
|
||||
}
|
||||
|
||||
@@ -254,7 +253,7 @@ func TestNegotiateAPVersionOverride(t *testing.T) {
|
||||
defer env.PatchAll(t, map[string]string{"DOCKER_API_VERSION": expected})()
|
||||
|
||||
client, err := NewEnvClient()
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
ping := types.Ping{
|
||||
APIVersion: "1.24",
|
||||
@@ -264,7 +263,7 @@ func TestNegotiateAPVersionOverride(t *testing.T) {
|
||||
|
||||
// test that we honored the env var
|
||||
client.NegotiateAPIVersionPing(ping)
|
||||
assert.Equal(t, expected, client.version)
|
||||
assert.Check(t, is.Equal(expected, client.version))
|
||||
}
|
||||
|
||||
type roundTripFunc func(*http.Request) (*http.Response, error)
|
||||
@@ -298,7 +297,7 @@ func TestClientRedirect(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
httpMethod string
|
||||
expectedErr error
|
||||
expectedErr *url.Error
|
||||
statusCode int
|
||||
}{
|
||||
{http.MethodGet, nil, 301},
|
||||
@@ -309,9 +308,15 @@ func TestClientRedirect(t *testing.T) {
|
||||
|
||||
for _, tc := range cases {
|
||||
req, err := http.NewRequest(tc.httpMethod, "/redirectme", nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
resp, err := client.Do(req)
|
||||
assert.Equal(t, tc.expectedErr, err)
|
||||
assert.Equal(t, tc.statusCode, resp.StatusCode)
|
||||
assert.Check(t, is.Equal(tc.statusCode, resp.StatusCode))
|
||||
if tc.expectedErr == nil {
|
||||
assert.Check(t, is.Nil(err))
|
||||
} else {
|
||||
urlError, ok := err.(*url.Error)
|
||||
assert.Assert(t, ok, "%T is not *url.Error", err)
|
||||
assert.Check(t, is.Equal(*tc.expectedErr, *urlError))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -21,7 +22,7 @@ func TestConfigCreateUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, err := client.ConfigCreate(context.Background(), swarm.ConfigSpec{})
|
||||
assert.EqualError(t, err, `"config create" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"config create" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestConfigCreateError(t *testing.T) {
|
||||
|
||||
@@ -10,8 +10,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -44,7 +45,7 @@ func TestConfigInspectUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, _, err := client.ConfigInspectWithRaw(context.Background(), "nothing")
|
||||
assert.EqualError(t, err, `"config inspect" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"config inspect" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestConfigInspectError(t *testing.T) {
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ func TestConfigListUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, err := client.ConfigList(context.Background(), types.ConfigListOptions{})
|
||||
assert.EqualError(t, err, `"config list" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"config list" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestConfigListError(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ func TestConfigRemoveUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
err := client.ConfigRemove(context.Background(), "config_id")
|
||||
assert.EqualError(t, err, `"config remove" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"config remove" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestConfigRemoveError(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -19,7 +20,7 @@ func TestConfigUpdateUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
err := client.ConfigUpdate(context.Background(), "config_id", swarm.Version{}, swarm.ConfigSpec{})
|
||||
assert.EqualError(t, err, `"config update" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"config update" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestConfigUpdateError(t *testing.T) {
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -24,7 +25,7 @@ func TestContainersPruneError(t *testing.T) {
|
||||
filters := filters.NewArgs()
|
||||
|
||||
_, err := client.ContainersPrune(context.Background(), filters)
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestContainersPrune(t *testing.T) {
|
||||
@@ -99,7 +100,7 @@ func TestContainersPrune(t *testing.T) {
|
||||
query := req.URL.Query()
|
||||
for key, expected := range listCase.expectedQueryParams {
|
||||
actual := query.Get(key)
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.Check(t, is.Equal(expected, actual))
|
||||
}
|
||||
content, err := json.Marshal(types.ContainersPruneReport{
|
||||
ContainersDeleted: []string{"container_id1", "container_id2"},
|
||||
@@ -117,8 +118,8 @@ func TestContainersPrune(t *testing.T) {
|
||||
}
|
||||
|
||||
report, err := client.ContainersPrune(context.Background(), listCase.filters)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, report.ContainersDeleted, 2)
|
||||
assert.Equal(t, uint64(9999), report.SpaceReclaimed)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Len(report.ContainersDeleted, 2))
|
||||
assert.Check(t, is.Equal(uint64(9999), report.SpaceReclaimed))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ func TestContainerRemoveError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{})
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestContainerRemoveNotFoundError(t *testing.T) {
|
||||
@@ -26,8 +27,8 @@ func TestContainerRemoveNotFoundError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusNotFound, "missing")),
|
||||
}
|
||||
err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{})
|
||||
assert.EqualError(t, err, "Error: No such container: container_id")
|
||||
assert.True(t, IsErrNotFound(err))
|
||||
assert.Check(t, is.Error(err, "Error: No such container: container_id"))
|
||||
assert.Check(t, IsErrNotFound(err))
|
||||
}
|
||||
|
||||
func TestContainerRemove(t *testing.T) {
|
||||
@@ -61,5 +62,5 @@ func TestContainerRemove(t *testing.T) {
|
||||
RemoveVolumes: true,
|
||||
Force: true,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -15,7 +16,7 @@ func TestDistributionInspectUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, err := client.DistributionInspect(context.Background(), "foobar:1.0", "")
|
||||
assert.EqualError(t, err, `"distribution inspect" requires API version 1.30, but the Docker daemon API version is 1.29`)
|
||||
assert.Check(t, is.Error(err, `"distribution inspect" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
||||
}
|
||||
|
||||
func TestDistributionInspectWithEmptyID(t *testing.T) {
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -24,7 +25,7 @@ func TestImagesPruneError(t *testing.T) {
|
||||
filters := filters.NewArgs()
|
||||
|
||||
_, err := client.ImagesPrune(context.Background(), filters)
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestImagesPrune(t *testing.T) {
|
||||
@@ -87,7 +88,7 @@ func TestImagesPrune(t *testing.T) {
|
||||
query := req.URL.Query()
|
||||
for key, expected := range listCase.expectedQueryParams {
|
||||
actual := query.Get(key)
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.Check(t, is.Equal(expected, actual))
|
||||
}
|
||||
content, err := json.Marshal(types.ImagesPruneReport{
|
||||
ImagesDeleted: []types.ImageDeleteResponseItem{
|
||||
@@ -112,8 +113,8 @@ func TestImagesPrune(t *testing.T) {
|
||||
}
|
||||
|
||||
report, err := client.ImagesPrune(context.Background(), listCase.filters)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, report.ImagesDeleted, 2)
|
||||
assert.Equal(t, uint64(9999), report.SpaceReclaimed)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Len(report.ImagesDeleted, 2))
|
||||
assert.Check(t, is.Equal(uint64(9999), report.SpaceReclaimed))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -20,7 +21,7 @@ func TestImageRemoveError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{})
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestImageRemoveImageNotFound(t *testing.T) {
|
||||
@@ -29,8 +30,8 @@ func TestImageRemoveImageNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{})
|
||||
assert.EqualError(t, err, "Error: No such image: unknown")
|
||||
assert.True(t, IsErrNotFound(err))
|
||||
assert.Check(t, is.Error(err, "Error: No such image: unknown"))
|
||||
assert.Check(t, IsErrNotFound(err))
|
||||
}
|
||||
|
||||
func TestImageRemove(t *testing.T) {
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ func TestNetworkInspectError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.NetworkInspect(context.Background(), "nothing", types.NetworkInspectOptions{})
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestNetworkInspectNotFoundError(t *testing.T) {
|
||||
@@ -31,8 +32,8 @@ func TestNetworkInspectNotFoundError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.NetworkInspect(context.Background(), "unknown", types.NetworkInspectOptions{})
|
||||
assert.EqualError(t, err, "Error: No such network: unknown")
|
||||
assert.True(t, IsErrNotFound(err))
|
||||
assert.Check(t, is.Error(err, "Error: No such network: unknown"))
|
||||
assert.Check(t, IsErrNotFound(err))
|
||||
}
|
||||
|
||||
func TestNetworkInspectWithEmptyID(t *testing.T) {
|
||||
@@ -113,5 +114,5 @@ func TestNetworkInspect(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err = client.NetworkInspect(context.Background(), "network_id", types.NetworkInspectOptions{Scope: "global"})
|
||||
assert.EqualError(t, err, "Error: No such network: network_id")
|
||||
assert.Check(t, is.Error(err, "Error: No such network: network_id"))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -89,7 +90,7 @@ func TestNetworksPrune(t *testing.T) {
|
||||
query := req.URL.Query()
|
||||
for key, expected := range listCase.expectedQueryParams {
|
||||
actual := query.Get(key)
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.Check(t, is.Equal(expected, actual))
|
||||
}
|
||||
content, err := json.Marshal(types.NetworksPruneReport{
|
||||
NetworksDeleted: []string{"network_id1", "network_id2"},
|
||||
@@ -106,7 +107,7 @@ func TestNetworksPrune(t *testing.T) {
|
||||
}
|
||||
|
||||
report, err := client.NetworksPrune(context.Background(), listCase.filters)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, report.NetworksDeleted, 2)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Len(report.NetworksDeleted, 2))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -31,15 +32,15 @@ func TestPingFail(t *testing.T) {
|
||||
}
|
||||
|
||||
ping, err := client.Ping(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, false, ping.Experimental)
|
||||
assert.Equal(t, "", ping.APIVersion)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
assert.Check(t, is.Equal(false, ping.Experimental))
|
||||
assert.Check(t, is.Equal("", ping.APIVersion))
|
||||
|
||||
withHeader = true
|
||||
ping2, err := client.Ping(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, true, ping2.Experimental)
|
||||
assert.Equal(t, "awesome", ping2.APIVersion)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
assert.Check(t, is.Equal(true, ping2.Experimental))
|
||||
assert.Check(t, is.Equal("awesome", ping2.APIVersion))
|
||||
}
|
||||
|
||||
// TestPingWithError tests the case where there is a protocol error in the ping.
|
||||
@@ -57,9 +58,9 @@ func TestPingWithError(t *testing.T) {
|
||||
}
|
||||
|
||||
ping, err := client.Ping(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, false, ping.Experimental)
|
||||
assert.Equal(t, "", ping.APIVersion)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
assert.Check(t, is.Equal(false, ping.Experimental))
|
||||
assert.Check(t, is.Equal("", ping.APIVersion))
|
||||
}
|
||||
|
||||
// TestPingSuccess tests that we are able to get the expected API headers/ping
|
||||
@@ -76,7 +77,7 @@ func TestPingSuccess(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
ping, err := client.Ping(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, true, ping.Experimental)
|
||||
assert.Equal(t, "awesome", ping.APIVersion)
|
||||
assert.Check(t, is.ErrorContains(err, ""))
|
||||
assert.Check(t, is.Equal(true, ping.Experimental))
|
||||
assert.Check(t, is.Equal("awesome", ping.APIVersion))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestSetHostHeader(t *testing.T) {
|
||||
|
||||
for c, test := range testCases {
|
||||
hostURL, err := ParseHostURL(test.host)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
|
||||
client := &Client{
|
||||
client: newMockClient(func(req *http.Request) (*http.Response, error) {
|
||||
@@ -71,7 +71,7 @@ func TestSetHostHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err = client.sendRequest(context.Background(), "GET", testURL, nil, nil, nil)
|
||||
require.NoError(t, err)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -21,7 +22,7 @@ func TestSecretCreateUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, err := client.SecretCreate(context.Background(), swarm.SecretSpec{})
|
||||
assert.EqualError(t, err, `"secret create" requires API version 1.25, but the Docker daemon API version is 1.24`)
|
||||
assert.Check(t, is.Error(err, `"secret create" requires API version 1.25, but the Docker daemon API version is 1.24`))
|
||||
}
|
||||
|
||||
func TestSecretCreateError(t *testing.T) {
|
||||
|
||||
@@ -10,8 +10,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -21,7 +22,7 @@ func TestSecretInspectUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, _, err := client.SecretInspectWithRaw(context.Background(), "nothing")
|
||||
assert.EqualError(t, err, `"secret inspect" requires API version 1.25, but the Docker daemon API version is 1.24`)
|
||||
assert.Check(t, is.Error(err, `"secret inspect" requires API version 1.25, but the Docker daemon API version is 1.24`))
|
||||
}
|
||||
|
||||
func TestSecretInspectError(t *testing.T) {
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ func TestSecretListUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
_, err := client.SecretList(context.Background(), types.SecretListOptions{})
|
||||
assert.EqualError(t, err, `"secret list" requires API version 1.25, but the Docker daemon API version is 1.24`)
|
||||
assert.Check(t, is.Error(err, `"secret list" requires API version 1.25, but the Docker daemon API version is 1.24`))
|
||||
}
|
||||
|
||||
func TestSecretListError(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ func TestSecretRemoveUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
err := client.SecretRemove(context.Background(), "secret_id")
|
||||
assert.EqualError(t, err, `"secret remove" requires API version 1.25, but the Docker daemon API version is 1.24`)
|
||||
assert.Check(t, is.Error(err, `"secret remove" requires API version 1.25, but the Docker daemon API version is 1.24`))
|
||||
}
|
||||
|
||||
func TestSecretRemoveError(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -19,7 +20,7 @@ func TestSecretUpdateUnsupported(t *testing.T) {
|
||||
client: &http.Client{},
|
||||
}
|
||||
err := client.SecretUpdate(context.Background(), "secret_id", swarm.Version{}, swarm.SecretSpec{})
|
||||
assert.EqualError(t, err, `"secret update" requires API version 1.25, but the Docker daemon API version is 1.24`)
|
||||
assert.Check(t, is.Error(err, `"secret update" requires API version 1.25, but the Docker daemon API version is 1.24`))
|
||||
}
|
||||
|
||||
func TestSecretUpdateError(t *testing.T) {
|
||||
|
||||
@@ -12,9 +12,10 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
registrytypes "github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -73,8 +74,8 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
assert.Equal(t, "foobar:1.0@sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96", serviceSpec.TaskTemplate.ContainerSpec.Image)
|
||||
assert.Len(t, serviceSpec.TaskTemplate.Placement.Platforms, 1)
|
||||
assert.Check(t, is.Equal("foobar:1.0@sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96", serviceSpec.TaskTemplate.ContainerSpec.Image))
|
||||
assert.Check(t, is.Len(serviceSpec.TaskTemplate.Placement.Platforms, 1))
|
||||
|
||||
p := serviceSpec.TaskTemplate.Placement.Platforms[0]
|
||||
b, err := json.Marshal(types.ServiceCreateResponse{
|
||||
@@ -115,8 +116,8 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
|
||||
spec := swarm.ServiceSpec{TaskTemplate: swarm.TaskSpec{ContainerSpec: &swarm.ContainerSpec{Image: "foobar:1.0"}}}
|
||||
|
||||
r, err := client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{QueryRegistry: true})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "service_linux_amd64", r.ID)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("service_linux_amd64", r.ID))
|
||||
}
|
||||
|
||||
func TestServiceCreateDigestPinning(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ func TestServiceRemoveError(t *testing.T) {
|
||||
}
|
||||
|
||||
err := client.ServiceRemove(context.Background(), "service_id")
|
||||
assert.EqualError(t, err, "Error response from daemon: Server error")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
}
|
||||
|
||||
func TestServiceRemoveNotFoundError(t *testing.T) {
|
||||
@@ -27,8 +28,8 @@ func TestServiceRemoveNotFoundError(t *testing.T) {
|
||||
}
|
||||
|
||||
err := client.ServiceRemove(context.Background(), "service_id")
|
||||
assert.EqualError(t, err, "Error: No such service: service_id")
|
||||
assert.True(t, IsErrNotFound(err))
|
||||
assert.Check(t, is.Error(err, "Error: No such service: service_id"))
|
||||
assert.Check(t, IsErrNotFound(err))
|
||||
}
|
||||
|
||||
func TestServiceRemove(t *testing.T) {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -55,6 +55,6 @@ func TestSwarmGetUnlockKey(t *testing.T) {
|
||||
}
|
||||
|
||||
resp, err := client.SwarmGetUnlockKey(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, unlockKey, resp.UnlockKey)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(unlockKey, resp.UnlockKey))
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestVolumeInspectNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.VolumeInspect(context.Background(), "unknown")
|
||||
assert.True(t, IsErrNotFound(err))
|
||||
assert.Check(t, IsErrNotFound(err))
|
||||
}
|
||||
|
||||
func TestVolumeInspectWithEmptyID(t *testing.T) {
|
||||
@@ -75,6 +75,6 @@ func TestVolumeInspect(t *testing.T) {
|
||||
}
|
||||
|
||||
volume, err := client.VolumeInspect(context.Background(), "volume_id")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expected, volume)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(expected, volume))
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDaemonParseShmSize(t *testing.T) {
|
||||
@@ -16,7 +17,7 @@ func TestDaemonParseShmSize(t *testing.T) {
|
||||
conf := &config.Config{}
|
||||
installConfigFlags(conf, flags)
|
||||
// By default `--default-shm-size=64M`
|
||||
assert.Equal(t, int64(64*1024*1024), conf.ShmSize.Value())
|
||||
assert.NoError(t, flags.Set("default-shm-size", "128M"))
|
||||
assert.Equal(t, int64(128*1024*1024), conf.ShmSize.Value())
|
||||
assert.Check(t, is.Equal(int64(64*1024*1024), conf.ShmSize.Value()))
|
||||
assert.Check(t, flags.Set("default-shm-size", "128M"))
|
||||
assert.Check(t, is.Equal(int64(128*1024*1024), conf.ShmSize.Value()))
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/internal/testutil"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func defaultOptions(configFile string) *daemonOptions {
|
||||
@@ -27,8 +27,8 @@ func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
|
||||
opts.Debug = true
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
if !loadedConfig.Debug {
|
||||
t.Fatalf("expected debug to be copied from the common flags, got false")
|
||||
}
|
||||
@@ -40,9 +40,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
|
||||
opts.TLS = true
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "/tmp/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("/tmp/ca.pem", loadedConfig.CommonTLSOptions.CAFile))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||
@@ -53,9 +53,9 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
|
||||
opts := defaultOptions(configFile)
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("config-file", configFile))
|
||||
assert.NoError(t, flags.Set("label", "l1=bar"))
|
||||
assert.NoError(t, flags.Set("label", "l2=baz"))
|
||||
assert.Check(t, flags.Set("config-file", configFile))
|
||||
assert.Check(t, flags.Set("label", "l1=bar"))
|
||||
assert.Check(t, flags.Set("label", "l2=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
testutil.ErrorContains(t, err, "as a flag and in the configuration file: labels")
|
||||
@@ -69,9 +69,9 @@ func TestLoadDaemonCliWithConflictingNodeGenericResources(t *testing.T) {
|
||||
opts := defaultOptions(configFile)
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("config-file", configFile))
|
||||
assert.NoError(t, flags.Set("node-generic-resource", "r1=bar"))
|
||||
assert.NoError(t, flags.Set("node-generic-resource", "r2=baz"))
|
||||
assert.Check(t, flags.Set("config-file", configFile))
|
||||
assert.Check(t, flags.Set("node-generic-resource", "r1=bar"))
|
||||
assert.Check(t, flags.Set("node-generic-resource", "r2=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
testutil.ErrorContains(t, err, "as a flag and in the configuration file: node-generic-resources")
|
||||
@@ -81,22 +81,22 @@ func TestLoadDaemonCliWithConflictingLabels(t *testing.T) {
|
||||
opts := defaultOptions("")
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("label", "foo=bar"))
|
||||
assert.NoError(t, flags.Set("label", "foo=baz"))
|
||||
assert.Check(t, flags.Set("label", "foo=bar"))
|
||||
assert.Check(t, flags.Set("label", "foo=baz"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
assert.EqualError(t, err, "conflict labels for foo=baz and foo=bar")
|
||||
assert.Check(t, is.Error(err, "conflict labels for foo=baz and foo=bar"))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliWithDuplicateLabels(t *testing.T) {
|
||||
opts := defaultOptions("")
|
||||
flags := opts.flags
|
||||
|
||||
assert.NoError(t, flags.Set("label", "foo=the-same"))
|
||||
assert.NoError(t, flags.Set("label", "foo=the-same"))
|
||||
assert.Check(t, flags.Set("label", "foo=the-same"))
|
||||
assert.Check(t, flags.Set("label", "foo=the-same"))
|
||||
|
||||
_, err := loadDaemonCliConfig(opts)
|
||||
assert.NoError(t, err)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||
@@ -107,9 +107,9 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, loadedConfig.TLS, true)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal(loadedConfig.TLS, true))
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||
@@ -120,9 +120,9 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.True(t, loadedConfig.TLS)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, loadedConfig.TLS)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||
@@ -133,9 +133,9 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
|
||||
opts.TLSOptions.CAFile = "/tmp/ca.pem"
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.False(t, loadedConfig.TLS)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, !loadedConfig.TLS)
|
||||
}
|
||||
|
||||
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||
@@ -144,10 +144,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "warn", loadedConfig.LogLevel)
|
||||
assert.Equal(t, logrus.WarnLevel, logrus.GetLevel())
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("warn", loadedConfig.LogLevel))
|
||||
assert.Check(t, is.Equal(logrus.WarnLevel, logrus.GetLevel()))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||
@@ -157,10 +157,10 @@ func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.Equal(t, "/etc/certs/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
|
||||
assert.Equal(t, "syslog", loadedConfig.LogConfig.Type)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, is.Equal("/etc/certs/ca.pem", loadedConfig.CommonTLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal("syslog", loadedConfig.LogConfig.Type))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
@@ -174,10 +174,10 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.Len(t, loadedConfig.AllowNondistributableArtifacts, 1)
|
||||
assert.Len(t, loadedConfig.Mirrors, 1)
|
||||
assert.Len(t, loadedConfig.InsecureRegistries, 1)
|
||||
assert.Check(t, is.Len(loadedConfig.AllowNondistributableArtifacts, 1))
|
||||
assert.Check(t, is.Len(loadedConfig.Mirrors, 1))
|
||||
assert.Check(t, is.Len(loadedConfig.InsecureRegistries, 1))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||
@@ -19,17 +19,17 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
opts.Debug = true
|
||||
opts.LogLevel = "info"
|
||||
assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
|
||||
assert.Check(t, opts.flags.Set("selinux-enabled", "true"))
|
||||
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.True(t, loadedConfig.Debug)
|
||||
assert.Equal(t, "info", loadedConfig.LogLevel)
|
||||
assert.True(t, loadedConfig.EnableSelinuxSupport)
|
||||
assert.Equal(t, "json-file", loadedConfig.LogConfig.Type)
|
||||
assert.Equal(t, "1k", loadedConfig.LogConfig.Config["max-size"])
|
||||
assert.Check(t, loadedConfig.Debug)
|
||||
assert.Check(t, is.Equal("info", loadedConfig.LogLevel))
|
||||
assert.Check(t, loadedConfig.EnableSelinuxSupport)
|
||||
assert.Check(t, is.Equal("json-file", loadedConfig.LogConfig.Type))
|
||||
assert.Check(t, is.Equal("1k", loadedConfig.LogConfig.Config["max-size"]))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
||||
@@ -39,11 +39,11 @@ func TestLoadDaemonConfigWithNetwork(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.Equal(t, "127.0.0.2", loadedConfig.IP)
|
||||
assert.Equal(t, "127.0.0.1", loadedConfig.DefaultIP.String())
|
||||
assert.Check(t, is.Equal("127.0.0.2", loadedConfig.IP))
|
||||
assert.Check(t, is.Equal("127.0.0.1", loadedConfig.DefaultIP.String()))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||
@@ -56,14 +56,14 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NotNil(t, loadedConfig.ClusterOpts)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
assert.Check(t, loadedConfig.ClusterOpts != nil)
|
||||
|
||||
expectedPath := "/var/lib/docker/discovery_certs/ca.pem"
|
||||
assert.Equal(t, expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"])
|
||||
assert.NotNil(t, loadedConfig.LogConfig.Config)
|
||||
assert.Equal(t, "test", loadedConfig.LogConfig.Config["tag"])
|
||||
assert.Check(t, is.Equal(expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"]))
|
||||
assert.Check(t, loadedConfig.LogConfig.Config != nil)
|
||||
assert.Check(t, is.Equal("test", loadedConfig.LogConfig.Config["tag"]))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||
@@ -73,17 +73,17 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.False(t, loadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, !loadedConfig.EnableUserlandProxy)
|
||||
|
||||
// make sure reloading doesn't generate configuration
|
||||
// conflicts after normalizing boolean values.
|
||||
reload := func(reloadedConfig *config.Config) {
|
||||
assert.False(t, reloadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, !reloadedConfig.EnableUserlandProxy)
|
||||
}
|
||||
assert.NoError(t, config.Reload(opts.configFile, opts.flags, reload))
|
||||
assert.Check(t, config.Reload(opts.configFile, opts.flags, reload))
|
||||
}
|
||||
|
||||
func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
@@ -92,8 +92,8 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
|
||||
|
||||
opts := defaultOptions(tempFile.Path())
|
||||
loadedConfig, err := loadDaemonCliConfig(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, loadedConfig)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, loadedConfig != nil)
|
||||
|
||||
assert.True(t, loadedConfig.EnableUserlandProxy)
|
||||
assert.Check(t, loadedConfig.EnableUserlandProxy)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ import (
|
||||
|
||||
cliconfig "github.com/docker/docker/cli/config"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCommonOptionsInstallFlags(t *testing.T) {
|
||||
@@ -20,10 +21,10 @@ func TestCommonOptionsInstallFlags(t *testing.T) {
|
||||
"--tlscert=\"/foo/cert\"",
|
||||
"--tlskey=\"/foo/key\"",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "/foo/cafile", opts.TLSOptions.CAFile)
|
||||
assert.Equal(t, "/foo/cert", opts.TLSOptions.CertFile)
|
||||
assert.Equal(t, opts.TLSOptions.KeyFile, "/foo/key")
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("/foo/cafile", opts.TLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal("/foo/cert", opts.TLSOptions.CertFile))
|
||||
assert.Check(t, is.Equal(opts.TLSOptions.KeyFile, "/foo/key"))
|
||||
}
|
||||
|
||||
func defaultPath(filename string) string {
|
||||
@@ -36,8 +37,8 @@ func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
|
||||
opts.InstallFlags(flags)
|
||||
|
||||
err := flags.Parse([]string{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, defaultPath("ca.pem"), opts.TLSOptions.CAFile)
|
||||
assert.Equal(t, defaultPath("cert.pem"), opts.TLSOptions.CertFile)
|
||||
assert.Equal(t, defaultPath("key.pem"), opts.TLSOptions.KeyFile)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal(defaultPath("ca.pem"), opts.TLSOptions.CAFile))
|
||||
assert.Check(t, is.Equal(defaultPath("cert.pem"), opts.TLSOptions.CertFile))
|
||||
assert.Check(t, is.Equal(defaultPath("key.pem"), opts.TLSOptions.KeyFile))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ResolvePath resolves the given path in the container to a resource on the
|
||||
@@ -13,6 +14,9 @@ import (
|
||||
// the absolute path to the resource relative to the container's rootfs, and
|
||||
// an error if the path points to outside the container's rootfs.
|
||||
func (container *Container) ResolvePath(path string) (resolvedPath, absPath string, err error) {
|
||||
if container.BaseFS == nil {
|
||||
return "", "", errors.New("ResolvePath: BaseFS of container " + container.ID + " is unexpectedly nil")
|
||||
}
|
||||
// Check if a drive letter supplied, it must be the system drive. No-op except on Windows
|
||||
path, err = system.CheckSystemDriveAndRemoveDriveLetter(path, container.BaseFS)
|
||||
if err != nil {
|
||||
@@ -45,6 +49,9 @@ func (container *Container) ResolvePath(path string) (resolvedPath, absPath stri
|
||||
// resolved to a path on the host corresponding to the given absolute path
|
||||
// inside the container.
|
||||
func (container *Container) StatPath(resolvedPath, absPath string) (stat *types.ContainerPathStat, err error) {
|
||||
if container.BaseFS == nil {
|
||||
return nil, errors.New("StatPath: BaseFS of container " + container.ID + " is unexpectedly nil")
|
||||
}
|
||||
driver := container.BaseFS
|
||||
|
||||
lstat, err := driver.Lstat(resolvedPath)
|
||||
|
||||
@@ -38,7 +38,7 @@ import (
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/volume"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/go-units"
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/docker/libnetwork"
|
||||
"github.com/docker/libnetwork/netlabel"
|
||||
"github.com/docker/libnetwork/options"
|
||||
@@ -311,6 +311,9 @@ func (container *Container) SetupWorkingDirectory(rootIDs idtools.IDPair) error
|
||||
// symlinking to a different path) between using this method and using the
|
||||
// path. See symlink.FollowSymlinkInScope for more details.
|
||||
func (container *Container) GetResourcePath(path string) (string, error) {
|
||||
if container.BaseFS == nil {
|
||||
return "", errors.New("GetResourcePath: BaseFS of container " + container.ID + " is unexpectedly nil")
|
||||
}
|
||||
// IMPORTANT - These are paths on the OS where the daemon is running, hence
|
||||
// any filepath operations must be done in an OS agnostic way.
|
||||
r, e := container.BaseFS.ResolveScopedPath(path, false)
|
||||
@@ -391,6 +394,8 @@ func (container *Container) StartLogger() (logger.Logger, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
container.LogPath = info.LogPath
|
||||
}
|
||||
|
||||
l, err := initDriver(info)
|
||||
@@ -974,11 +979,6 @@ func (container *Container) startLogging() error {
|
||||
copier.Run()
|
||||
container.LogDriver = l
|
||||
|
||||
// set LogPath field only for json-file logdriver
|
||||
if jl, ok := l.(*jsonfilelog.JSONFileLogger); ok {
|
||||
container.LogPath = jl.LogPath()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package container // import "github.com/docker/docker/container"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
swarmtypes "github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/daemon/logger/jsonfilelog"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
)
|
||||
|
||||
func TestContainerStopSignal(t *testing.T) {
|
||||
@@ -66,3 +71,56 @@ func TestContainerSecretReferenceDestTarget(t *testing.T) {
|
||||
t.Fatalf("expected secret dest %q; received %q", expected, d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerLogPathSetForJSONFileLogger(t *testing.T) {
|
||||
containerRoot, err := ioutil.TempDir("", "TestContainerLogPathSetForJSONFileLogger")
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(containerRoot)
|
||||
|
||||
c := &Container{
|
||||
Config: &container.Config{},
|
||||
HostConfig: &container.HostConfig{
|
||||
LogConfig: container.LogConfig{
|
||||
Type: jsonfilelog.Name,
|
||||
},
|
||||
},
|
||||
ID: "TestContainerLogPathSetForJSONFileLogger",
|
||||
Root: containerRoot,
|
||||
}
|
||||
|
||||
logger, err := c.StartLogger()
|
||||
assert.NilError(t, err)
|
||||
defer logger.Close()
|
||||
|
||||
expectedLogPath, err := filepath.Abs(filepath.Join(containerRoot, fmt.Sprintf("%s-json.log", c.ID)))
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, c.LogPath, expectedLogPath)
|
||||
}
|
||||
|
||||
func TestContainerLogPathSetForRingLogger(t *testing.T) {
|
||||
containerRoot, err := ioutil.TempDir("", "TestContainerLogPathSetForRingLogger")
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(containerRoot)
|
||||
|
||||
c := &Container{
|
||||
Config: &container.Config{},
|
||||
HostConfig: &container.HostConfig{
|
||||
LogConfig: container.LogConfig{
|
||||
Type: jsonfilelog.Name,
|
||||
Config: map[string]string{
|
||||
"mode": string(container.LogModeNonBlock),
|
||||
},
|
||||
},
|
||||
},
|
||||
ID: "TestContainerLogPathSetForRingLogger",
|
||||
Root: containerRoot,
|
||||
}
|
||||
|
||||
logger, err := c.StartLogger()
|
||||
assert.NilError(t, err)
|
||||
defer logger.Close()
|
||||
|
||||
expectedLogPath, err := filepath.Abs(filepath.Join(containerRoot, fmt.Sprintf("%s-json.log", c.ID)))
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, c.LogPath, expectedLogPath)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pborman/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var root string
|
||||
@@ -109,56 +110,56 @@ func TestNames(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.NoError(t, db.ReserveName("name1", "containerid1"))
|
||||
assert.NoError(t, db.ReserveName("name1", "containerid1")) // idempotent
|
||||
assert.NoError(t, db.ReserveName("name2", "containerid2"))
|
||||
assert.EqualError(t, db.ReserveName("name2", "containerid3"), ErrNameReserved.Error())
|
||||
assert.Check(t, db.ReserveName("name1", "containerid1"))
|
||||
assert.Check(t, db.ReserveName("name1", "containerid1")) // idempotent
|
||||
assert.Check(t, db.ReserveName("name2", "containerid2"))
|
||||
assert.Check(t, is.Error(db.ReserveName("name2", "containerid3"), ErrNameReserved.Error()))
|
||||
|
||||
// Releasing a name allows the name to point to something else later.
|
||||
assert.NoError(t, db.ReleaseName("name2"))
|
||||
assert.NoError(t, db.ReserveName("name2", "containerid3"))
|
||||
assert.Check(t, db.ReleaseName("name2"))
|
||||
assert.Check(t, db.ReserveName("name2", "containerid3"))
|
||||
|
||||
view := db.Snapshot()
|
||||
|
||||
id, err := view.GetID("name1")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "containerid1", id)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("containerid1", id))
|
||||
|
||||
id, err = view.GetID("name2")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "containerid3", id)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("containerid3", id))
|
||||
|
||||
_, err = view.GetID("notreserved")
|
||||
assert.EqualError(t, err, ErrNameNotReserved.Error())
|
||||
assert.Check(t, is.Error(err, ErrNameNotReserved.Error()))
|
||||
|
||||
// Releasing and re-reserving a name doesn't affect the snapshot.
|
||||
assert.NoError(t, db.ReleaseName("name2"))
|
||||
assert.NoError(t, db.ReserveName("name2", "containerid4"))
|
||||
assert.Check(t, db.ReleaseName("name2"))
|
||||
assert.Check(t, db.ReserveName("name2", "containerid4"))
|
||||
|
||||
id, err = view.GetID("name1")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "containerid1", id)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("containerid1", id))
|
||||
|
||||
id, err = view.GetID("name2")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "containerid3", id)
|
||||
assert.Check(t, err)
|
||||
assert.Check(t, is.Equal("containerid3", id))
|
||||
|
||||
// GetAllNames
|
||||
assert.Equal(t, map[string][]string{"containerid1": {"name1"}, "containerid3": {"name2"}}, view.GetAllNames())
|
||||
assert.Check(t, is.DeepEqual(map[string][]string{"containerid1": {"name1"}, "containerid3": {"name2"}}, view.GetAllNames()))
|
||||
|
||||
assert.NoError(t, db.ReserveName("name3", "containerid1"))
|
||||
assert.NoError(t, db.ReserveName("name4", "containerid1"))
|
||||
assert.Check(t, db.ReserveName("name3", "containerid1"))
|
||||
assert.Check(t, db.ReserveName("name4", "containerid1"))
|
||||
|
||||
view = db.Snapshot()
|
||||
assert.Equal(t, map[string][]string{"containerid1": {"name1", "name3", "name4"}, "containerid4": {"name2"}}, view.GetAllNames())
|
||||
assert.Check(t, is.DeepEqual(map[string][]string{"containerid1": {"name1", "name3", "name4"}, "containerid4": {"name2"}}, view.GetAllNames()))
|
||||
|
||||
// Release containerid1's names with Delete even though no container exists
|
||||
assert.NoError(t, db.Delete(&Container{ID: "containerid1"}))
|
||||
assert.Check(t, db.Delete(&Container{ID: "containerid1"}))
|
||||
|
||||
// Reusing one of those names should work
|
||||
assert.NoError(t, db.ReserveName("name1", "containerid4"))
|
||||
assert.Check(t, db.ReserveName("name1", "containerid4"))
|
||||
view = db.Snapshot()
|
||||
assert.Equal(t, map[string][]string{"containerid4": {"name1", "name2"}}, view.GetAllNames())
|
||||
assert.Check(t, is.DeepEqual(map[string][]string{"containerid4": {"name1", "name2"}}, view.GetAllNames()))
|
||||
}
|
||||
|
||||
// Test case for GitHub issue 35920
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM aarch64/debian:jessie
|
||||
RUN echo deb http://ftp.debian.org/debian jessie-backports main > /etc/apt/sources.list.d/backports.list
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev libseccomp-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-arm64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM aarch64/debian:stretch
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-dev libseccomp-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-arm64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM aarch64/ubuntu:trusty
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-arm64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM aarch64/ubuntu:xenial
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-dev libseccomp-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-arm64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list.d
|
||||
RUN apt-get update && apt-get install -y -t wheezy-backports btrfs-tools --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ubuntu:trusty
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ubuntu:yakkety
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ubuntu:zesty
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
# GOARM is the ARM architecture version which is unrelated to the above Golang version
|
||||
ENV GOARM 6
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM armhf/ubuntu:trusty
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM armhf/ubuntu:xenial
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM armhf/ubuntu:yakkety
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config vim-common libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ppc64le/ubuntu:trusty
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libsystemd-journal-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ppc64le/ubuntu:xenial
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libseccomp-dev libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM ppc64le/ubuntu:yakkety
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev pkg-config vim-common libseccomp-dev libsystemd-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM s390x/ubuntu:xenial
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config libsystemd-dev vim-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ FROM s390x/ubuntu:yakkety
|
||||
|
||||
RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libseccomp-dev pkg-config libsystemd-dev vim-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM amazonlinux:latest
|
||||
RUN yum groupinstall -y "Development Tools"
|
||||
RUN yum install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN yum groupinstall -y "Development Tools"
|
||||
RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs
|
||||
RUN yum install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN dnf -y upgrade
|
||||
RUN dnf install -y @development-tools fedora-packager
|
||||
RUN dnf install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN dnf -y upgrade
|
||||
RUN dnf install -y @development-tools fedora-packager
|
||||
RUN dnf install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM opensuse:13.2
|
||||
RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build
|
||||
RUN zypper --non-interactive install libbtrfs-devel device-mapper-devel glibc-static libselinux-devel pkg-config selinux-policy selinux-policy-devel systemd-devel tar git cmake vim systemd-rpm-macros
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ RUN yum install -y kernel-uek-devel-4.1.12-32.el6uek
|
||||
RUN yum groupinstall -y "Development Tools"
|
||||
RUN yum install -y btrfs-progs-devel device-mapper-devel glibc-static libselinux-devel pkgconfig selinux-policy selinux-policy-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM oraclelinux:7
|
||||
RUN yum groupinstall -y "Development Tools"
|
||||
RUN yum install -y --enablerepo=ol7_optional_latest btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM photon:1.0
|
||||
RUN tdnf install -y wget curl ca-certificates gzip make rpm-build sed gcc linux-api-headers glibc-devel binutils libseccomp elfutils
|
||||
RUN tdnf install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkg-config selinux-policy selinux-policy-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ RUN yum groupinstall --skip-broken -y "Development Tools"
|
||||
RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs
|
||||
RUN yum install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fSL "https://golang.org/dl/go${GO_VERSION}.linux-armv6l.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN yum groupinstall -y "Development Tools"
|
||||
RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs
|
||||
RUN yum install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN dnf -y upgrade
|
||||
RUN dnf install -y @development-tools fedora-packager
|
||||
RUN dnf install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ RUN zypper addrepo -n ppc64le-updates -f https://download.opensuse.org/ports/upd
|
||||
RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build
|
||||
RUN zypper --non-interactive install libbtrfs-devel device-mapper-devel glibc-static libselinux-devel pkg-config selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-ppc64le.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ FROM sinenomine/clefos-base-s390x
|
||||
RUN touch /var/lib/rpm/* && yum groupinstall -y "Development Tools"
|
||||
RUN touch /var/lib/rpm/* && yum install -y btrfs-progs-devel device-mapper-devel glibc-static libseccomp-devel libselinux-devel pkgconfig selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim-common
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ RUN zypper ar https://download.opensuse.org/ports/zsystems/tumbleweed/repo/oss/
|
||||
RUN zypper --non-interactive install ca-certificates* curl gzip rpm-build
|
||||
RUN zypper --non-interactive install libbtrfs-devel device-mapper-devel glibc-static libselinux-devel pkg-config selinux-policy selinux-policy-devel sqlite-devel systemd-devel tar git cmake vim systemd-rpm-macros
|
||||
|
||||
ENV GO_VERSION 1.9.4
|
||||
ENV GO_VERSION 1.9.5
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-s390x.tar.gz" | tar xzC /usr/local
|
||||
ENV PATH $PATH:/usr/local/go/bin
|
||||
|
||||
|
||||
156
daemon/build.go
156
daemon/build.go
@@ -15,130 +15,126 @@ import (
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type releaseableLayer struct {
|
||||
type roLayer struct {
|
||||
released bool
|
||||
layerStore layer.Store
|
||||
roLayer layer.Layer
|
||||
rwLayer layer.RWLayer
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) Mount() (containerfs.ContainerFS, error) {
|
||||
var err error
|
||||
var mountPath containerfs.ContainerFS
|
||||
func (l *roLayer) DiffID() layer.DiffID {
|
||||
if l.roLayer == nil {
|
||||
return layer.DigestSHA256EmptyTar
|
||||
}
|
||||
return l.roLayer.DiffID()
|
||||
}
|
||||
|
||||
func (l *roLayer) Release() error {
|
||||
if l.released {
|
||||
return nil
|
||||
}
|
||||
if l.roLayer != nil {
|
||||
metadata, err := l.layerStore.Release(l.roLayer)
|
||||
layer.LogReleaseMetadata(metadata)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to release ROLayer")
|
||||
}
|
||||
}
|
||||
l.roLayer = nil
|
||||
l.released = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *roLayer) NewRWLayer() (builder.RWLayer, error) {
|
||||
var chainID layer.ChainID
|
||||
if rl.roLayer != nil {
|
||||
chainID = rl.roLayer.ChainID()
|
||||
if l.roLayer != nil {
|
||||
chainID = l.roLayer.ChainID()
|
||||
}
|
||||
|
||||
mountID := stringid.GenerateRandomID()
|
||||
rl.rwLayer, err = rl.layerStore.CreateRWLayer(mountID, chainID, nil)
|
||||
newLayer, err := l.layerStore.CreateRWLayer(mountID, chainID, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to create rwlayer")
|
||||
}
|
||||
|
||||
mountPath, err = rl.rwLayer.Mount("")
|
||||
rwLayer := &rwLayer{layerStore: l.layerStore, rwLayer: newLayer}
|
||||
|
||||
fs, err := newLayer.Mount("")
|
||||
if err != nil {
|
||||
// Clean up the layer if we fail to mount it here.
|
||||
metadata, err := rl.layerStore.ReleaseRWLayer(rl.rwLayer)
|
||||
layer.LogReleaseMetadata(metadata)
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to release RWLayer: %s", err)
|
||||
}
|
||||
rl.rwLayer = nil
|
||||
rwLayer.Release()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mountPath, nil
|
||||
rwLayer.fs = fs
|
||||
|
||||
return rwLayer, nil
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) Commit() (builder.ReleaseableLayer, error) {
|
||||
var chainID layer.ChainID
|
||||
if rl.roLayer != nil {
|
||||
chainID = rl.roLayer.ChainID()
|
||||
}
|
||||
type rwLayer struct {
|
||||
released bool
|
||||
layerStore layer.Store
|
||||
rwLayer layer.RWLayer
|
||||
fs containerfs.ContainerFS
|
||||
}
|
||||
|
||||
stream, err := rl.rwLayer.TarStream()
|
||||
func (l *rwLayer) Root() containerfs.ContainerFS {
|
||||
return l.fs
|
||||
}
|
||||
|
||||
func (l *rwLayer) Commit() (builder.ROLayer, error) {
|
||||
stream, err := l.rwLayer.TarStream()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
newLayer, err := rl.layerStore.Register(stream, chainID)
|
||||
var chainID layer.ChainID
|
||||
if parent := l.rwLayer.Parent(); parent != nil {
|
||||
chainID = parent.ChainID()
|
||||
}
|
||||
|
||||
newLayer, err := l.layerStore.Register(stream, chainID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO: An optimization would be to handle empty layers before returning
|
||||
return &releaseableLayer{layerStore: rl.layerStore, roLayer: newLayer}, nil
|
||||
return &roLayer{layerStore: l.layerStore, roLayer: newLayer}, nil
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) DiffID() layer.DiffID {
|
||||
if rl.roLayer == nil {
|
||||
return layer.DigestSHA256EmptyTar
|
||||
}
|
||||
return rl.roLayer.DiffID()
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) Release() error {
|
||||
if rl.released {
|
||||
func (l *rwLayer) Release() error {
|
||||
if l.released {
|
||||
return nil
|
||||
}
|
||||
if err := rl.releaseRWLayer(); err != nil {
|
||||
// Best effort attempt at releasing read-only layer before returning original error.
|
||||
rl.releaseROLayer()
|
||||
return err
|
||||
|
||||
if l.fs != nil {
|
||||
if err := l.rwLayer.Unmount(); err != nil {
|
||||
return errors.Wrap(err, "failed to unmount RWLayer")
|
||||
}
|
||||
l.fs = nil
|
||||
}
|
||||
if err := rl.releaseROLayer(); err != nil {
|
||||
return err
|
||||
|
||||
metadata, err := l.layerStore.ReleaseRWLayer(l.rwLayer)
|
||||
layer.LogReleaseMetadata(metadata)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to release RWLayer")
|
||||
}
|
||||
rl.released = true
|
||||
l.released = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) releaseRWLayer() error {
|
||||
if rl.rwLayer == nil {
|
||||
return nil
|
||||
}
|
||||
if err := rl.rwLayer.Unmount(); err != nil {
|
||||
logrus.Errorf("Failed to unmount RWLayer: %s", err)
|
||||
return err
|
||||
}
|
||||
metadata, err := rl.layerStore.ReleaseRWLayer(rl.rwLayer)
|
||||
layer.LogReleaseMetadata(metadata)
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to release RWLayer: %s", err)
|
||||
}
|
||||
rl.rwLayer = nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (rl *releaseableLayer) releaseROLayer() error {
|
||||
if rl.roLayer == nil {
|
||||
return nil
|
||||
}
|
||||
metadata, err := rl.layerStore.Release(rl.roLayer)
|
||||
layer.LogReleaseMetadata(metadata)
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to release ROLayer: %s", err)
|
||||
}
|
||||
rl.roLayer = nil
|
||||
return err
|
||||
}
|
||||
|
||||
func newReleasableLayerForImage(img *image.Image, layerStore layer.Store) (builder.ReleaseableLayer, error) {
|
||||
func newROLayerForImage(img *image.Image, layerStore layer.Store) (builder.ROLayer, error) {
|
||||
if img == nil || img.RootFS.ChainID() == "" {
|
||||
return &releaseableLayer{layerStore: layerStore}, nil
|
||||
return &roLayer{layerStore: layerStore}, nil
|
||||
}
|
||||
// Hold a reference to the image layer so that it can't be removed before
|
||||
// it is released
|
||||
roLayer, err := layerStore.Get(img.RootFS.ChainID())
|
||||
layer, err := layerStore.Get(img.RootFS.ChainID())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get layer for image %s", img.ImageID())
|
||||
}
|
||||
return &releaseableLayer{layerStore: layerStore, roLayer: roLayer}, nil
|
||||
return &roLayer{layerStore: layerStore, roLayer: layer}, nil
|
||||
}
|
||||
|
||||
// TODO: could this use the regular daemon PullImage ?
|
||||
@@ -170,12 +166,12 @@ func (daemon *Daemon) pullForBuilder(ctx context.Context, name string, authConfi
|
||||
// GetImageAndReleasableLayer returns an image and releaseable layer for a reference or ID.
|
||||
// Every call to GetImageAndReleasableLayer MUST call releasableLayer.Release() to prevent
|
||||
// leaking of layers.
|
||||
func (daemon *Daemon) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ReleaseableLayer, error) {
|
||||
func (daemon *Daemon) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
|
||||
if refOrID == "" {
|
||||
if !system.IsOSSupported(opts.OS) {
|
||||
return nil, nil, system.ErrNotSupportedOperatingSystem
|
||||
}
|
||||
layer, err := newReleasableLayerForImage(nil, daemon.layerStores[opts.OS])
|
||||
layer, err := newROLayerForImage(nil, daemon.layerStores[opts.OS])
|
||||
return nil, layer, err
|
||||
}
|
||||
|
||||
@@ -189,7 +185,7 @@ func (daemon *Daemon) GetImageAndReleasableLayer(ctx context.Context, refOrID st
|
||||
if !system.IsOSSupported(image.OperatingSystem()) {
|
||||
return nil, nil, system.ErrNotSupportedOperatingSystem
|
||||
}
|
||||
layer, err := newReleasableLayerForImage(image, daemon.layerStores[image.OperatingSystem()])
|
||||
layer, err := newROLayerForImage(image, daemon.layerStores[image.OperatingSystem()])
|
||||
return image, layer, err
|
||||
}
|
||||
}
|
||||
@@ -201,7 +197,7 @@ func (daemon *Daemon) GetImageAndReleasableLayer(ctx context.Context, refOrID st
|
||||
if !system.IsOSSupported(image.OperatingSystem()) {
|
||||
return nil, nil, system.ErrNotSupportedOperatingSystem
|
||||
}
|
||||
layer, err := newReleasableLayerForImage(image, daemon.layerStores[image.OperatingSystem()])
|
||||
layer, err := newROLayerForImage(image, daemon.layerStores[image.OperatingSystem()])
|
||||
return image, layer, err
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user