-
Notifications
You must be signed in to change notification settings - Fork 2
/
GNUmakefile
74 lines (53 loc) · 2.14 KB
/
GNUmakefile
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
PLUGINS_DIR="$(HOME)/.terraform.d/plugins"
MONDOO_PLUGIN_DIR="registry.terraform.io/mondoohq/mondoo"
DEV_BIN_PATH="99.0.0/$$(go env GOOS)_$$(go env GOARCH)/terraform-provider-mondoo_v99.0.0"
default: testacc
default: build
build:
go build -v ./...
install: build
go install -v ./...
# See https://golangci-lint.run/
lint: ## Runs go linter
golangci-lint run
# Generate docs and copywrite headers
generate: ## Generate or update documentation
cd tools; go generate .
go generate ./...
fmt: ## Runs go formatter
gofmt -s -w -e .
.PHONY: dev/enter
dev/enter: write-terraform-rc cleanup-examples ## Updates the terraformrc to point to the DEV_BIN_PATH. Installs the provider to the DEV_BIN_PATH
mkdir -vp $(PLUGINS_DIR)
go build -o $(PLUGINS_DIR)/$(MONDOO_PLUGIN_DIR)/$(DEV_BIN_PATH)
.PHONY: dev/exit
dev/exit: remove-terraform-rc ## Removes development provider package from DEV_BIN_PATH
@rm -rvf "$(PLUGINS_DIR)/$(MONDOO_PLUGIN_DIR)"
.PHONY: write-terraform-rc
write-terraform-rc: ## Write to terraformrc file to mirror mondoohq/mondoo to DEV_BIN_PATH
scripts/mirror-provider.sh
.PHONY: remove-terraform-rc
remove-terraform-rc: ## Remove the terraformrc file
@rm -vf "$(HOME)/.terraformrc"
.PHONY: cleanup-examples
cleanup-examples: ## A quick way to clean up any left over Terraform files inside the examples/ folder
find . -name ".terraform*" -type f -exec rm -rf {} \;
find . -name "terraform.tfstate*" -type f -exec rm -rf {} \;
find . -name ".terraform.lock.hcl" -type f -exec rm -rf {} \;
help: ## Show this help
@grep -E '^([a-zA-Z_/-]+):.*## ' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf "%-20s %s\n", $$1, $$2}'
test: ## Runs go tests
go test -v -cover -timeout=120s -parallel=4 ./...
hcl/fmt: ## Runs terraform formatter
terraform fmt -recursive
hcl/lint: ## Runs terraform linter
tflint --recursive --config $(PWD)/.tflint.hcl
# Run acceptance tests
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
license: license/headers/check
license/headers/check:
copywrite headers --plan
license/headers/apply:
copywrite headers
.PHONY: build install lint generate fmt test testacc license license/headers/check license/headers/apply