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
2525Tiny Alpine-based multistage-build dockerized version of [ terraform-docs] ( https://github.com/segmentio/terraform-docs ) <sup >[ 1] </sup >,
2626which additionally implements ` terraform-docs-replace `  allowing you to automatically and safely
2727replace 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.
2929The image is built nightly against multiple stable versions and pushed to Dockerhub.
3030
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 >
3233
3334
3435## Available Docker image versions  
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ if [ "${#}" -ge "1" ]; then
144144	# ##
145145	elif  [ " ${1} " =  " terraform-docs-012" ;  then 
146146		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" 
148148
149149		#  Remove last argument (path)
150150		args=" $( trim_last_arg " ${@ } " ) " #  get all the args except the last arg
Original file line number Diff line number Diff line change 1010    braceCnt++ 
1111  }
1212
13-   if  ( /\} 
13+     if  ( /\} 
1414    braceCnt-- 
1515  }
1616
17+   # [START] variable or output block started 
1718  if  ($0  ~  /(variable| output) "(. *? )" /) {
19+     # [CLOSE] "default" block 
20+     if  (blockDefCnt >  0 ) {
21+       blockDefCnt =  0 
22+     }
1823    blockCnt++ 
1924    print  $0 
2025  }
2126
27+   # [START] multiline default statement started 
2228  if  (blockCnt >  0 ) {
23-     if  ($1  ==  " description " 
29+     if  ($1  ==  " default " 
2430      print  $0 
31+       if  ($NF  ~  /[\[ \(\{ ] /) {
32+         blockDefCnt++ 
33+         blockDefStart= 1 
34+       }
2535    }
2636  }
2737
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 
3444      }
45+       print  $0 
3546    }
3647  }
3748
49+   # [PRINT] single line "type" 
3850  if  (blockCnt >  0 ) {
3951    if  ($1  ==  " type" 
52+       # [CLOSE] "default" block 
53+       if  (blockDefCnt >  0 ) {
54+         blockDefCnt =  0 
55+       }
4056      type= $3 
4157      if  (type ~  " object" 
4258        print  "   type = \" object\" " 
4662    }
4763  }
4864
65+   # [CLOSE] variable/output block 
4966  if  (blockCnt >  0 ) {
5067    if  (braceCnt ==  0  &&  blockCnt >  0 ) {
5168      blockCnt-- 
5269      print  $0 
5370    }
5471  }
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+   }
5581}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments