-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGNUmakefile
105 lines (84 loc) · 3.59 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
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
TEST?=$$(go list ./... |grep -v 'vendor')
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=citrixitm
DOCKER_SOURCE_DIR=/terraform-provider-$(PKG_NAME)
DOCKER_IMAGE_NAME=$(PKG_NAME)-terraform
DOCKER_CONTAINER_NAME=$(PKG_NAME)_tf_dev_container
default: build
build: fmtcheck
go install
test: fmtcheck
go test ./...
testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
install-tools:
GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
lint:
@echo "==> Checking source code against linters..."
@golangci-lint run ./$(PKG_NAME)
fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG_NAME)
# Currently required by tf-deploy compile
fmtcheck:
@echo "==> Checking source code against gofmt..."
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/
website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
docker-build:
@docker build -t $(DOCKER_IMAGE_NAME) .
# docker-start is used to resume an existing exited container named
# $(DOCKER_CONTAINER_NAME). Use docker-run to create a new container.
docker-start:
docker/start_container.sh $(DOCKER_CONTAINER_NAME)
docker-exec-bash:
@docker exec -it $(DOCKER_CONTAINER_NAME) /bin/bash
docker-exec-install-plugin:
@docker exec -it $(DOCKER_CONTAINER_NAME) docker/install_plugin_binary.sh
docker-show-env:
@echo ITM variables...
@echo ITM_BASE_URL: $(ITM_BASE_URL)
@echo ITM_CLIENT_ID: $(ITM_CLIENT_ID)
@echo ITM_CLIENT_SECRET: $(ITM_CLIENT_SECRET)
@echo ITM_HOST_MODULE_DIR: $(ITM_HOST_MODULE_DIR)
check-itm-env:
ifndef ITM_BASE_URL
$(error ITM_BASE_URL is undefined)
endif
ifndef ITM_CLIENT_ID
$(error ITM_CLIENT_ID is undefined)
endif
ifndef ITM_CLIENT_SECRET
$(error ITM_CLIENT_SECRET is undefined)
endif
# docker-run is used to create a container named $(DOCKER_CONTAINER_NAME).
# Use docker-start to restart an existing exited container by that name.
docker-run: docker-show-env check-itm-env
ifndef ITM_HOST_MODULE_DIR
@docker run -it --name $(DOCKER_CONTAINER_NAME) --env ITM_BASE_URL --env ITM_CLIENT_ID --env ITM_CLIENT_SECRET --mount type=bind,src=$(PWD),dst=$(DOCKER_SOURCE_DIR) $(DOCKER_IMAGE_NAME) /bin/bash
else
@echo "Attaching host directory $(ITM_HOST_MODULE_DIR) as a bind mount to /terraform-module inside the container."
@docker run -it --name $(DOCKER_CONTAINER_NAME) --env ITM_BASE_URL --env ITM_CLIENT_ID --env ITM_CLIENT_SECRET --mount type=bind,src=$(PWD),dst=$(DOCKER_SOURCE_DIR) --mount type=bind,src=$(ITM_HOST_MODULE_DIR),dst=/terraform-module $(DOCKER_IMAGE_NAME) /bin/bash
endif
.PHONY: build fmt fmtcheck install-tools lint test test-compile testacc website website-lint website-test