forked from sl1pm4t/terraform-provider-kops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (99 loc) · 3.57 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
PROVIDER_VERSION := "0.0.1"
OS := $(shell echo `uname` | tr '[:upper:]' '[:lower:]')
TOOLS_DIR := $(PWD)/.tools
GOIMPORTS := $(TOOLS_DIR)/goimports
GOIMPORTS_VERSION := latest
GOARCH ?= amd64
.PHONY: all
all: clean gen fmt build verify-gen vet test
.PHONY: clean
clean:
@rm -f terraform-provider-kops
@rm -rf ./pkg/schemas/config
@rm -rf ./pkg/schemas/datasources
@rm -rf ./pkg/schemas/kops
@rm -rf ./pkg/schemas/kube
@rm -rf ./pkg/schemas/resources
@rm -rf ./pkg/schemas/utils
@rm -rf ./docs/data-sources/*.md
@rm -rf ./docs/provider-config/*.md
@rm -rf ./docs/resources/*.md
$(GOIMPORTS):
@echo Install goimports... >&2
@GOBIN=$(TOOLS_DIR) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)
.PHONY: gen-tf-code
gen-tf-code: clean $(GOIMPORTS)
@go run ./hack/gen-tf-code/...
@go fmt ./pkg/schemas/...
@$(GOIMPORTS) -w ./pkg/schemas
.PHONY: gen
gen: gen-tf-code
.PHONY: build
build: gen
@CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/eddycharly/terraform-provider-kops/pkg/version.BuildVersion=v${PROVIDER_VERSION}'" ./cmd/terraform-provider-kops
.PHONY: fmt
fmt: build
@go fmt ./cmd/...
@go fmt ./pkg/...
.PHONY: verify-gen
verify-gen: fmt
@git --no-pager diff .
@echo 'If this test fails, it is because the git diff is non-empty after running "make gen".' >&2
@echo 'To correct this, locally run "make gen", commit the changes, and re-run tests.' >&2
@git diff --quiet --exit-code .
.PHONY: test
test: fmt
@go test ./...
.PHONY: vet
vet: fmt
@go vet ./...
.PHONY: install
install: all
@mkdir -p ${HOME}/.terraform.d/plugins/github/eddycharly/kops/${PROVIDER_VERSION}/${OS}_${GOARCH}
@cp terraform-provider-kops $(HOME)/.terraform.d/plugins/github/eddycharly/kops/${PROVIDER_VERSION}/${OS}_${GOARCH}/terraform-provider-kops
# EXAMPLES FOR TERRAFORM >= 0.15
.PHONY: examples
examples: example-basic example-aws-profile example-aws-assume-role example-bastion example-klog
.PHONY: example-basic
example-basic: install
@terraform -chdir=./examples/basic init
@terraform -chdir=./examples/basic validate
@terraform -chdir=./examples/basic plan
.PHONY: example-aws-profile
example-aws-profile: install
@terraform -chdir=./examples/aws-profile init
@terraform -chdir=./examples/aws-profile validate
@terraform -chdir=./examples/aws-profile plan
.PHONY: example-aws-assume-role
example-aws-assume-role: install
@terraform -chdir=./examples/aws-assume-role init
@terraform -chdir=./examples/aws-assume-role validate
.PHONY: example-bastion
example-bastion: install
@terraform -chdir=./examples/bastion init
@terraform -chdir=./examples/bastion validate
@terraform -chdir=./examples/bastion plan
.PHONY: example-klog
example-klog: install
@terraform -chdir=./examples/klog init
@terraform -chdir=./examples/klog validate
@terraform -chdir=./examples/klog plan
# INTEGRATION TESTS
.PHONY: integration
integration: integration-basic integration-external-policies
.PHONY: integration-reset
integration-reset:
@rm -rf ./store
@rm -f ./terraform.tfstate
.PHONY: integration-basic
integration-basic: integration-reset
@terraform -chdir=./tests/basic init
@terraform -chdir=./tests/basic validate
@terraform -chdir=./tests/basic plan
@terraform -chdir=./tests/basic apply -auto-approve
.PHONY: integration-external-policies
integration-external-policies: integration-reset
@terraform -chdir=./tests/external-policies init
@terraform -chdir=./tests/external-policies validate
@terraform -chdir=./tests/external-policies plan
@terraform -chdir=./tests/external-policies apply -auto-approve