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,17 @@
ARG GO_VERSION
FROM golang:${GO_VERSION}-alpine
RUN apk add --no-cache \
bash \
git \
openssh-client \
tar
# Build the gdm binary and then clean out /go.
RUN go get github.com/sparrc/gdm && \
mv /go/bin/gdm /usr/local/bin/gdm && \
rm -rf /go/*
COPY fs/ /
ENTRYPOINT ["influxdb_tarball.bash"]

View File

@@ -0,0 +1,62 @@
#!/bin/bash
function printHelp() {
>&2 echo \
"USAGE: $0 [-p INFLUXDB_GIT_DIR]
-s INFLUXDB_SHA -b INFLUXDB_BRANCH -v INFLUXDB_VERSION -o OUTDIR
Emits a tarball of influxdb source code and dependencies to OUTDIR.
If using -p flag, directory containing influxdb source code will be used as source of truth.
This is helpful if you have local commits that have not been pushed.
If not using -p, you must provide -S to clone over SSH.
"
}
if [ $# -eq 0 ]; then
printHelp
exit 1
fi
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SRCDIR/../_go_versions.sh"
SHA=""
BRANCH=""
VERSION=""
OUTDIR=""
# These variables may expand to command arguments. Don't double quote them when used later.
INFLUXDB_GIT_MOUNT=""
while getopts hs:b:v:o:p:S: arg; do
case "$arg" in
h) printHelp; exit 1;;
s) SHA="$OPTARG";;
b) BRANCH="$OPTARG";;
v) VERSION="$OPTARG";;
o) OUTDIR="$OPTARG";;
p) INFLUXDB_GIT_MOUNT="--mount type=bind,src=$OPTARG,dst=/influxdb-git,ro=1";;
esac
done
if [ -z "$OUTDIR" ]; then
# Not bothering to check the other variables since they're checked in the inner docker script.
printHelp
exit 1
fi
# Only build with GO_CURRENT_VERSION. No need to build source tarball with next version of Go.
docker build --build-arg "GO_VERSION=$GO_CURRENT_VERSION" -t influxdata/influxdb/releng/source-tarball:latest "$SRCDIR"
mkdir -p "$OUTDIR"
docker run --rm \
$INFLUXDB_GIT_MOUNT \
--mount "type=bind,src=${OUTDIR},dst=/out" \
influxdata/influxdb/releng/source-tarball:latest \
-s "$SHA" \
-b "$BRANCH" \
-v "$VERSION"

View File

@@ -0,0 +1,85 @@
#!/bin/bash
function printHelp() {
>&2 echo "USAGE: $0 -s INFLUXDB_SHA -b INFLUXDB_BRANCH -v INFLUXDB_VERSION
Emits a tarball of influxdb source code and dependencies to /out,
which must be a mounted volume if you want to access the file.
If the directory /influxdb-git exists and is mounted,
that will be used as the git repository used when cloning influxdb.
"
}
if [ $# -eq 0 ]; then
printHelp
exit 1
fi
SHA=""
BRANCH=""
VERSION=""
while getopts hs:b:v: arg; do
case "$arg" in
h) printHelp; exit 1;;
s) SHA="$OPTARG";;
b) BRANCH="$OPTARG";;
v) VERSION="$OPTARG";;
esac
done
if [ -z "$SHA" ] || [ -z "$BRANCH" ] || [ -z "$VERSION" ]; then
printHelp
exit 1
fi
IPATH=/go/src/github.com/influxdata
mkdir -p "$IPATH" && cd "$IPATH"
if [ -d /influxdb-git ]; then
git clone /influxdb-git "$IPATH/influxdb"
else
git clone https://github.com/influxdata/influxdb.git
fi
cd influxdb
git checkout "$SHA"
gdm restore
cd ..
# Emit version metadata to appropriate files.
# Include machine-parseable metadata JSON file.
printf '{
"version": "%s",
"branch": "%s",
"sha": "%s"
}' "$VERSION" "$BRANCH" "$SHA" > "./influxdb/.metadata.json"
# Set version info for influxdb binaries.
printf 'package main
// Code generated by influxdata/releng tooling. DO NOT EDIT.
func init() {
version = "%s"
branch = "%s"
commit = "%s"
}' "$VERSION" "$BRANCH" "$SHA" > "./influxdb/cmd/influxd/version.generated.go"
# influx uses just version.
printf 'package main
// Code generated by influxdata/releng tooling. DO NOT EDIT.
func init() {
version = "%s"
}' "$VERSION" > "./influxdb/cmd/influx/version.generated.go"
TARBALL_NAME="influxdb-src-$SHA.tar.gz"
(cd /go && tar czf "/out/$TARBALL_NAME" --exclude-vcs ./*) # --exclude-vcs is a GNU tar option.
(cd /out && md5sum "$TARBALL_NAME" > "$TARBALL_NAME.md5")
(cd /out && sha256sum "$TARBALL_NAME" > "$TARBALL_NAME.sha256")