Skip to content

Commit c1c56e6

Browse files
committed
Switch to go modules
Signed-off-by: CrazyMax <[email protected]>
1 parent 154ce5e commit c1c56e6

500 files changed

Lines changed: 59649 additions & 16635 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
name: "Upload to Codecov"
7070
command: |
7171
docker cp \
72-
test-$CIRCLE_BUILD_NUM:/go/src/github.com/docker/cli/coverage.txt \
72+
test-$CIRCLE_BUILD_NUM:/src/coverage.txt \
7373
coverage.txt
7474
apk add -U bash curl
7575
curl -s https://codecov.io/bash | bash || \

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
.gitignore
55
appveyor.yml
66
build
7-
/vndr.log

.github/workflows/validate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
target:
2020
- lint
2121
- shellcheck
22+
- validate-vendor
2223
steps:
2324
-
2425
name: Checkout

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ cli/winresources/rsrc_*.syso
1515
/docs/yaml/gen/
1616
coverage.txt
1717
profile.out
18-
/vndr.log

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
2020
FROM go-${TARGETOS} AS build-base-alpine
2121
COPY --from=xx / /
2222
RUN apk add --no-cache clang lld llvm file git
23-
WORKDIR /go/src/github.com/docker/cli
23+
WORKDIR /src
2424

2525
FROM build-base-alpine AS build-alpine
2626
ARG TARGETPLATFORM
@@ -30,7 +30,7 @@ RUN xx-apk add --no-cache musl-dev gcc
3030
FROM go-${TARGETOS} AS build-base-buster
3131
COPY --from=xx / /
3232
RUN apt-get update && apt-get install --no-install-recommends -y clang lld file
33-
WORKDIR /go/src/github.com/docker/cli
33+
WORKDIR /src
3434

3535
FROM build-base-buster AS build-buster
3636
ARG TARGETPLATFORM

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ plugins-osx: ## build example CLI plugins for macOS
4949
dynbinary: ## build dynamically linked binary
5050
USE_GLIBC=1 docker buildx bake dynbinary
5151

52-
vendor: vendor.conf ## check that vendor matches vendor.conf
52+
.PHONY: vendor
53+
vendor: ## update vendor based on go mod/sum
5354
rm -rf vendor
54-
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log'
55-
scripts/validate/check-git-diff vendor
56-
scripts/validate/check-all-packages-vendored
55+
go mod tidy
56+
go mod vendor
5757

5858
.PHONY: authors
5959
authors: ## generate AUTHORS file from git history
@@ -73,6 +73,5 @@ help: ## print this help
7373

7474
.PHONY: ci-validate
7575
ci-validate:
76-
time make -B vendor
7776
time make manpages
7877
time make yamldocs

docker-bake.hcl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ target "shellcheck" {
7373
target = "shellcheck"
7474
output = ["type=cacheonly"]
7575
}
76+
77+
target "validate-vendor" {
78+
dockerfile = "./dockerfiles/Dockerfile.vendor"
79+
target = "validate"
80+
output = ["type=cacheonly"]
81+
}
82+
83+
target "update-vendor" {
84+
dockerfile = "./dockerfiles/Dockerfile.vendor"
85+
target = "update"
86+
output = ["."]
87+
}
88+
89+
// Used to invalidate cache for mod-outdated run stage
90+
// See also https://github.com/moby/buildkit/issues/1213
91+
variable "TIMESTAMP" {
92+
default = ""
93+
}
94+
target "mod-outdated" {
95+
dockerfile = "./dockerfiles/Dockerfile.vendor"
96+
target = "outdated"
97+
args = {
98+
TIMESTAMP = TIMESTAMP
99+
}
100+
output = ["type=cacheonly"]
101+
}

docker.Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
# Overridable env vars
8-
DOCKER_CLI_MOUNTS ?= -v "$(CURDIR)":/go/src/github.com/docker/cli
8+
DOCKER_CLI_MOUNTS ?= -v "$(CURDIR)":/src
99
DOCKER_CLI_CONTAINER_NAME ?=
1010
DOCKER_CLI_GO_BUILD_CACHE ?= y
1111

