File tree Expand file tree Collapse file tree 3 files changed +38
-11
lines changed Expand file tree Collapse file tree 3 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,11 @@ View **[Dockerfile](https://github.com/cytopia/docker-terraform-docs/blob/master
25
25
Tiny Alpine-based multistage-build dockerized version of [ terraform-docs] ( https://github.com/segmentio/terraform-docs ) <sup >[ 1] </sup >,
26
26
which additionally implements ` terraform-docs-replace ` allowing you to automatically and safely
27
27
replace the ` terraform-docs ` generated output infile.
28
- Furthermore this implementation is also ** Terraform >= 0.12 ready** . See [ Generic Usage] ( #generic ) for more details.
28
+ Furthermore this implementation is also ** Terraform >= 0.12 ready** < sup > [ 2 ] </ sup > . See [ Generic Usage] ( #generic ) for more details.
29
29
The image is built nightly against multiple stable versions and pushed to Dockerhub.
30
30
31
- <sub >[ 1] Official project: https://github.com/segmentio/terraform-docs </sub >
31
+ * <sub >[ 1] Official project: https://github.com/segmentio/terraform-docs </sub >
32
+ * <sub >[ 2] Based on an awk script by [ cloudposse/build-harness] ( https://github.com/cloudposse/build-harness/blob/master/bin/terraform-docs.awk ) </sub >
32
33
33
34
34
35
## Available Docker image versions
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ if [ "${#}" -ge "1" ]; then
144
144
# ##
145
145
elif [ " ${1} " = " terraform-docs-012" ]; then
146
146
mkdir -p /tmp-012
147
- awk -f /usr/bin/ terraform-docs.awk * .tf > " /tmp-012/tmp.tf"
147
+ awk -f /terraform-docs.awk * .tf > " /tmp-012/tmp.tf"
148
148
149
149
# Remove last argument (path)
150
150
args=" $( trim_last_arg " ${@ } " ) " # get all the args except the last arg
Original file line number Diff line number Diff line change 10
10
braceCnt++
11
11
}
12
12
13
- if ( /\} / ) {
13
+ if ( /\} / ) {
14
14
braceCnt--
15
15
}
16
16
17
+ # [START] variable or output block started
17
18
if ($0 ~ /(variable| output) "(. *? )" /) {
19
+ # [CLOSE] "default" block
20
+ if (blockDefCnt > 0 ) {
21
+ blockDefCnt = 0
22
+ }
18
23
blockCnt++
19
24
print $0
20
25
}
21
26
27
+ # [START] multiline default statement started
22
28
if (blockCnt > 0 ) {
23
- if ($1 == " description " ) {
29
+ if ($1 == " default " ) {
24
30
print $0
31
+ if ($NF ~ /[\[ \(\{ ] /) {
32
+ blockDefCnt++
33
+ blockDefStart= 1
34
+ }
25
35
}
26
36
}
27
37
28
- if (blockCnt > 0 ) {
29
- if ($1 == " default " ) {
30
- if (braceCnt > 1 ) {
31
- print " default = {} "
32
- } else {
33
- print $ 0
38
+ # [PRINT] single line "description"
39
+ if (blockDefCnt == 0 ) {
40
+ if ($1 == " description " ) {
41
+ # [CLOSE] " default" block
42
+ if (blockDefCnt > 0 ) {
43
+ blockDefCnt = 0
34
44
}
45
+ print $0
35
46
}
36
47
}
37
48
49
+ # [PRINT] single line "type"
38
50
if (blockCnt > 0 ) {
39
51
if ($1 == " type" ) {
52
+ # [CLOSE] "default" block
53
+ if (blockDefCnt > 0 ) {
54
+ blockDefCnt = 0
55
+ }
40
56
type= $3
41
57
if (type ~ " object" ) {
42
58
print " type = \" object\" "
46
62
}
47
63
}
48
64
65
+ # [CLOSE] variable/output block
49
66
if (blockCnt > 0 ) {
50
67
if (braceCnt == 0 && blockCnt > 0 ) {
51
68
blockCnt--
52
69
print $0
53
70
}
54
71
}
72
+
73
+ # [PRINT] Multiline "default" statement
74
+ if (blockCnt > 0 && blockDefCnt > 0 ) {
75
+ if (blockDefStart == 1 ) {
76
+ blockDefStart = 0
77
+ } else {
78
+ print $0
79
+ }
80
+ }
55
81
}
You can’t perform that action at this time.
0 commit comments