Skip to content

Commit 912a898

Browse files
committed
handle vendor validation
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 5849cda commit 912a898

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

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 policy-helpers-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/dockerfiles/vendor.Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARG ALPINE_VERSION=3.23
55
ARG MODOUTDATED_VERSION=v0.9.0
66

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

@@ -15,8 +16,9 @@ RUN --mount=target=/context \
1516
set -e
1617
rsync -a /context/. .
1718
go mod tidy
19+
go mod vendor
1820
mkdir /out
19-
cp -r go.mod go.sum /out
21+
cp -r go.mod go.sum vendor /out
2022
EOT
2123

2224
FROM scratch AS update
@@ -28,10 +30,11 @@ RUN --mount=target=/context \
2830
set -e
2931
rsync -a /context/. .
3032
git add -A
33+
rm -rf vendor
3134
cp -rf /out/* .
32-
if [ -n "$(git status --porcelain -- go.mod go.sum)" ]; then
33-
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
34-
git status --porcelain -- go.mod go.sum
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
3538
exit 1
3639
fi
3740
EOT

0 commit comments

Comments
 (0)