@@ -19,6 +19,7 @@ ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
1919
DOCKER_CLI_MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
2020
endif
2121
VERSION = $(shell cat VERSION)
22+
TIMESTAMP = $(shell date '+%s')
2223
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIRS -e GOOS -e GOARCH -e GOARM -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION)
2324

2425
# Some Dockerfiles use features that are only supported with BuildKit enabled
@@ -87,8 +88,20 @@ fmt: ## run gofmt
8788
$(DOCKER_RUN) $(DEV_DOCKER_IMAGE_NAME) make fmt
8889

8990
.PHONY: vendor
90-
vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf
91-
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make vendor
91+
vendor: ## update vendor based on go mod/sum
92+
$(eval $@_TMP_OUT := $(shell mktemp -d -t dockercli-output.XXXXXXXXXX))
93+
docker buildx bake --set "*.output=$($@_TMP_OUT)" update-vendor
94+
rm -rf ./vendor
95+
cp -R "$($@_TMP_OUT)"/out/* .
96+
rm -rf $($@_TMP_OUT)/*
97+
98+
.PHONY: validate-vendor
99+
validate-vendor: ## validate vendor
100+
docker buildx bake validate-vendor
101+
102+
.PHONY: mod-outdated
103+
mod-outdated: ## check outdated dependencies
104+
TIMESTAMP=$(TIMESTAMP) docker buildx bake mod-outdated
92105

93106
.PHONY: authors
94107
authors: ## generate AUTHORS file from git history

dockerfiles/Dockerfile.dev

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
1212
--mount=type=tmpfs,target=/go/src/ \
1313
GO111MODULE=on go install gotest.tools/gotestsum@${GOTESTSUM_VERSION}
1414

15-
FROM golang AS vndr
16-
ARG VNDR_VERSION=v0.1.2
17-
RUN --mount=type=cache,target=/root/.cache/go-build \
18-
--mount=type=cache,target=/go/pkg/mod \
19-
--mount=type=tmpfs,target=/go/src/ \
20-
GO111MODULE=on go install github.com/LK4D4/vndr@${VNDR_VERSION}
21-
2215
FROM golang AS dev
2316
RUN apk add --no-cache \
2417
bash \
@@ -30,11 +23,10 @@ RUN apk add --no-cache \
3023

3124
CMD bash
3225
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
33-
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
26+
ENV PATH=$PATH:/src/build
3427

35-
COPY --from=vndr /go/bin/* /go/bin/
3628
COPY --from=gotestsum /go/bin/* /go/bin/
3729

38-
WORKDIR /go/src/github.com/docker/cli
30+
WORKDIR /src
3931
ENV GO111MODULE=auto
4032
COPY . .

dockerfiles/Dockerfile.e2e

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ RUN curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${
2424
&& mv gotestsum /usr/local/bin/gotestsum \
2525
&& rm gotestsum.tar.gz
2626

27-
ENV CGO_ENABLED=0 \
28-
DISABLE_WARN_OUTSIDE_CONTAINER=1 \
29-
PATH=/go/src/github.com/docker/cli/build:$PATH
30-
WORKDIR /go/src/github.com/docker/cli
27+
ENV CGO_ENABLED=0
28+
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
29+
WORKDIR /src
3130

3231
# Trust notary CA cert.
3332
COPY e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
@@ -39,6 +38,7 @@ ARG GITCOMMIT
3938
ENV VERSION=${VERSION}
4039
ENV GITCOMMIT=${GITCOMMIT}
4140
ENV DOCKER_BUILDKIT=1
41+
ENV TARGET=/usr/local/bin
4242
RUN ./scripts/build/binary
4343
RUN ./scripts/build/plugins e2e/cli-plugins/plugins/*
4444

0 commit comments

Comments
 (0)