Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
name: "Upload to Codecov"
command: |
docker cp \
test-$CIRCLE_BUILD_NUM:/go/src/github.com/docker/cli/coverage.txt \
test-$CIRCLE_BUILD_NUM:/src/coverage.txt \
coverage.txt
apk add -U bash curl
curl -s https://codecov.io/bash | bash || \
Expand Down
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
.gitignore
appveyor.yml
build
/vndr.log
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
target:
- lint
- shellcheck
- validate-vendor
steps:
-
name: Checkout
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ cli/winresources/rsrc_*.syso
/docs/yaml/gen/
coverage.txt
profile.out
/vndr.log
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM go-${TARGETOS} AS build-base-alpine
COPY --from=xx / /
RUN apk add --no-cache clang lld llvm file git
WORKDIR /go/src/github.com/docker/cli
WORKDIR /src

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

FROM build-base-buster AS build-buster
ARG TARGETPLATFORM
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ plugins-osx: ## build example CLI plugins for macOS
dynbinary: ## build dynamically linked binary
USE_GLIBC=1 docker buildx bake dynbinary

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

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

.PHONY: ci-validate
ci-validate:
time make -B vendor
time make manpages
time make yamldocs
26 changes: 26 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,29 @@ target "shellcheck" {
target = "shellcheck"
output = ["type=cacheonly"]
}

target "validate-vendor" {
dockerfile = "./dockerfiles/Dockerfile.vendor"
target = "validate"
output = ["type=cacheonly"]
}

target "update-vendor" {
dockerfile = "./dockerfiles/Dockerfile.vendor"
target = "update"
output = ["."]
}

// Used to invalidate cache for mod-outdated run stage
// See also https://github.com/moby/buildkit/issues/1213
variable "TIMESTAMP" {
default = ""
}
target "mod-outdated" {
dockerfile = "./dockerfiles/Dockerfile.vendor"
target = "outdated"
args = {
TIMESTAMP = TIMESTAMP
}
output = ["type=cacheonly"]
}
19 changes: 16 additions & 3 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

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

Expand All @@ -19,6 +19,7 @@ ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
DOCKER_CLI_MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
endif
VERSION = $(shell cat VERSION)
TIMESTAMP = $(shell date '+%s')
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)

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

