Skip to content

Commit

Permalink
get-go-dependencies.sh: Pin swift version, and use a bash function fo…
Browse files Browse the repository at this point in the history
…r git operations
  • Loading branch information
stuarteberg committed Feb 20, 2021
1 parent 1193493 commit 731b242
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions scripts/get-go-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ export GO111MODULE=auto
echo $(type go)
echo $(go version)

ensure_checkout() {
REMOTE=$1
LOCAL=$2
TAG=$3
SHA=$4

if [[ -d ${LOCAL} ]]; then
cd ${LOCAL} && git fetch --tags && git checkout ${TAG} && cd -
else
git clone --depth 1 --branch ${TAG} ${REMOTE} ${LOCAL}
fi

if [[ ! -z "${SHA}" ]]; then
cd ${LOCAL} && git pull --unshallow && git fetch --tags && git checkout ${SHA} && cd -
fi
}

# gopackages
go get github.com/janelia-flyem/go
cd ${GOPATH}/src/github.com/janelia-flyem/go
Expand Down Expand Up @@ -123,35 +140,27 @@ go get github.com/gogo/protobuf/protoc-gen-gogoslick
#
# We can't use 'go get github.com/dgraph-io/ristretto/...' because we don't want the latest tag.
# (See badger notes below. Same reason.)
RISTRETTO_DIR=${GOPATH}/src/github.com/dgraph-io/ristretto
RISTRETTO_VERSION=v0.0.1 # Don't change this without also changing it in meta.yaml!!
if [[ -d ${RISTRETTO_DIR} ]]; then
cd ${RISTRETTO_DIR} && git fetch && cd -
else
git clone https://github.com/dgraph-io/ristretto ${RISTRETTO_DIR}
fi
cd ${RISTRETTO_DIR} && git fetch --tags origin && git checkout ${RISTRETTO_VERSION} && cd -
#go install -i github.com/dgraph-io/ristretto
#go get github.com/dgraph-io/ristretto
RISTRETTO_REPO=https://github.com/dgraph-io/ristretto
RISTRETTO_DIR=${GOPATH}/src/github.com/dgraph-io/ristretto
RISTRETTO_TAG=v0.0.1 # Don't change this without also changing it in meta.yaml!!
ensure_checkout ${RISTRETTO_REPO} ${RISTRETTO_DIR} ${RISTRETTO_TAG}

# badger
#
# We can't use 'go get github.com/dgraph-io/badger/...' because we don't want the latest tag.
# Eventually we should switch to using 'go get' in 'module-aware' mode:
# https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more
# ...in which case we'll be able to refer to a specific tag of the main badger repo.
BADGER_DIR=${GOPATH}/src/github.com/dgraph-io/badger
BADGER_VERSION=v2.0.0 # Don't change this without also changing it in meta.yaml!!
if [[ -d ${BADGER_DIR} ]]; then
cd ${BADGER_DIR} && git fetch && cd -
else
git clone https://github.com/dgraph-io/badger ${BADGER_DIR}
fi
cd ${BADGER_DIR} && git fetch --tags origin && git checkout ${BADGER_VERSION} && cd -
#go install -i github.com/dgraph-io/badger
BADGER_REPO=https://github.com/dgraph-io/badger
BADGER_DIR=${GOPATH}/src/github.com/dgraph-io/badger
BADGER_TAG=v2.0.0 # Don't change this without also changing it in meta.yaml!!
ensure_checkout ${BADGER_REPO} ${BADGER_DIR} ${BADGER_TAG}

# badger dependencies
go get github.com/DataDog/zstd
go get github.com/dgraph-io/ristretto

go get github.com/AndreasBriese/bbloom
go get github.com/dgryski/go-farm
Expand All @@ -163,26 +172,23 @@ go get github.com/dustin/go-humanize
go get github.com/coocood/freecache

# Openstack Swift
go get github.com/ncw/swift
#go get github.com/ncw/swift
SWIFT_REPO=https://github.com/ncw/swift
SWIFT_DIR=${GOPATH}/src/github.com/ncw/swift
SWIFT_TAG=master
SWIFT_SHA=753d2090bb62619675997bd87a8e3af423a00f2d
ensure_checkout ${SWIFT_REPO} ${SWIFT_DIR} ${SWIFT_TAG} ${SWIFT_SHA}

# Go Cloud Development Kit
go get gocloud.dev
go get github.com/google/wire
go get golang.org/x/xerrors

# kafka
CONFLUENTINC_DIR=${GOPATH}/src/github.com/confluentinc
KAFKA_GO_DIR=${CONFLUENTINC_DIR}/confluent-kafka-go
mkdir -p ${CONFLUENTINC_DIR}

# Can't use 'go get' directly, because that gets the newest version and we want something older.
# Instead, we clone it manually, checkout the tag we want, and then build it.
if [[ -d ${KAFKA_GO_DIR} ]]; then
cd ${KAFKA_GO_DIR} && git fetch && cd -
else
git clone https://github.com/confluentinc/confluent-kafka-go ${KAFKA_GO_DIR}
fi
cd ${KAFKA_GO_DIR} && git fetch --tags origin && git checkout v1.3.0 && cd -
KAFKA_GO_REPO=https://github.com/confluentinc/confluent-kafka-go
KAFKA_GO_DIR=${GOPATH}/src/github.com/confluentinc/confluent-kafka-go
KAFKA_GO_TAG=v1.3.0
ensure_checkout ${KAFKA_GO_REPO} ${KAFKA_GO_DIR} ${KAFKA_GO_TAG}

if [ $(uname) == "Linux" ]; then
# For some reason, the confluent kafka package cannot be built correctly unless you set LD_LIBRARY_PATH,
Expand Down

0 comments on commit 731b242

Please sign in to comment.