-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
124 lines (100 loc) · 3.32 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
TEST?=$$(go list ./...)
HOSTNAME=github.com
NAMESPACE=aziontech
NAME=azion
VERSION=$(shell git describe --tags --always)
DEV_VERSION=0.1.0
OS_ARCH=${GOHOSTOS}_${GOHOSTARCH}
CURDIR=$(shell pwd)
GO := $(shell which go)
ifeq (, $(GO))
$(error "No go binary found in $(PATH), please install go 1.19 or higher before continue")
endif
GOPATH ?= $(shell $(GO) env GOPATH)
GOBIN ?= $(GOPATH)/bin
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS || echo unknown)
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH || echo unknown)
GOSEC ?= $(GOBIN)/gosec
GORELEASER ?= $(shell which goreleaser)
GOFMT ?= $(shell which gofmt)
GOFMT_FILES?=$$(find . -name '*.go')
default: install
install:
go mod tidy
go install .
fmt:
go fmt ./...
vet:
go vet ./...
generate:
go generate ./...
.PHONY: release
release: tools
$(GORELEASER) release --rm-dist --snapshot --skip-publish --skip-sign
.PHONY: clean-release
clean-release:
rm -Rf dist/*
clean-dev:
@echo "==> Removing development version ($(DEV_VERSION))"
@rm -rf ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${DEV_VERSION}/${OS_ARCH}/terraform-provider-azion_$(DEV_VERSION)
@if [ -d ./terraformScripts ]; then \
echo "==> Removing terraform Files "; \
rm -rf ./terraformScripts/.terraform*; \
rm -rf ./terraformScripts/resource/.terraform*; \
find ./terraformScripts/ -name ".terraform*" -exec rm {} \; ; \
find ./terraformScripts/ -name *.lock.hcl -exec rm {} \; ; \
find ./terraformScripts/ -name "*tfstate*" -exec rm {} \; ; \
fi
install-dev:
@echo "==> Building development version ($(DEV_VERSION))"
go build -gcflags="all=-N -l" -o terraform-provider-azion_$(DEV_VERSION)
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${DEV_VERSION}/${OS_ARCH}
mv terraform-provider-azion_$(DEV_VERSION) ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${DEV_VERSION}/${OS_ARCH}
.PHONY: testacc
testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -parallel 1
.PHONY: vet
vet:
@$(GO) vet $(TEST) ; if [ $$? -eq 1 ]; then \
echo "\nVet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
.PHONY: fmt
fmt:
@$(GOFMT) -w $(GOFMT_FILES)
.PHONY: lint
lint: get-lint-deps ## running GoLint
@ $(GOBIN)/golangci-lint run ./... --config .golintci.yml
.PHONY: get-lint-deps
get-lint-deps:
@if [ ! -x $(GOBIN)/golangci-lint ]; then\
curl -sfL \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.52.2 ;\
fi
.PHONY: sec
sec: get-gosec-deps
@ -$(GOSEC) ./...
.PHONY: get-gosec-deps
get-gosec-deps:
@if [ ! -x $(GOBIN)/gosec ]; then\
curl -sfL \
https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(GOBIN) v2.15.0 ;\
fi
func-init:
@rm -rf func-tests/.terraform.lock.hcl
@rm -rf func-tests/.terraform
@rm -rf func-tests/terraform.log
@rm -rf func-tests/terraform.tfstate
@cd func-tests && terraform init
func-plan:
@cd func-tests && TF_LOG=TRACE TF_LOG_PATH=./terraform.log terraform plan
func-apply:
@cd func-tests && TF_LOG=TRACE TF_LOG_PATH=./terraform.log terraform apply -auto-approve -lock=false
func-destroy:
@cd func-tests && terraform destroy -auto-approve
debug:
@go build -o terraform-provider-azion
@dlv exec terraform-provider-azion -- -debug
dev:
@go run main.go -debug