mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 14:11:10 +01:00
Allow easier swapping of Go version (#8102)
This commit is contained in:
parent
45adc7892c
commit
61c5efc0eb
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
|
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
|
TEST_TIMEOUT?=45m
|
||||||
EXTENDED_TEST_TIMEOUT=60m
|
EXTENDED_TEST_TIMEOUT=60m
|
||||||
INTEG_TEST_TIMEOUT=120m
|
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_VERSION_MIN=1.12.7
|
||||||
|
GO_CMD?=go
|
||||||
CGO_ENABLED?=0
|
CGO_ENABLED?=0
|
||||||
ifneq ($(FDB_ENABLED), )
|
ifneq ($(FDB_ENABLED), )
|
||||||
CGO_ENABLED=1
|
CGO_ENABLED=1
|
||||||
@ -59,11 +60,11 @@ test: prep
|
|||||||
VAULT_TOKEN= \
|
VAULT_TOKEN= \
|
||||||
VAULT_DEV_ROOT_TOKEN_ID= \
|
VAULT_DEV_ROOT_TOKEN_ID= \
|
||||||
VAULT_ACC= \
|
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
|
testcompile: prep
|
||||||
@for pkg in $(TEST) ; do \
|
@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
|
done
|
||||||
|
|
||||||
# testacc runs acceptance tests
|
# testacc runs acceptance tests
|
||||||
@ -72,7 +73,7 @@ testacc: prep
|
|||||||
echo "ERROR: Set TEST to a specific package"; \
|
echo "ERROR: Set TEST to a specific package"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
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 runs the race checker
|
||||||
testrace: prep
|
testrace: prep
|
||||||
@ -81,7 +82,7 @@ testrace: prep
|
|||||||
VAULT_TOKEN= \
|
VAULT_TOKEN= \
|
||||||
VAULT_DEV_ROOT_TOKEN_ID= \
|
VAULT_DEV_ROOT_TOKEN_ID= \
|
||||||
VAULT_ACC= \
|
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:
|
cover:
|
||||||
./scripts/coverage.sh --html
|
./scripts/coverage.sh --html
|
||||||
@ -89,9 +90,9 @@ cover:
|
|||||||
# vet runs the Go source code static analysis tool `vet` to find
|
# vet runs the Go source code static analysis tool `vet` to find
|
||||||
# any common errors.
|
# any common errors.
|
||||||
vet:
|
vet:
|
||||||
@go list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
@$(GO_CMD) list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||||
| grep -v '.*github.com/hashicorp/vault$$' \
|
| grep -v '.*github.com/hashicorp/vault$$' \
|
||||||
| xargs go vet ; if [ $$? -eq 1 ]; then \
|
| xargs $(GO_CMD) vet ; if [ $$? -eq 1 ]; then \
|
||||||
echo ""; \
|
echo ""; \
|
||||||
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
||||||
echo "and fix them if necessary before submitting the code for reviewal."; \
|
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 runs vet plus a number of other checkers, it is more comprehensive, but louder
|
||||||
lint:
|
lint:
|
||||||
@go list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
@$(GO_CMD) list -f '{{.Dir}}' ./... | grep -v /vendor/ \
|
||||||
| xargs golangci-lint run; if [ $$? -eq 1 ]; then \
|
| xargs golangci-lint run; if [ $$? -eq 1 ]; then \
|
||||||
echo ""; \
|
echo ""; \
|
||||||
echo "Lint found suspicious constructs. Please check the reported constructs"; \
|
echo "Lint found suspicious constructs. Please check the reported constructs"; \
|
||||||
@ -113,7 +114,7 @@ ci-lint:
|
|||||||
# source files.
|
# source files.
|
||||||
prep: fmtcheck
|
prep: fmtcheck
|
||||||
@sh -c "'$(CURDIR)/scripts/goversioncheck.sh' '$(GO_VERSION_MIN)'"
|
@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.
|
@# Remove old (now broken) husky git hooks.
|
||||||
@[ ! -d .git/hooks ] || grep -l '^# husky$$' .git/hooks/* | xargs rm -f
|
@[ ! -d .git/hooks ] || grep -l '^# husky$$' .git/hooks/* | xargs rm -f
|
||||||
@if [ -d .git/hooks ]; then cp .hooks/* .git/hooks/; fi
|
@if [ -d .git/hooks ]; then cp .hooks/* .git/hooks/; fi
|
||||||
@ -129,7 +130,7 @@ ci-verify:
|
|||||||
bootstrap:
|
bootstrap:
|
||||||
@for tool in $(EXTERNAL_TOOLS) ; do \
|
@for tool in $(EXTERNAL_TOOLS) ; do \
|
||||||
echo "Installing/Updating $$tool" ; \
|
echo "Installing/Updating $$tool" ; \
|
||||||
GO111MODULE=off go get -u $$tool; \
|
GO111MODULE=off $(GO_CMD) get -u $$tool; \
|
||||||
done
|
done
|
||||||
|
|
||||||
# Note: if you have plugins in GOPATH you can update all of them via something like:
|
# 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
|
@misspell -error -source=text website/source
|
||||||
|
|
||||||
mysql-database-plugin:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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.
|
# 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
|
define GPG_KEY_VARS
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
GO_CMD=${GO_CMD:-go}
|
||||||
|
|
||||||
GO_VERSION_MIN=$1
|
GO_VERSION_MIN=$1
|
||||||
echo "==> Checking that build is using go version >= $1..."
|
echo "==> Checking that build is using go version >= $1..."
|
||||||
|
|
||||||
if go version | grep -q devel;
|
if $GO_CMD version | grep -q devel;
|
||||||
then
|
then
|
||||||
GO_VERSION="devel"
|
GO_VERSION="devel"
|
||||||
else
|
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_ARR <<< "$GO_VERSION"
|
||||||
IFS="." read -r -a GO_VERSION_REQ <<< "$GO_VERSION_MIN"
|
IFS="." read -r -a GO_VERSION_REQ <<< "$GO_VERSION_MIN"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user