4
4
5
5
.PHONY : build rebuild lint test _test-version _test-run-one _test-run-two tag pull login push enter
6
6
7
- CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
8
-
7
+ # --------------------------------------------------------------------------------------------------
8
+ # VARIABLES
9
+ # --------------------------------------------------------------------------------------------------
9
10
DIR = .
10
- FILE = Dockerfile
11
+ FILE_012 = Dockerfile-0.12
12
+ FILE_011 = Dockerfile-0.11
11
13
IMAGE = cytopia/terraform-docs
12
14
TAG = latest
15
+ NO_CACHE =
16
+
17
+
18
+ # --------------------------------------------------------------------------------------------------
19
+ # DEFAULT TARGET
20
+ # --------------------------------------------------------------------------------------------------
21
+ help :
22
+ @echo " lint Lint this repository."
23
+ @echo " build [TAG=x.y.z] Build terraform-docs docker image."
24
+ @echo " rebuild [TAG=x.y.z] Build terraform-docs docker image without cache."
25
+ @echo " test [TAG=x.y.z] Test built terraform-docs docker image."
13
26
27
+
28
+ # --------------------------------------------------------------------------------------------------
29
+ # BUILD TARGETS
30
+ # --------------------------------------------------------------------------------------------------
14
31
build :
15
- docker build --build-arg VERSION=$(TAG ) -t $(IMAGE ) -f $(DIR ) /$(FILE ) $(DIR )
32
+ if [ " $( TAG) " = " 0.1.0" ] \
33
+ || [ " $( TAG) " = " 0.1.1" ] \
34
+ || [ " $( TAG) " = " 0.2.0" ] \
35
+ || [ " $( TAG) " = " 0.3.0" ] \
36
+ || [ " $( TAG) " = " 0.4.0" ] \
37
+ || [ " $( TAG) " = " 0.4.5" ] \
38
+ || [ " $( TAG) " = " 0.5.0" ] \
39
+ || [ " $( TAG) " = " 0.6.0" ] \
40
+ || [ " $( TAG) " = " 0.7.0" ]; then \
41
+ docker build $(NO_CACHE ) --build-arg VERSION=$(TAG ) -t $(IMAGE ) -f $(DIR ) /$(FILE_011 ) $(DIR ) ; \
42
+ else \
43
+ docker build $(NO_CACHE ) --build-arg VERSION=$(TAG ) -t $(IMAGE ) -f $(DIR ) /$(FILE_012 ) $(DIR ) ; \
44
+ fi
45
+
46
+ rebuild : NO_CACHE=--no-cache
47
+ rebuild : build
16
48
17
- rebuild : pull
18
- docker build --no-cache --build-arg VERSION=$(TAG ) -t $(IMAGE ) -f $(DIR ) /$(FILE ) $(DIR )
19
49
50
+ # --------------------------------------------------------------------------------------------------
51
+ # LINT TARGETS
52
+ # --------------------------------------------------------------------------------------------------
20
53
lint :
21
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-cr --text --ignore ' .git/,.github/,tests/' --path .
22
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-crlf --text --ignore ' .git/,.github/,tests/' --path .
23
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-trailing-single-newline --text --ignore ' .git/,.github/,tests/' --path .
24
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-trailing-space --text --ignore ' .git/,.github/,tests/' --path .
25
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-utf8 --text --ignore ' .git/,.github/,tests/' --path .
26
- @docker run --rm -v $(CURRENT_DIR ) :/data cytopia/file-lint file-utf8-bom --text --ignore ' .git/,.github/,tests/' --path .
54
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-cr --text --ignore ' .git/,.github/,tests/' --path .
55
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-crlf --text --ignore ' .git/,.github/,tests/' --path .
56
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-trailing-single-newline --text --ignore ' .git/,.github/,tests/' --path .
57
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-trailing-space --text --ignore ' .git/,.github/,tests/' --path .
58
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-utf8 --text --ignore ' .git/,.github/,tests/' --path .
59
+ @docker run --rm -v $(PWD ) :/data cytopia/file-lint file-utf8-bom --text --ignore ' .git/,.github/,tests/' --path .
27
60
61
+
62
+ # --------------------------------------------------------------------------------------------------
63
+ # TEST TARGETS
64
+ # --------------------------------------------------------------------------------------------------
28
65
test :
29
66
@$(MAKE ) --no-print-directory _test-version
30
67
@$(MAKE ) --no-print-directory _test-run-one
@@ -64,7 +101,7 @@ _test-run-one:
64
101
@echo ' <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' > tests/basic/TEST-$(TAG ) .md
65
102
@echo >> tests/basic/TEST-$(TAG ) .md
66
103
@echo ' <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' >> tests/basic/TEST-$(TAG ) .md
67
- @if ! docker run --rm -v $(CURRENT_DIR ) /tests/basic:/data $(IMAGE ) terraform-docs-replace md TEST-$(TAG ) .md; then \
104
+ @if ! docker run --rm -v $(PWD ) /tests/basic:/data $(IMAGE ) terraform-docs-replace md TEST-$(TAG ) .md; then \
68
105
echo " Failed" ; \
69
106
exit 1; \
70
107
fi ; \
@@ -83,27 +120,31 @@ _test-run-two:
83
120
@echo " - Testing terraform-docs (2/2)"
84
121
@echo " ------------------------------------------------------------"
85
122
$(eval TFDOC_ARG_SORT = $(shell \
86
- if [ " $( TAG) " = " latest " ] || [ " $( TAG) " = " 0.7.0 " ] || [ " $( TAG) " = " 0.6 .0" ] || [ " $( TAG) " = " 0.5.0 " ]; then \
123
+ if [ " $( TAG) " ! = " 0.1.0 " ] && [ " $( TAG) " ! = " 0.1.1 " ] && [ " $( TAG ) " != " 0.2.0 " ] && [ " $( TAG) " ! = " 0.3 .0" ] && [ " $( TAG) " ! = " 0.4.0 " ] && [ " $( TAG ) " != " 0.4.5 " ]; then \
87
124
echo " --sort-inputs-by-required" ; \
88
125
fi ; \
89
126
))
90
127
$(eval TFDOC_ARG_AGGREGATE = $(shell \
91
- if [ " $( TAG) " = " latest " ] || [ " $( TAG ) " = " 0.7 .0" ] || [ " $( TAG) " = " 0.6.0 " ] || [ " $( TAG) " = " 0.5 .0" ] || [ " $( TAG) " = " 0.4.5 " ] || [ " $( TAG ) " = " 0.4 .0" ]; then \
128
+ if [ " $( TAG) " ! = " 0.1 .0" ] && [ " $( TAG) " ! = " 0.1.1 " ] && [ " $( TAG) " ! = " 0.2 .0" ] && [ " $( TAG) " ! = " 0.3 .0" ]; then \
92
129
echo " --with-aggregate-type-defaults" ; \
93
130
fi ; \
94
131
))
95
132
@# ---- Test Terraform < 0.12 ----
96
- @if ! docker run --rm -v $(CURRENT_DIR ) /tests/default:/data $(IMAGE ) terraform-docs-replace $(TFDOC_ARG_SORT ) $(TFDOC_ARG_AGGREGATE ) md TEST-$(TAG ) .md; then \
133
+ @if ! docker run --rm -v $(PWD ) /tests/default:/data $(IMAGE ) terraform-docs-replace $(TFDOC_ARG_SORT ) $(TFDOC_ARG_AGGREGATE ) md TEST-$(TAG ) .md; then \
97
134
echo " Failed" ; \
98
135
exit 1; \
99
136
fi
100
137
@# ---- Test Terraform >= 0.12 ----
101
- @if ! docker run --rm -v $(CURRENT_DIR ) /tests/0.12:/data $(IMAGE ) terraform-docs-replace-012 $(TFDOC_ARG_SORT ) $(TFDOC_ARG_AGGREGATE ) md TEST-$(TAG ) .md; then \
138
+ @if ! docker run --rm -v $(PWD ) /tests/0.12:/data $(IMAGE ) terraform-docs-replace-012 $(TFDOC_ARG_SORT ) $(TFDOC_ARG_AGGREGATE ) md TEST-$(TAG ) .md; then \
102
139
echo " Failed" ; \
103
140
exit 1; \
104
141
fi ; \
105
142
echo " Success" ;
106
143
144
+
145
+ # --------------------------------------------------------------------------------------------------
146
+ # HELPER TARGETS
147
+ # --------------------------------------------------------------------------------------------------
107
148
tag :
108
149
docker tag $(IMAGE ) $(IMAGE ) :$(TAG )
109
150
0 commit comments