2018-03-26 10:52:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-10-02 17:03:32 +00:00
|
|
|
: ${CONTINUOUS_INTEGRATION=}
|
|
|
|
|
|
|
|
progressFlag=""
|
|
|
|
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
|
|
|
|
|
2018-03-26 10:52:36 +00:00
|
|
|
case ${1:-} in
|
2018-09-14 18:36:19 +00:00
|
|
|
'')
|
|
|
|
. $(dirname $0)/util
|
2019-01-26 06:29:13 +00:00
|
|
|
gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' go.mod)
|
2018-09-14 18:36:19 +00:00
|
|
|
case $buildmode in
|
|
|
|
"buildkit")
|
2019-10-18 07:36:14 +00:00
|
|
|
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt build-arg:GOGO_VERSION=$gogo_version --opt target=validate --opt filename=./hack/dockerfiles/generated-files.Dockerfile
|
2018-09-14 18:36:19 +00:00
|
|
|
;;
|
|
|
|
"docker-buildkit")
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
2019-10-18 07:36:14 +00:00
|
|
|
docker build --iidfile $iidfile --build-arg GOGO_VERSION=$gogo_version -f ./hack/dockerfiles/generated-files.Dockerfile --target validate --force-rm . || exit 1
|
2018-09-14 18:36:19 +00:00
|
|
|
iid=$(cat $iidfile)
|
|
|
|
docker rmi $iid
|
|
|
|
rm -f $iidfile
|
|
|
|
;;
|
|
|
|
*)
|
2019-10-12 15:03:30 +00:00
|
|
|
echo "Unsupported build mode: $buildmode" >&2
|
|
|
|
exit 1
|
2018-09-14 18:36:19 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
check)
|
|
|
|
diffs="$(git status --porcelain -- **/*.pb.go 2>/dev/null)"
|
|
|
|
set +x
|
|
|
|
if [ "$diffs" ] ; then
|
|
|
|
{
|
|
|
|
echo 'The result of "go generate" differs'
|
|
|
|
echo
|
|
|
|
echo "$diffs"
|
|
|
|
echo
|
|
|
|
echo 'Please update with "make generated-files"'
|
|
|
|
echo
|
|
|
|
} >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo 'Congratulations! All auto generated files are correct.'
|
|
|
|
;;
|
2018-03-26 10:52:36 +00:00
|
|
|
esac
|