-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
57 lines (47 loc) · 1.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
REPO_DIR := $(shell basename $(CURDIR))
PLUGIN_DIR := $(GOPATH)/vault-plugins
PLUGIN_NAME := $(shell command ls cmd/)
.PHONY: default
default: dev
.PHONY: dev
dev:
CGO_ENABLED=0 go build -o bin/$(PLUGIN_NAME) cmd/$(PLUGIN_NAME)/main.go
.PHONY: bootstrap
bootstrap:
@echo "Downloading tools ..."
@go generate -tags tools tools/tools.go
# This should only ever be performed once, so we lean on the cmd/ directory
# to indicate whether this has already been done.
@if [ "$(PLUGIN_NAME)" != "$(REPO_DIR)" ]; then \
echo "Renaming cmd/$(PLUGIN_NAME) to cmd/$(REPO_DIR) ..."; \
mv cmd/$(PLUGIN_NAME) to cmd/$(REPO_DIR); \
echo "Renaming Go module to github.com/hashicorp/$(REPO_DIR) ..."; \
go mod edit -module github.com/hashicorp/$(REPO_DIR); \
fi
.PHONY: test
test: fmtcheck
CGO_ENABLED=0 go test -v ./... $(TESTARGS) -timeout=20m
.PHONY: testacc
testacc: fmtcheck
CGO_ENABLED=0 VAULT_ACC=1 go test -v ./... $(TESTARGS) -timeout=20m
.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
.PHONY: fmt
fmt:
gofumpt -l -w . && cd bootstrap/terraform && terraform fmt
.PHONY: setup-env
setup-env:
cd bootstrap/terraform && terraform init && terraform apply -auto-approve
.PHONY: teardown-env
teardown-env:
cd bootstrap/terraform && terraform init && terraform destroy -auto-approve
.PHONY: configure
configure: dev
@./scripts/configure.sh \
$(PLUGIN_DIR) \
$(PLUGIN_NAME) \
$(TEST_REDIS_HOST) \
$(TEST_REDIS_PORT) \
$(TEST_REDIS_USERNAME) \
$(TEST_REDIS_PASSWORD)