Skip to content

Commit b781131

Browse files
authored
Merge pull request #389 from crazy-max/go-mod-vendor
chore: go mod vendor
2 parents 2c51f12 + 5f41ce9 commit b781131

File tree

1,229 files changed

+384273
-19
lines changed

Some content is hidden

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

1,229 files changed

+384273
-19
lines changed

Dockerfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
99
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
1010
COPY --from=xx / /
1111
ENV CGO_ENABLED=0
12+
ENV GOFLAGS="-mod=vendor"
1213
RUN apk add --no-cache file git
1314
WORKDIR /src
1415

@@ -23,12 +24,7 @@ RUN --mount=target=. <<EOT
2324
echo "$version" | tee /tmp/.version
2425
EOT
2526

26-
FROM base AS vendored
27-
COPY go.mod go.sum ./
28-
RUN --mount=type=cache,target=/go/pkg/mod \
29-
go mod download
30-
31-
FROM vendored AS test
27+
FROM base AS test
3228
ENV CGO_ENABLED=1
3329
RUN apk add --no-cache gcc linux-headers musl-dev
3430
RUN --mount=type=bind,target=. \
@@ -42,7 +38,7 @@ EOT
4238
FROM scratch AS test-coverage
4339
COPY --from=test /tmp/coverage.txt /coverage.txt
4440

45-
FROM vendored AS build
41+
FROM base AS build
4642
ARG TARGETPLATFORM
4743
RUN --mount=type=bind,target=. \
4844
--mount=type=bind,from=version,source=/tmp/.version,target=/tmp/.version \

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: all
2+
all:
3+
4+
.PHONY: vendor
5+
vendor:
6+
$(eval $@_TMP_OUT := $(shell mktemp -d -t ftpgrab-output.XXXXXXXXXX))
7+
docker buildx bake --set "*.output=type=local,dest=$($@_TMP_OUT)" vendor
8+
rm -rf ./vendor
9+
cp -R "$($@_TMP_OUT)"/* ./
10+
rm -rf "$($@_TMP_OUT)"/*

hack/vendor.Dockerfile

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,43 @@ ARG ALPINE_VERSION="3.18"
55
ARG GOMOD_OUTDATED_VERSION="v0.8.0"
66

77
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
8-
RUN apk add --no-cache git linux-headers musl-dev
8+
ENV GOFLAGS="-mod=vendor"
9+
RUN apk add --no-cache git linux-headers musl-dev rsync
910
WORKDIR /src
1011

1112
FROM base AS vendored
12-
RUN --mount=type=bind,target=.,rw \
13-
--mount=type=cache,target=/go/pkg/mod <<EOT
13+
RUN --mount=target=/context \
14+
--mount=target=.,type=tmpfs \
15+
--mount=target=/go/pkg/mod,type=cache <<EOT
1416
set -e
17+
rsync -a /context/. .
1518
go mod tidy
16-
go mod download
19+
go mod vendor
1720
mkdir /out
18-
cp go.mod go.sum /out
21+
cp -r go.mod go.sum vendor /out
1922
EOT
2023

2124
FROM scratch AS update
2225
COPY --from=vendored /out /
2326

2427
FROM vendored AS validate
25-
RUN --mount=type=bind,target=.,rw <<EOT
28+
RUN --mount=target=/context \
29+
--mount=target=.,type=tmpfs <<EOT
2630
set -e
31+
rsync -a /context/. .
2732
git add -A
33+
rm -rf vendor
2834
cp -rf /out/* .
29-
diff=$(git status --porcelain -- go.mod go.sum)
30-
if [ -n "$diff" ]; then
31-
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
32-
echo "$diff"
35+
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
36+
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
37+
git status --porcelain -- go.mod go.sum vendor
3338
exit 1
3439
fi
3540
EOT
3641

3742
FROM psampaz/go-mod-outdated:${GOMOD_OUTDATED_VERSION} AS go-mod-outdated
3843
FROM base AS outdated
39-
RUN --mount=type=bind,target=. \
44+
RUN --mount=type=bind,target=.,rw \
4045
--mount=type=cache,target=/go/pkg/mod \
4146
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
42-
go list -mod=readonly -u -m -json all | go-mod-outdated -update -direct
47+
go list -mod=mod -u -m -json all | go-mod-outdated -update -direct

vendor/github.com/BurntSushi/toml/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/BurntSushi/toml/COPYING

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/BurntSushi/toml/README.md

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)