.PHONY: vendor
vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make vendor
vendor: ## update vendor based on go mod/sum
$(eval $@_TMP_OUT := $(shell mktemp -d -t dockercli-output.XXXXXXXXXX))
docker buildx bake --set "*.output=$($@_TMP_OUT)" update-vendor
rm -rf ./vendor
cp -R "$($@_TMP_OUT)"/out/* .
rm -rf $($@_TMP_OUT)/*

.PHONY: validate-vendor
validate-vendor: ## validate vendor
docker buildx bake validate-vendor

.PHONY: mod-outdated
mod-outdated: ## check outdated dependencies
TIMESTAMP=$(TIMESTAMP) docker buildx bake mod-outdated

.PHONY: authors
authors: ## generate AUTHORS file from git history
Expand Down
12 changes: 2 additions & 10 deletions dockerfiles/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=tmpfs,target=/go/src/ \
GO111MODULE=on go install gotest.tools/gotestsum@${GOTESTSUM_VERSION}

FROM golang AS vndr
ARG VNDR_VERSION=v0.1.2
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=tmpfs,target=/go/src/ \
GO111MODULE=on go install github.com/LK4D4/vndr@${VNDR_VERSION}

FROM golang AS dev
RUN apk add --no-cache \
bash \
Expand All @@ -30,11 +23,10 @@ RUN apk add --no-cache \

CMD bash
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
ENV PATH=$PATH:/src/build

COPY --from=vndr /go/bin/* /go/bin/
COPY --from=gotestsum /go/bin/* /go/bin/

WORKDIR /go/src/github.com/docker/cli
WORKDIR /src
ENV GO111MODULE=auto
COPY . .
8 changes: 4 additions & 4 deletions dockerfiles/Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ RUN curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${
&& mv gotestsum /usr/local/bin/gotestsum \
&& rm gotestsum.tar.gz

ENV CGO_ENABLED=0 \
DISABLE_WARN_OUTSIDE_CONTAINER=1 \
PATH=/go/src/github.com/docker/cli/build:$PATH
WORKDIR /go/src/github.com/docker/cli
ENV CGO_ENABLED=0
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
WORKDIR /src

# Trust notary CA cert.
COPY e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
Expand All @@ -39,6 +38,7 @@ ARG GITCOMMIT
ENV VERSION=${VERSION}
ENV GITCOMMIT=${GITCOMMIT}
ENV DOCKER_BUILDKIT=1
ENV TARGET=/usr/local/bin
RUN ./scripts/build/binary
RUN ./scripts/build/plugins e2e/cli-plugins/plugins/*

Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/Dockerfile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ ARG GOLANGCI_LINT_VERSION=v1.23.8
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint

FROM golang:${GO_VERSION}-alpine AS lint
ENV GO111MODULE=off
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
ENV GOGC=75
WORKDIR /go/src/github.com/docker/cli
WORKDIR /src
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
golangci-lint run
golangci-lint run
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.shellcheck
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.3

FROM koalaman/shellcheck-alpine:v0.7.1 AS shellcheck
WORKDIR /go/src/github.com/docker/cli
WORKDIR /src
RUN --mount=type=bind,target=. \
set -eo pipefail; \
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
46 changes: 46 additions & 0 deletions dockerfiles/Dockerfile.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1.3-labs

ARG GO_VERSION=1.16.8

FROM golang:${GO_VERSION}-alpine AS base
RUN apk add --no-cache git rsync
WORKDIR /src

FROM base AS vendored
RUN --mount=target=/context \
--mount=target=.,type=tmpfs \
--mount=target=/go/pkg/mod,type=cache <<EOT
set -e
rsync -a /context/. .
go mod tidy
go mod vendor
mkdir /out
cp -r go.mod go.sum vendor /out
EOT

FROM scratch AS update
COPY --from=vendored /out /out

FROM vendored AS validate
RUN --mount=target=/context \
--mount=target=.,type=tmpfs <<EOT
set -e
rsync -a /context/. .
git add -A
rm -rf vendor
cp -rf /out/* .
diff=$(git status --porcelain -- go.mod go.sum vendor)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"'
echo $diff
exit 1
fi
EOT

FROM psampaz/go-mod-outdated:v0.8.0 AS go-mod-outdated
FROM base AS outdated
ARG TIMESTAMP
RUN --mount=target=.,ro \
--mount=target=/go/pkg/mod,type=cache \
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
go list -mod=readonly -u -m -json all | go-mod-outdated -update -direct
91 changes: 91 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
module github.com/docker/cli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the tricky bit.

Using go modules for this repository itself is generally not problematic, but but for anyone using the cli as a dependency, things are more complicated.

The module is named github.com/docker/cli, but Go will refuse to use it under that name if there's a go.mod, because the current version is v20.10.x, so it will require the packages to be renamed to github.com/docker/cli/v20.

That "works" if we release once a year, but if we would do multiple releases, it will be complicated. Tags on this repository are for the binary releases, which use CalVer, not SemVer, but "sometimes" the format is "compatible" (any release done in October, November or December, because then the second digit will start with a 1. However, that would put v21.10.0 and v21.11.0 both to be github.com/docker/cli/v21, and with a go.mod, you add the promise that it's SemVer, so no breaking changes allowed in between.

Releases before October each year would also not be picked up by go modules (the v22.01.0 version string is not in the correct format for SemVer, so will be ignored).

Copy link
Member Author

@crazy-max crazy-max Sep 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed, if we follow our versioning practice (CalVer), it's unfortunately not affordable.


go 1.16

require (
github.com/Microsoft/go-winio v0.4.19 // indirect
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
github.com/containerd/console v1.0.2
github.com/containerd/containerd v1.5.5
github.com/coreos/etcd v3.3.25+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1
github.com/creack/pty v1.1.11
github.com/docker/compose-on-kubernetes v0.5.0-test1
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.7+incompatible
github.com/docker/docker-credential-helpers v0.6.4
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0
github.com/docker/swarmkit v1.12.1-0.20210726173615-3629f50980f6
github.com/fvbommel/sortorder v1.0.2
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/imdario/mergo v0.3.11
github.com/mitchellh/mapstructure v1.3.2
github.com/moby/buildkit v0.8.2-0.20210615162540-9f254e18360a
github.com/moby/sys/signal v0.5.0
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/theupdateframework/notary v0.6.1
github.com/tonistiigi/fsutil v0.0.0-20210609172227-d72af97c0eaf
github.com/tonistiigi/go-rosetta v0.0.0-20200727161949-f79598599c5d
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
golang.org/x/text v0.3.4
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/grpc v1.38.0 // indirect
gopkg.in/yaml.v2 v2.4.0
gotest.tools/v3 v3.0.3
k8s.io/api v0.20.6
k8s.io/apimachinery v0.20.6
k8s.io/client-go v0.20.6
k8s.io/klog v1.0.1-0.20200310124935-4ad0115ba9e4 // indirect
)

replace (
cloud.google.com/go => cloud.google.com/go v0.44.3
github.com/docker/distribution => github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20210811141259-343665850e3a+incompatible // master ; v21.xx-dev
github.com/docker/go => github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // contains a customized version of canonical/json and is used by Notary. The package is periodically rebased on current Go versions.
github.com/evanphx/json-patch => gopkg.in/evanphx/json-patch.v4 v4.1.0
github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2
github.com/google/go-cmp => github.com/google/go-cmp v0.2.0
github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.2.0
github.com/imdario/mergo => github.com/imdario/mergo v0.3.8
github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
github.com/json-iterator/go => github.com/json-iterator/go v1.1.10
github.com/moby/buildkit => github.com/moby/buildkit v0.8.2-0.20210615162540-9f254e18360a // master ; v0.9.0-dev
github.com/moby/sys/mount => github.com/moby/sys/mount v0.2.0
github.com/moby/sys/mountinfo => github.com/moby/sys/mountinfo v0.4.1
github.com/moby/sys/signal => github.com/moby/sys/signal v0.5.0
github.com/moby/sys/symlink => github.com/moby/sys/symlink v0.1.0
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.6.0
github.com/prometheus/client_model => github.com/prometheus/client_model v0.2.0
github.com/prometheus/common => github.com/prometheus/common v0.9.1
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.11
github.com/theupdateframework/notary => github.com/theupdateframework/notary v0.7.1-0.20210315103452-bf96a202a09a
golang.org/x/term => golang.org/x/term v0.0.0-20201117132131-f5c789dd3221
golang.org/x/text => golang.org/x/text v0.3.3
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.8
gotest.tools/v3 => gotest.tools/v3 v3.0.2
k8s.io/api => k8s.io/api v0.16.9
k8s.io/apimachinery => k8s.io/apimachinery v0.16.9
k8s.io/client-go => k8s.io/client-go v0.16.9
k8s.io/klog => k8s.io/klog v1.0.1-0.20200310124935-4ad0115ba9e4 // v1.0.0-2-g4ad0115 pending v1.0.1 release to fix https://github.com/docker/cli/issues/2420
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d
k8s.io/utils => k8s.io/utils v0.0.0-20190923111123-69764acb6e8e
sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.1.0
)
Loading