-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (59 loc) · 2.09 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
ACCTEST_COUNT ?= 1
ACCTEST_PARALLELISM ?= 20
ACCTEST_TIMEOUT ?= 120m
ifneq ($(origin TESTS), undefined)
RUNARGS = -run='$(TESTS)'
endif
# Default target
default: testacc
# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v -count $(ACCTEST_COUNT) -parallel $(ACCTEST_PARALLELISM) -timeout $(ACCTEST_TIMEOUT) $(RUNARGS) $(TESTARGS)
# Install the provider binary to GOBIN
.PHONY: install
install:
go install .
# Generate documentation
.PHONY: docs
docs:
go generate ./...
# Generate headers.
.PHONY: ltag
ltag:
go install github.com/kunalkushwaha/ltag@latest
ltag
# Generate headers.
.PHONY: ltag-validate
ltag-validate:
go install github.com/kunalkushwaha/ltag@latest
ltag -check
# Setup local development environment
.PHONY: local-build
local-build: install setup-terraformrc
# Setup or update ~/.terraformrc with GOBIN path for docker/docker provider
.PHONY: setup-terraformrc
setup-terraformrc:
@echo "Setting up ~/.terraformrc for local development..."
@GOBIN_PATH=$$(go env GOBIN); \
if [ -z "$$GOBIN_PATH" ]; then \
echo "GOBIN is not set. Defaulting to GOPATH/bin"; \
GOBIN_PATH=$$(go env GOPATH)/bin; \
fi; \
echo "Using GOBIN_PATH=$$GOBIN_PATH"; \
if [ ! -f ~/.terraformrc ]; then \
echo 'provider_installation {' > ~/.terraformrc; \
echo ' dev_overrides {' >> ~/.terraformrc; \
echo " \"registry.terraform.io/docker/docker\" = \"$$GOBIN_PATH\"" >> ~/.terraformrc; \
echo ' }' >> ~/.terraformrc; \
echo ' direct {}' >> ~/.terraformrc; \
echo '}' >> ~/.terraformrc; \
echo "~/.terraformrc has been created and set up for local development."; \
else \
if grep -q 'registry.terraform.io/docker/docker' ~/.terraformrc; then \
echo "The override for registry.terraform.io/docker/docker already exists in ~/.terraformrc."; \
else \
awk '/dev_overrides/ {print; print " \"registry.terraform.io/docker/docker\" = \"'"$$GOBIN_PATH"'\""; next}1' ~/.terraformrc > ~/.terraformrc.tmp && mv ~/.terraformrc.tmp ~/.terraformrc; \
echo "Added the override for registry.terraform.io/docker/docker to ~/.terraformrc."; \
fi; \
fi