-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
89 lines (67 loc) · 2.38 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
projectname?=vkv
default: help
.PHONY: help
help: ## list makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## build golang binary
@go build -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -o $(projectname)
.PHONY: install
install: ## install golang binary
@go install -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)"
.PHONY: run
run: ## run the app
@go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" main.go
PHONY: test
test: clean ## display test coverage
go test --cover -parallel=1 -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | sort -rnk3
PHONY: fmt
fmt: ## format go files
gofumpt -w .
gci write .
PHONY: lint
lint: ## lint go files
golangci-lint run -c .golang-ci.yml
.PHONY: pre-commit
pre-commit: ## run pre-commit hooks
pre-commit run
.PHONY: bootstrap
bootstrap: ## install build deps
go generate -tags tools tools/tools.go
.PHONY: vault
vault: clean ## set up a development vault server and write kv secrets
nohup vault server -dev -dev-root-token-id=root 2> /dev/null &
sleep 3
./scripts/prepare-vault.sh
.PHONY: vault-ent
vault-ent: clean ## set up a development vault enterprise server and write kv secrets
nohup vault server -dev -dev-root-token-id=root 2> /dev/null &
sleep 3
./scripts/prepare-vault.sh
vault namespace create sub
VAULT_NAMESPACE="sub" ./scripts/prepare-vault-ent.sh
VAULT_NAMESPACE="sub" vault namespace create sub2
VAULT_NAMESPACE="sub/sub2" ./scripts/prepare-vault-ent.sh
vault namespace create test
VAULT_NAMESPACE="test" vault namespace create test2
VAULT_NAMESPACE="test/test2" vault namespace create test3
VAULT_NAMESPACE="test/test2/test3" ./scripts/prepare-vault-ent.sh
.PHONY: clean
clean: ## clean the development vault
@rm -rf coverage.out dist/ $(projectname) manpages/ dist/ completions/ || true
@kill -9 $(shell pgrep -x vault) 2> /dev/null || true
@kill -9 $(shell pgrep -x vault-ent) 2> /dev/null || true
ASSETS = diff demo fzf
.PHONY: assets
assets: clean vault-ent ## generate all assets
for i in $(ASSETS); do \
vhs < assets/tapes/$$i.tape; \
done
.PHONY: docs
docs: ## build and serve docs
mkdocs serve
.PHONY: docgen
docgen:
go run main.go docs
find ./docs -name '*.md' -print0 | xargs -0 sed -i 's/```vkv/```go/g'