-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
104 lines (89 loc) · 2.83 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
SHELL := /bin/bash
GOLANGCI_LINT := golangci-lint run --disable-all \
-E errcheck \
-E goimports \
-E gosimple \
-E govet \
-E ineffassign \
-E staticcheck \
-E typecheck \
-E unused
VERSION := 0.11.10
.PHONY: test build
help:
@echo Usage:
@echo
@echo " make clean"
@echo
@echo " # Regenerate docs/."
@echo " make gen"
@echo
@echo " make lint"
@echo " make fmt"
@echo
@echo " make test"
@echo " make test-coverage"
@echo
@echo " make terraform CONFIGURATION=examples/basic ARGS=apply"
@echo
@echo " # Run in \"Debug\" mode (connect debugger to port 2345)."
@echo " make debug"
@echo
@echo " # Install terraform-provider-better-uptime locally."
@echo " #"
@echo " # terraform {"
@echo " # required_providers {"
@echo " # custom = {"
@echo " # source = \"registry.terraform.io/BetterStackHQ/better-uptime\""
@echo " # version = \"0.0.0-0\""
@echo " # }"
@echo " # }"
@echo " # }"
@echo " make install"
@echo
@echo " # Upload terraform-provider-better-uptime to GitHub."
@echo " make VERSION=0.0.0-0 release"
@echo
clean:
rm -f cover.out coverage.html terraform-provider-better-uptime
rm -rf release/
lint-init:
@test -n "$$(which golangci-lint)" || (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.46.2)
lint: lint-init
$(GOLANGCI_LINT)
terraform fmt -check -diff -recursive
fmt: lint-init
$(GOLANGCI_LINT) --fix
terraform fmt -recursive
gen:
go generate ./...
@echo
@echo "docs/ can be previewed at https://registry.terraform.io/tools/doc-preview"
test:
go test ./...
test-race:
go test -race ./...
test-coverage:
go test -coverprofile cover.out ./...
go tool cover -html=cover.out -o coverage.html
rm -f cover.out
@echo
@echo "open coverage.html to review the report"
# https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
terraform: install
cd $(CONFIGURATION) && rm -f .terraform.lock.hcl && terraform init && \
TF_LOG=DEBUG TF_PROVIDER_BETTERUPTIME_LOG_INSECURE=1 terraform $(ARGS)
build:
# -gcflags "all=-N -l" is here for delve (`go tool compile -help` for more)
go build -gcflags "all=-N -l" -ldflags "-X main.version=$(VERSION)"
install: build
PLUGIN_DIR="$$HOME/.terraform.d/plugins/registry.terraform.io/BetterStackHQ/better-uptime/$(VERSION)/$$(go env GOOS)_$$(go env GOARCH)" && \
mkdir -p "$$PLUGIN_DIR" && \
cp terraform-provider-better-uptime "$$PLUGIN_DIR/"
uninstall:
rm -rf "$$HOME/.terraform.d/plugins/registry.terraform.io/BetterStackHQ/better-uptime/$(VERSION)"
debug: build
# https://github.com/go-delve/delve/blob/master/Documentation/installation/README.md
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./terraform-provider-better-uptime -- --debug