mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Allow easier swapping of Go version (#8102)
This commit is contained in:
37
Makefile
37
Makefile
@@ -4,7 +4,7 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
export RELEASE_GPG_KEY_FINGERPRINT := 91A6 E7F8 5D05 C656 30BE F189 5185 2D87 348F FC4C
|
||||
|
||||
TEST?=$$(go list ./... | grep -v /vendor/ | grep -v /integ)
|
||||
TEST?=$$($(GO_CMD) list ./... | grep -v /vendor/ | grep -v /integ)
|
||||
TEST_TIMEOUT?=45m
|
||||
EXTENDED_TEST_TIMEOUT=60m
|
||||
INTEG_TEST_TIMEOUT=120m
|
||||
@@ -21,6 +21,7 @@ GOFMT_FILES?=$$(find . -name '*.go' | grep -v pb.go | grep -v vendor)
|
||||
|
||||
|
||||
GO_VERSION_MIN=1.12.7
|
||||
GO_CMD?=go
|
||||
CGO_ENABLED?=0
|
||||
ifneq ($(FDB_ENABLED), )
|
||||
CGO_ENABLED=1
|
||||
@@ -59,11 +60,11 @@ test: prep
|
||||
VAULT_TOKEN= \
|
||||
VAULT_DEV_ROOT_TOKEN_ID= \
|
||||
VAULT_ACC= \
|
||||
go test -tags='$(BUILD_TAGS)' $(TEST) $(TESTARGS) -timeout=$(TEST_TIMEOUT) -parallel=20
|
||||
$(GO_CMD) test -tags='$(BUILD_TAGS)' $(TEST) $(TESTARGS) -timeout=$(TEST_TIMEOUT) -parallel=20
|
||||
|
||||
testcompile: prep
|
||||
@for pkg in $(TEST) ; do \
|
||||
go test -v -c -tags='$(BUILD_TAGS)' $$pkg -parallel=4 ; \
|
||||
$(GO_CMD) test -v -c -tags='$(BUILD_TAGS)' $$pkg -parallel=4 ; \
|
||||
done
|
||||
|
||||
# testacc runs acceptance tests
|
||||
@@ -72,7 +73,7 @@ testacc: prep
|
||||
echo "ERROR: Set TEST to a specific package"; \
|
||||
exit 1; \
|
||||
fi
|
||||
VAULT_ACC=1 go test -tags='$(BUILD_TAGS)' $(TEST) -v $(TESTARGS) -timeout=$(EXTENDED_TEST_TIMEOUT)
|
||||
VAULT_ACC=1 $(GO_CMD) test -tags='$(BUILD_TAGS)' $(TEST) -v $(TESTARGS) -timeout=$(EXTENDED_TEST_TIMEOUT)
|
||||
|
||||
# testrace runs the race checker
|
||||
testrace: prep
|
||||
@@ -81,7 +82,7 @@ testrace: prep
|
||||
VAULT_TOKEN= \
|
||||
VAULT_DEV_ROOT_TOKEN_ID= \
|
||||
VAULT_ACC= \
|
||||
go test -tags='$(BUILD_TAGS)' -race $(TEST) $(TESTARGS) -timeout=$(EXTENDED_TEST_TIMEOUT) -parallel=20
|
||||
$(GO_CMD) test -tags='$(BUILD_TAGS)' -race $(TEST) $(TESTARGS) -timeout=$(EXTENDED_TEST_TIMEOUT) -parallel=20
|
||||
|
||||
cover:
|
||||
./scripts/coverage.sh --html
|
||||
@@ -89,9 +90,9 @@ cover:
|
||||
# vet runs the Go source code static analysis tool `vet` to find
|
||||
# any common errors.
|
||||
vet:
|
||||
@go list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||
@$(GO_CMD) list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||
| grep -v '.*github.com/hashicorp/vault$$' \
|
||||
| xargs go vet ; if [ $$? -eq 1 ]; then \
|
||||
| xargs $(GO_CMD) vet ; if [ $$? -eq 1 ]; then \
|
||||
echo ""; \
|
||||
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
||||
echo "and fix them if necessary before submitting the code for reviewal."; \
|
||||
@@ -99,7 +100,7 @@ vet:
|
||||
|
||||
# lint runs vet plus a number of other checkers, it is more comprehensive, but louder
|
||||
lint:
|
||||
@go list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||
@$(GO_CMD) list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||
| xargs golangci-lint run; if [ $$? -eq 1 ]; then \
|
||||
echo ""; \
|
||||
echo "Lint found suspicious constructs. Please check the reported constructs"; \
|
||||
@@ -113,7 +114,7 @@ ci-lint:
|
||||
# source files.
|
||||
prep: fmtcheck
|
||||
@sh -c "'$(CURDIR)/scripts/goversioncheck.sh' '$(GO_VERSION_MIN)'"
|
||||
@go generate $(go list ./... | grep -v /vendor/)
|
||||
@$(GO_CMD) generate $($(GO_CMD) list ./... | grep -v /vendor/)
|
||||
@# Remove old (now broken) husky git hooks.
|
||||
@[ ! -d .git/hooks ] || grep -l '^# husky$$' .git/hooks/* | xargs rm -f
|
||||
@if [ -d .git/hooks ]; then cp .hooks/* .git/hooks/; fi
|
||||
@@ -129,7 +130,7 @@ ci-verify:
|
||||
bootstrap:
|
||||
@for tool in $(EXTERNAL_TOOLS) ; do \
|
||||
echo "Installing/Updating $$tool" ; \
|
||||
GO111MODULE=off go get -u $$tool; \
|
||||
GO111MODULE=off $(GO_CMD) get -u $$tool; \
|
||||
done
|
||||
|
||||
# Note: if you have plugins in GOPATH you can update all of them via something like:
|
||||
@@ -220,28 +221,28 @@ spellcheck:
|
||||
@misspell -error -source=text website/source
|
||||
|
||||
mysql-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/mysql-database-plugin ./plugins/database/mysql/mysql-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/mysql-database-plugin ./plugins/database/mysql/mysql-database-plugin
|
||||
|
||||
mysql-legacy-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/mysql-legacy-database-plugin ./plugins/database/mysql/mysql-legacy-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/mysql-legacy-database-plugin ./plugins/database/mysql/mysql-legacy-database-plugin
|
||||
|
||||
cassandra-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/cassandra-database-plugin ./plugins/database/cassandra/cassandra-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/cassandra-database-plugin ./plugins/database/cassandra/cassandra-database-plugin
|
||||
|
||||
influxdb-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/influxdb-database-plugin ./plugins/database/influxdb/influxdb-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/influxdb-database-plugin ./plugins/database/influxdb/influxdb-database-plugin
|
||||
|
||||
postgresql-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/postgresql-database-plugin ./plugins/database/postgresql/postgresql-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/postgresql-database-plugin ./plugins/database/postgresql/postgresql-database-plugin
|
||||
|
||||
mssql-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/mssql-database-plugin ./plugins/database/mssql/mssql-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/mssql-database-plugin ./plugins/database/mssql/mssql-database-plugin
|
||||
|
||||
hana-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/hana-database-plugin ./plugins/database/hana/hana-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/hana-database-plugin ./plugins/database/hana/hana-database-plugin
|
||||
|
||||
mongodb-database-plugin:
|
||||
@CGO_ENABLED=0 go build -o bin/mongodb-database-plugin ./plugins/database/mongodb/mongodb-database-plugin
|
||||
@CGO_ENABLED=0 $(GO_CMD) build -o bin/mongodb-database-plugin ./plugins/database/mongodb/mongodb-database-plugin
|
||||
|
||||
# GPG_KEY_VARS sets FPR to the fingerprint with no spaces and GIT_GPG_KEY_ID to a git compatible gpg key id.
|
||||
define GPG_KEY_VARS
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GO_CMD=${GO_CMD:-go}
|
||||
|
||||
GO_VERSION_MIN=$1
|
||||
echo "==> Checking that build is using go version >= $1..."
|
||||
|
||||
if go version | grep -q devel;
|
||||
if $GO_CMD version | grep -q devel;
|
||||
then
|
||||
GO_VERSION="devel"
|
||||
else
|
||||
GO_VERSION=$(go version | grep -o 'go[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | tr -d 'go')
|
||||
GO_VERSION=$($GO_CMD version | grep -o 'go[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | tr -d 'go')
|
||||
|
||||
IFS="." read -r -a GO_VERSION_ARR <<< "$GO_VERSION"
|
||||
IFS="." read -r -a GO_VERSION_REQ <<< "$GO_VERSION_MIN"
|
||||
|
||||
Reference in New Issue
Block a user