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
|
|
|
|
gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' vendor.conf)
|
|
|
|
case $buildmode in
|
|
|
|
"buildkit")
|
2018-10-02 17:03:32 +00:00
|
|
|
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --frontend-opt build-arg:GOGO_VERSION=$gogo_version --frontend-opt filename=./hack/dockerfiles/generated-files.buildkit.Dockerfile
|
2018-09-14 18:36:19 +00:00
|
|
|
;;
|
|
|
|
"docker-buildkit")
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
|
|
|
docker build --iidfile $iidfile --build-arg GOGO_VERSION=$gogo_version -f ./hack/dockerfiles/generated-files.buildkit.Dockerfile --target validate --force-rm . || exit 1
|
|
|
|
iid=$(cat $iidfile)
|
|
|
|
docker rmi $iid
|
|
|
|
rm -f $iidfile
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
docker build --build-arg GOGO_VERSION=$gogo_version -f ./hack/dockerfiles/generated-files.Dockerfile --target validate --force-rm .
|
|
|
|
;;
|
|
|
|
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
|