1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 11:36:51 +00:00

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

39
vendor/github.com/influxdata/influxdb/releng/README.md generated vendored Normal file
View File

@@ -0,0 +1,39 @@
# influxdb/releng
This directory and its subdirectories contain release engineering scripts to build source tarballs and packages, run unit tests in an isolated environment, and so on.
The directory layout typically looks like:
```
├── Dockerfile
├── build.bash
└── fs
└── usr
└── local
└── bin
└── influxdb_tarball.bash
```
Where you only need to run `build.bash` (or other shell scripts in the root directory) with valid arguments to complete the step.
All scripts in the root folders accept the `-h` flag to explain usage.
The `fs` folder is overlaid on the Docker image so that is clear where each script for the Docker containers reside.
Those scripts make assumptions about the environment which are controlled in the outer scripts (i.e. `build.bash`), so the scripts not intended to be run outside of Docker.
By default, these scripts will use the "current" Go version as determined by `_go_versions.sh`.
To use the "next" version of Go, set the environment variable GO_NEXT to a non-empty value.
## source-tarball
Generates a source tarball of influxdb that can be extracted to a new `GOPATH` such that you can `go build github.com/influxdata/influxdb/cmd/influxd`, etc., without manually setting linker flags or anything.
## raw-binaries
Builds the raw binaries for the various influxdb commands, and stores them in OS/architecture-specific tarballs in the provided destination path.
## packages
Given a source tarball and an archive of raw binaries, generates OS/architecture-specific packages (i.e. .deb and .rpm files).
## unit-tests
Given a source tarball, runs the influxdb unit tests in a clean Docker environment.

View File

@@ -0,0 +1,5 @@
# These are the current and "next" Go versions used to build influxdb.
# This file is meant to be sourced from other scripts.
export GO_CURRENT_VERSION=1.8.3
export GO_NEXT_VERSION=1.9

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")

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")

View File

@@ -0,0 +1,15 @@
ARG GO_VERSION
FROM golang:${GO_VERSION}-alpine
RUN apk add --no-cache \
bash \
jq \
git
RUN go get -u github.com/jstemmer/go-junit-report && \
mv /go/bin/go-junit-report /usr/bin/go-junit-report && \
rm -rf /go/*
COPY fs/ /
ENTRYPOINT ["influxdb_prebuild_tests.bash"]

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Extract tarball into GOPATH.
tar xz -C "$GOPATH" -f /influxdb-src.tar.gz
cd "$GOPATH/src/github.com/influxdata/influxdb"
go test -v ./... 2>&1 | tee /out/tests.log | go-junit-report > /out/influxdb.junit.xml

View File

@@ -0,0 +1,48 @@
#!/bin/bash
function printHelp() {
>&2 echo "USAGE: $0 -i PATH_TO_SOURCE_TARBALL -o OUTDIR
Runs unit tests for influxdb.
If the environment variable GO_NEXT is not empty, tests run with the 'next' version of Go.
"
}
if [ $# -eq 0 ]; then
printHelp
exit 1
fi
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SRCDIR/../_go_versions.sh"
OUTDIR=""
TARBALL=""
while getopts hi:o: arg; do
case "$arg" in
h) printHelp; exit 1;;
i) TARBALL="$OPTARG";;
o) OUTDIR="$OPTARG";;
esac
done
if [ -z "$TARBALL" ] || [ -z "$OUTDIR" ]; 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/unit-tests:"$DOCKER_TAG" "$SRCDIR"
docker run --rm \
--mount type=bind,source="$OUTDIR",destination=/out \
--mount type=bind,source="$TARBALL",destination=/influxdb-src.tar.gz,ro=1 \
influxdata/influxdb/releng/unit-tests:"$DOCKER_TAG"