Skip to content

Commit

Permalink
Remove gox in favor of go build (#26)
Browse files Browse the repository at this point in the history
* Remove gox in favor of go build

gox is no longer maintained and releases are done with `go build` now.
See hashicorp/vault#16353 where we removed gox
in Vault.

* revert accidental commit of snowflake.go file

* update readme link

* re-revert snowflake.go; confusion bc branch needed rebase
  • Loading branch information
fairclothjm authored Mar 16, 2023
1 parent 38c8ce1 commit f1a22c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 40 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
TOOL?=vault-plugin-database-snowflake
TEST?=$$(go list ./...)
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
EXTERNAL_TOOLS=\
github.com/mitchellh/gox
EXTERNAL_TOOLS=
BUILD_TAGS?=${TOOL}
GOFMT_FILES?=$$(find . -name '*.go')

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature requests can be submitted in the Issues section as well.
## Quick Links

* [Database Secrets Engine for Snowflake - Docs](https://www.vaultproject.io/docs/secrets/databases/snowflake)
* [Database Secrets Engine for Snowflake - API Docs](https://www.vaultproject.io/api-docs/secret/databases/snowflake)
* [Database Secrets Engine for Snowflake - API Docs](https://developer.hashicorp.com/vault/api-docs/secret/databases/snowflake)
* [Snowflake Website](https://www.snowflake.com/)
* [Vault Website](https://www.vaultproject.io)

Expand Down
46 changes: 9 additions & 37 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ TOOL=vault-plugin-database-snowflake
# This script builds the application from source for multiple platforms.
set -e

GO_CMD=${GO_CMD:-go}

# Get the parent directory of where this script is.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
Expand All @@ -23,11 +25,6 @@ BUILD_TAGS="${BUILD_TAGS}:-${TOOL}"
GIT_COMMIT="$(git rev-parse HEAD)"
GIT_DIRTY="$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"

# Determine the arch/os combos we're building for
XC_ARCH=${XC_ARCH:-"386 amd64"}
XC_OS=${XC_OS:-linux darwin windows freebsd openbsd netbsd solaris}
XC_OSARCH=${XC_OSARCH:-"linux/386 linux/amd64 linux/arm linux/arm64 darwin/386 darwin/amd64 darwin/arm64 windows/386 windows/amd64 freebsd/386 freebsd/amd64 freebsd/arm openbsd/386 openbsd/amd64 openbsd/arm netbsd/386 netbsd/amd64 netbsd/arm solaris/amd64"}

GOPATH=${GOPATH:-$(go env GOPATH)}
case $(uname) in
CYGWIN*)
Expand All @@ -41,46 +38,21 @@ rm -f bin/*
rm -rf pkg/*
mkdir -p bin/

# If its dev mode, only build for our self
if [ "${VAULT_DEV_BUILD}x" != "x" ]; then
XC_OS=$(go env GOOS)
XC_ARCH=$(go env GOARCH)
XC_OSARCH=$(go env GOOS)/$(go env GOARCH)
fi

# Build!
echo "==> Building..."
gox \
-osarch="${XC_OSARCH}" \
${GO_CMD} build \
-gcflags "${GCFLAGS}" \
-ldflags "-X github.com/hashicorp/${TOOL}/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}'" \
-output "pkg/{{.OS}}_{{.Arch}}/${TOOL}" \
-tags="${BUILD_TAGS}" \
./cmd/$TOOL
-o "bin/${TOOL}" \
-tags "${BUILD_TAGS}" \
"${DIR}/cmd/${TOOL}"

# Move all the compiled things to the $GOPATH/bin
OLDIFS=$IFS
IFS=: MAIN_GOPATH=($GOPATH)
IFS=$OLDIFS

# Copy our OS/Arch to the bin/ directory
DEV_PLATFORM="./pkg/$(go env GOOS)_$(go env GOARCH)"
for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do
cp ${F} bin/
cp ${F} ${MAIN_GOPATH}/bin/
done

if [ "${VAULT_DEV_BUILD}x" = "x" ]; then
# Zip and copy to the dist dir
echo "==> Packaging..."
for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do
OSARCH=$(basename ${PLATFORM})
echo "--> ${OSARCH}"

pushd $PLATFORM >/dev/null 2>&1
zip ../${OSARCH}.zip ./*
popd >/dev/null 2>&1
done
fi
rm -f ${MAIN_GOPATH}/bin/${TOOL}
cp bin/${TOOL} ${MAIN_GOPATH}/bin/

# Done!
echo
Expand Down

0 comments on commit f1a22c3

Please sign in to comment.