-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (59 loc) · 2.14 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
BINDIR = bin
BIN = terraform-provider-kowabunga
LDFLAGS += -X main.version=$$(git describe --always --abbrev=40 --dirty)
GOVULNCHECK = $(BINDIR)/govulncheck
GOVULNCHECK_VERSION = v1.1.3
GOLINT = $(BINDIR)/golangci-lint
GOLINT_VERSION = v1.62.2
GOSEC = $(BINDIR)/gosec
GOSEC_VERSION = v2.21.4
V = 0
Q = $(if $(filter 1,$V),,@)
M = $(shell printf "\033[34;1m▶\033[0m")
.PHONY: all
all: mod fmt lint vet $(BIN) ; @
# Updates all go modules
update: ; $(info $(M) updating modules…) @
$Q go get -u ./...
$Q go mod tidy
.PHONY: mod
mod: ; $(info $(M) collecting modules…) @
$Q go mod download
$Q go mod tidy
.PHONY: fmt
fmt: ; $(info $(M) formatting code…) @
$Q go fmt ./internal/provider .
.PHONY: get-lint
get-lint: ; $(info $(M) downloading go-lint…) @
$Q test -x $(GOLINT) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLINT_VERSION)
.PHONY: lint
lint: get-lint ; $(info $(M) running linter…) @
$Q $(GOLINT) run -e SA1019 ./... ; exit 0
.PHONY: get-govulncheck
get-govulncheck: ; $(info $(M) downloading govulncheck…) @
$Q test -x $(GOVULNCHECK) || GOBIN="$(PWD)/$(BINDIR)/" go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)
.PHONY: vuln
vuln: get-govulncheck ; $(info $(M) running govulncheck…) @ ## Check for known vulnerabilities
$Q $(GOVULNCHECK) ./... ; exit 0
.PHONY: get-gosec
get-gosec: ; $(info $(M) downloading gosec…) @
$Q test -x $(GOSEC) || GOBIN="$(PWD)/$(BINDIR)/" go install github.com/securego/gosec/v2/cmd/gosec@$(GOSEC_VERSION)
.PHONY: sec
sec: get-gosec ; $(info $(M) running gosec…) @ ## AST / SSA code checks
$Q $(GOSEC) -terse -exclude=G101,G115 ./... ; exit 0
.PHONY: vet
vet: ; $(info $(M) running vetter…) @
$Q go vet ./internal/provider .
.PHONY: doc
doc: ; $(info $(M) generating documentation…) @
$Q go generate ./...
.PHONY: $(BIN)
$(BIN): ; $(info $(M) building terraform provider plugin…) @
$Q go build -ldflags "${LDFLAGS}"
.PHONY: install
install: ; $(info $(M) installing terraform provider plugin…) @
$Q go install -ldflags "${LDFLAGS}"
.PHONY: clean
clean: ; $(info $(M) cleanup…) @
$Q rm -f $(BIN)
$Q rm -f $(DINDIR)