Skip to content

Commit caef84b

Browse files
committed
vendor with go mod
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 6fbf816 commit caef84b

File tree

537 files changed

+64718
-13904
lines changed

Some content is hidden

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

537 files changed

+64718
-13904
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
/man/man*/
55
/docs/yaml/gen/
66
profile.out
7-
/vndr.log
7+
8+
# top-level go.mod is not meant to be checked in
9+
/go.mod

.github/workflows/validate.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ on:
1111
pull_request:
1212

1313
jobs:
14-
lint:
14+
validate:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
fail-fast: false
1818
matrix:
1919
target:
2020
- lint
2121
- shellcheck
22+
- validate-vendor
2223
steps:
2324
-
2425
name: Checkout

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ Thumbs.db
1515
/man/man8/
1616
/docs/yaml/gen/
1717
profile.out
18-
/vndr.log
18+
19+
# top-level go.mod is not meant to be checked in
20+
/go.mod

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,18 @@ dynbinary: ## build dynamically linked binary
4949
plugins: ## build example CLI plugins
5050
./scripts/build/plugins
5151

52-
vendor: vendor.conf ## check that vendor matches vendor.conf
52+
.PHONY: vendor
53+
vendor: ## update vendor with go modules
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+
./scripts/vendor update
56+
57+
.PHONY: validate-vendor
58+
validate-vendor: ## validate vendor
59+
./scripts/vendor validate
60+
61+
.PHONY: mod-outdated
62+
mod-outdated: ## check outdated dependencies
63+
./scripts/vendor outdated
5764

5865
.PHONY: authors
5966
authors: ## generate AUTHORS file from git history
@@ -73,6 +80,5 @@ help: ## print this help
7380

7481
.PHONY: ci-validate
7582
ci-validate:
76-
time make -B vendor
7783
time make manpages
7884
time make yamldocs

docker-bake.hcl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,32 @@ target "shellcheck" {
7878
output = ["type=cacheonly"]
7979
}
8080

81+
target "validate-vendor" {
82+
dockerfile = "./dockerfiles/Dockerfile.vendor"
83+
target = "validate"
84+
output = ["type=cacheonly"]
85+
}
86+
87+
target "update-vendor" {
88+
dockerfile = "./dockerfiles/Dockerfile.vendor"
89+
target = "update"
90+
output = ["."]
91+
}
92+
93+
// Used to invalidate cache for mod-outdated run stage
94+
// See also https://github.com/moby/buildkit/issues/1213
95+
variable "TIMESTAMP" {
96+
default = ""
97+
}
98+
target "mod-outdated" {
99+
dockerfile = "./dockerfiles/Dockerfile.vendor"
100+
target = "outdated"
101+
args = {
102+
TIMESTAMP = TIMESTAMP
103+
}
104+
output = ["type=cacheonly"]
105+
}
106+
81107
target "test" {
82108
target = "test"
83109
output = ["type=cacheonly"]

docker.Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
2020
DOCKER_CLI_MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
2121
endif
2222
VERSION = $(shell cat VERSION)
23+
TIMESTAMP = $(shell date '+%s')
2324
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)
2425

2526
# Some Dockerfiles use features that are only supported with BuildKit enabled
@@ -80,8 +81,20 @@ fmt: ## run gofmt
8081
$(DOCKER_RUN) $(DEV_DOCKER_IMAGE_NAME) make fmt
8182

8283
.PHONY: vendor
83-
vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf
84-
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make vendor
84+
vendor: ## update vendor with go modules
85+
$(eval $@_TMP_OUT := $(shell mktemp -d -t dockercli-output.XXXXXXXXXX))
86+
docker buildx bake --set "*.output=$($@_TMP_OUT)" update-vendor
87+
rm -rf ./vendor
88+
cp -R "$($@_TMP_OUT)"/out/* .
89+
rm -rf $($@_TMP_OUT)/*
90+
91+
.PHONY: validate-vendor
92+
validate-vendor: ## validate vendor
93+
docker buildx bake validate-vendor
94+
95+
.PHONY: mod-outdated
96+
mod-outdated: ## check outdated dependencies
97+
TIMESTAMP=$(TIMESTAMP) docker buildx bake mod-outdated
8598

8699
.PHONY: authors
87100
authors: ## generate AUTHORS file from git history

dockerfiles/Dockerfile.dev

Lines changed: 0 additions & 8 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 goversioninfo
2316
ARG GOVERSIONINFO_VERSION=v1.3.0
2417
RUN --mount=type=cache,target=/root/.cache/go-build \
@@ -39,7 +32,6 @@ CMD bash
3932
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
4033
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
4134

42-
COPY --from=vndr /go/bin/* /go/bin/
4335
COPY --from=gotestsum /go/bin/* /go/bin/
4436
COPY --from=goversioninfo /go/bin/* /go/bin/
4537

dockerfiles/Dockerfile.vendor

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# syntax=docker/dockerfile:1.3-labs
2+
3+
ARG GO_VERSION=1.16.11
4+
ARG MODVENDOR_VERSION=v0.5.0
5+
ARG MODOUTDATED_VERSION=v0.8.0
6+
7+
FROM golang:${GO_VERSION}-alpine AS base
8+
RUN apk add --no-cache bash git rsync
9+
WORKDIR /src
10+
ARG MODVENDOR_VERSION
11+
RUN --mount=type=cache,target=/root/.cache/go-build \
12+
--mount=type=cache,target=/go/pkg/mod \
13+
GO111MODULE=on go install "github.com/goware/modvendor@${MODVENDOR_VERSION}"
14+
15+
FROM base AS vendored
16+
RUN --mount=target=/context \
17+
--mount=target=.,type=tmpfs \
18+
--mount=target=/go/pkg/mod,type=cache <<EOT
19+
set -e
20+
rsync -a /context/. .
21+
./scripts/vendor update
22+
mkdir /out
23+
cp -r vendor.mod vendor.sum vendor /out
24+
EOT
25+
26+
FROM scratch AS update
27+
COPY --from=vendored /out /out
28+
29+
FROM vendored AS validate
30+
RUN --mount=target=/context \
31+
--mount=target=.,type=tmpfs <<EOT
32+
set -e
33+
rsync -a /context/. .
34+
git add -A
35+
rm -rf vendor
36+
cp -rf /out/* .
37+
./scripts/vendor validate
38+
EOT
39+
40+
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
41+
FROM base AS outdated
42+
ARG TIMESTAMP
43+
RUN --mount=target=.,rw \
44+
--mount=target=/go/pkg/mod,type=cache \
45+
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
46+
./scripts/vendor outdated

man/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
package main
44

55
// Not used, but required for generating other man pages.
6-
// Import it here so that the package is included by vndr.
6+
// Import it here so that the package is included by go modules.
77
import _ "github.com/cpuguy83/go-md2man/v2"

scripts/validate/check-all-packages-vendored

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)