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 (
10
10
"log"
11
11
"os"
12
12
"path/filepath"
13
+ "reflect"
14
+ "sort"
13
15
"strings"
14
16
"syscall"
15
17
"text/template"
@@ -90,6 +92,11 @@ func marshalJson(input interface{}) (string,error) {
90
92
return strings .TrimSuffix (buf .String (), "\n " ), nil
91
93
}
92
94
95
+ func arrayLast (input interface {}) interface {} {
96
+ arr := reflect .ValueOf (input )
97
+ return arr .Index (arr .Len () - 1 ).Interface ()
98
+ }
99
+
93
100
func generateFile (config Config , containers Context ) bool {
94
101
templatePath := config .Template
95
102
tmpl , err := template .New (filepath .Base (templatePath )).Funcs (template.FuncMap {
@@ -102,6 +109,7 @@ func generateFile(config Config, containers Context) bool {
102
109
"dict" : dict ,
103
110
"sha1" : hashSha1 ,
104
111
"json" : marshalJson ,
112
+ "last" : arrayLast ,
105
113
}).ParseFiles (templatePath )
106
114
if err != nil {
107
115
log .Fatalf ("unable to parse template: %s" , err )
You can’t perform that action at this time.
0 commit comments