add vendoring with go dep

This commit is contained in:
Adrian Todorov
2017-10-25 20:52:40 +00:00
parent 704f4d20d1
commit a59409f16b
1627 changed files with 489673 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
ARG GO_VERSION
FROM golang:${GO_VERSION}
RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
&& rm -rf /var/lib/apt/lists/*
COPY fs/ /
ENTRYPOINT ["influxdb_raw_binaries.bash"]

View File

@@ -0,0 +1,58 @@
#!/bin/bash
function printHelp() {
>&2 echo "USAGE: $0 -i PATH_TO_SOURCE_TARBALL -o OUTDIR
Emits an archive of influxdb binaries based on the current environment's GOOS and GOARCH.
If the environment variable GO_NEXT is not empty, builds the binaries with the 'next' version of Go.
"
}
if [ $# -eq 0 ]; then
printHelp
exit 1
fi
if [ -z "$GOOS" ] || [ -z "$GOARCH" ]; then
>&2 echo 'The environment variables $GOOS and $GOARCH must both be set.'
exit 1
fi
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SRCDIR/../_go_versions.sh"
OUTDIR=""
TARBALL=""
RACE_FLAG=""
while getopts hi:o:r arg; do
case "$arg" in
h) printHelp; exit 1;;
i) TARBALL="$OPTARG";;
o) OUTDIR="$OPTARG";;
r) RACE_FLAG="-r";;
esac
done
if [ -z "$OUTDIR" ] || [ -z "$TARBALL" ]; then
printHelp
exit 1
fi
if [ -z "$GO_NEXT" ]; then
DOCKER_TAG=latest
GO_VERSION="$GO_CURRENT_VERSION"
else
DOCKER_TAG=next
GO_VERSION="$GO_NEXT_VERSION"
fi
docker build --build-arg "GO_VERSION=$GO_VERSION" -t influxdata/influxdb/releng/raw-binaries:"$DOCKER_TAG" "$SRCDIR"
mkdir -p "$OUTDIR"
docker run --rm \
--mount type=bind,source="${OUTDIR}",destination=/out \
--mount type=bind,source="${TARBALL}",destination=/influxdb-src.tar.gz,ro=1 \
-e GOOS -e GOARCH -e CGO_ENABLED \
influxdata/influxdb/releng/raw-binaries:"$DOCKER_TAG" $RACE_FLAG

View File

@@ -0,0 +1,80 @@
#!/bin/bash
function printHelp() {
>&2 echo "USAGE: $0 [-r]
Untars the plutonium source tarball mounted at /plutonium-src.tar.gz,
then emits a tarball of plutonium binaries to /out,
which must be a mounted volume if you want to access the file.
Relies upon environment variables GOOS and GOARCH to determine what to build.
Respects CGO_ENABLED.
To build with race detection enabled, pass the -r flag.
"
}
RACE_FLAG=""
while getopts hr arg; do
case "$arg" in
h) printHelp; exit 1;;
r) RACE_FLAG="-race";;
esac
done
if [ -z "$GOOS" ] || [ -z "$GOARCH" ]; then
>&2 echo 'The environment variables $GOOS and $GOARCH must both be set.'
exit 1
fi
# Extract tarball into GOPATH.
tar xz -C "$GOPATH" -f /influxdb-src.tar.gz
SHA=$(jq -r .sha < "$GOPATH/src/github.com/influxdata/influxdb/.metadata.json")
SUFFIX=
if [ "$CGO_ENABLED" == "0" ]; then
# Only add the static suffix to the filename when explicitly requested.
SUFFIX=_static
elif [ -n "$RACE_FLAG" ]; then
# -race depends on cgo, so this option is exclusive from CGO_ENABLED.
SUFFIX=_race
fi
TARBALL_NAME="influxdb_bin_${GOOS}_${GOARCH}${SUFFIX}-${SHA}.tar.gz"
# note: according to https://github.com/golang/go/wiki/GoArm
# we want to support armel using GOARM=5
# and we want to support armhf using GOARM=6
# no GOARM setting is necessary for arm64
if [ $GOARCH == "armel" ]; then
GOARCH=arm
GOARM=5
fi
if [ $GOARCH == "armhf" ]; then
GOARCH=arm
GOARM=6
fi
OUTDIR=$(mktemp -d)
for cmd in \
influxdb/cmd/influxd \
influxdb/cmd/influx_stress \
influxdb/cmd/influx \
influxdb/cmd/influx_inspect \
influxdb/cmd/influx_tsm \
; do
go build $RACE_FLAG -i -o "$OUTDIR/$(basename $cmd)" "github.com/influxdata/$cmd"
done
(cd "$OUTDIR" && tar czf "/out/$TARBALL_NAME" ./*)
(cd /out && md5sum "$TARBALL_NAME" > "$TARBALL_NAME.md5")
(cd /out && sha256sum "$TARBALL_NAME" > "$TARBALL_NAME.sha256")