forked from myklst/terraform-provider-st-tencentcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (42 loc) · 1.52 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
# The name of Terraform custom provider.
CUSTOM_PROVIDER_NAME ?= terraform-provider-st-tencentcloud
# The url of Terraform provider.
CUSTOM_PROVIDER_URL ?= example.local/myklst/st-tencentcloud
UNAME := $(shell uname)
.PHONY: install-local-custom-provider
install-local-custom-provider: darwin_arm64 linux_amd64
darwin_arm64:
ifneq ($(UNAME), Darwin)
$(info 'skip darwin_arm64')
else
export PROVIDER_LOCAL_PATH='$(CUSTOM_PROVIDER_URL)'
GOOS=darwin GOARCH=arm64 go install .
GO_INSTALL_PATH="$$(go env GOPATH)/bin"; \
HOME_DIR="$$(ls -d ~)"; \
mkdir -p $$HOME_DIR/.terraform.d/plugins/$(CUSTOM_PROVIDER_URL)/0.1.0/darwin_arm64/; \
cp $$GO_INSTALL_PATH/$(CUSTOM_PROVIDER_NAME) $$HOME_DIR/.terraform.d/plugins/$(CUSTOM_PROVIDER_URL)/0.1.0/darwin_arm64/$(CUSTOM_PROVIDER_NAME)
endif
linux_amd64:
ifneq ($(UNAME), Linux)
$(info 'skip linux_amd64')
else
export PROVIDER_LOCAL_PATH='$(CUSTOM_PROVIDER_URL)'
GOOS=linux GOARCH=amd64 go install .
GO_INSTALL_PATH="$$(go env GOPATH)/bin"; \
HOME_DIR="$$(ls -d ~)"; \
mkdir -p $$HOME_DIR/.terraform.d/plugins/$(CUSTOM_PROVIDER_URL)/0.1.0/linux_amd64/; \
cp $$GO_INSTALL_PATH/$(CUSTOM_PROVIDER_NAME) $$HOME_DIR/.terraform.d/plugins/$(CUSTOM_PROVIDER_URL)/0.1.0/linux_amd64/$(CUSTOM_PROVIDER_NAME)
unset PROVIDER_LOCAL_PATH
endif
.PHONY: generate-terraform-document
generate-terraform-document:
go generate ./...
.PHONY: go-fmt
go-fmt:
goimports -l -w -local "github.com/myklst/$(CUSTOM_PROVIDER_NAME)/" .
.PHONY: go-lint
go-lint:
golangci-lint run
.PHONY: go-test
go-test:
go test -v ./...