-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
168 lines (119 loc) · 2.64 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
SHELL=/bin/bash
export TFLINT_LOG := "info"
export TF_VAR_flux_git_user := "dummy"
export TF_VAR_flux_git_token := "dummy"
.PHONY: test
test: test-all
.PHONY: test-all
test-all: test-shared test-blue test-green
.PHONY: test-shared
test-shared: format-shared init-shared validate-shared lint-shared plan-shared
.PHONY: test-blue
test-blue: format-blue init-blue validate-blue lint-blue plan-blue
.PHONY: test-green
test-green: format-green init-green validate-green lint-green plan-green
define FORMAT
pushd ../../terraform/${1} \
&& terraform fmt \
&& popd
endef
.PHONY: format-shared
format-shared:
$(call FORMAT,shared)
.PHONY: format-blue
format-blue:
$(call FORMAT,blue)
.PHONY: format-green
format-green:
$(call FORMAT,green)
define FORMAT-CHECK
pushd ../../terraform/${1} \
&& terraform fmt -check \
&& popd
endef
.PHONY: format-check-shared
format-check-shared:
$(call FORMAT-CHECK,shared)
.PHONY: format-check-blue
format-check-blue:
$(call FORMAT-CHECK,blue)
.PHONY: format-check-green
format-check-green:
$(call FORMAT-CHECK,green)
define INIT
pushd ../fixtures/${1} \
&& terraform init -upgrade -no-color \
&& terraform fmt \
&& popd
endef
.PHONY: init-shared
init-shared:
$(call INIT,shared)
.PHONY: init-blue
init-blue:
$(call INIT,blue)
.PHONY: init-green
init-green:
$(call INIT,green)
define VALIDATE
pushd ../fixtures/${1} \
&& terraform validate -no-color -json | jq -e '. | select(.warning_count == 0)' \
&& popd
endef
.PHONY: validate-shared
validate-shared:
$(call VALIDATE,shared)
.PHONY: validate-blue
validate-blue:
$(call VALIDATE,blue)
.PHONY: validate-green
validate-green:
$(call VALIDATE,green)
define LINT
tflint --init \
&& pushd ../fixtures/${1} \
&& tflint --config ../../integration/.tflint.hcl --call-module-type=all --var-file=integration.tfvars --no-color -f compact \
&& popd
endef
.PHONY: lint-shared
lint-shared:
$(call LINT,shared)
.PHONY: lint-blue
lint-blue:
$(call LINT,blue)
.PHONY: lint-green
lint-green:
$(call LINT,green)
define PLAN
pushd ../fixtures/${1} \
&& terraform plan -var-file=integration.tfvars -no-color \
&& popd
endef
.PHONY: plan-shared
plan-shared:
$(call PLAN,shared)
.PHONY: plan-blue
plan-blue:
$(call PLAN,blue)
.PHONY: plan-green
plan-green:
$(call PLAN,green)
define CLEAN
pushd ../fixtures/${1} \
&& rm -f terraform.tfstate \
&& rm -f terraform.tfstate.backup \
&& popd
endef
.PHONY: clean
clean: clean-all
.PHONY: clean-all
clean-all: clean-blue clean-green clean-shared
.PHONY: clean-shared
clean-shared:
$(call CLEAN,shared)
.PHONY: clean-blue
clean-blue:
$(call CLEAN,blue)
.PHONY: clean-green
clean-green:
$(call CLEAN,shared)