Skip to content

Commit

Permalink
Merge pull request #371 from crazy-max/mod-vendor
Browse files Browse the repository at this point in the history
chore: go mod vendor
  • Loading branch information
crazy-max authored Dec 21, 2024
2 parents cc208f2 + c9be030 commit 1259f16
Show file tree
Hide file tree
Showing 1,602 changed files with 444,378 additions and 18 deletions.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
COPY --from=xx / /
ENV CGO_ENABLED=0
ENV GOFLAGS="-mod=vendor"
RUN apk add --no-cache file git
WORKDIR /src

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

FROM base AS vendored
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download

FROM vendored AS build
FROM base AS build
ARG TARGETPLATFORM
RUN --mount=type=bind,target=. \
--mount=type=bind,from=version,source=/tmp/.version,target=/tmp/.version \
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: all
all:

.PHONY: vendor
vendor:
$(eval $@_TMP_OUT := $(shell mktemp -d -t swarm-cronjob-output.XXXXXXXXXX))
docker buildx bake --set "*.output=type=local,dest=$($@_TMP_OUT)" vendor
rm -rf ./vendor
cp -R "$($@_TMP_OUT)"/* ./
rm -rf "$($@_TMP_OUT)"/*
29 changes: 17 additions & 12 deletions hack/vendor.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,43 @@ ARG ALPINE_VERSION="3.18"
ARG GOMOD_OUTDATED_VERSION="v0.8.0"

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

FROM base AS vendored
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/go/pkg/mod <<EOT
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 download
go mod vendor
mkdir /out
cp go.mod go.sum /out
cp -r go.mod go.sum vendor /out
EOT

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

FROM vendored AS validate
RUN --mount=type=bind,target=.,rw <<EOT
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)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
echo "$diff"
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
git status --porcelain -- go.mod go.sum vendor
exit 1
fi
EOT

FROM psampaz/go-mod-outdated:${GOMOD_OUTDATED_VERSION} AS go-mod-outdated
FROM base AS outdated
RUN --mount=type=bind,target=. \
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/go/pkg/mod \
--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
go list -mod=mod -u -m -json all | go-mod-outdated -update -direct
21 changes: 21 additions & 0 deletions vendor/github.com/Azure/go-ansiterm/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/Azure/go-ansiterm/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

188 changes: 188 additions & 0 deletions vendor/github.com/Azure/go-ansiterm/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/github.com/Azure/go-ansiterm/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions vendor/github.com/Azure/go-ansiterm/csi_entry_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1259f16

Please sign in to comment.