File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
1010 "log"
1111 "os"
1212 "path/filepath"
13+ "reflect"
14+ "sort"
1315 "strings"
1416 "syscall"
1517 "text/template"
@@ -90,6 +92,11 @@ func marshalJson(input interface{}) (string,error) {
9092 return strings .TrimSuffix (buf .String (), "\n " ), nil
9193}
9294
95+ func arrayLast (input interface {}) interface {} {
96+ arr := reflect .ValueOf (input )
97+ return arr .Index (arr .Len () - 1 ).Interface ()
98+ }
99+
93100func generateFile (config Config , containers Context ) bool {
94101 templatePath := config .Template
95102 tmpl , err := template .New (filepath .Base (templatePath )).Funcs (template.FuncMap {
@@ -102,6 +109,7 @@ func generateFile(config Config, containers Context) bool {
102109 "dict" : dict ,
103110 "sha1" : hashSha1 ,
104111 "json" : marshalJson ,
112+ "last" : arrayLast ,
105113 }).ParseFiles (templatePath )
106114 if err != nil {
107115 log .Fatalf ("unable to parse template: %s" , err )
You can’t perform that action at this time.
0 commit comments