@@ -13,7 +13,6 @@ import (
13
13
"os"
14
14
"path"
15
15
"path/filepath"
16
- "reflect"
17
16
"strconv"
18
17
"text/template"
19
18
)
@@ -29,10 +28,11 @@ type TemplateVariable struct {
29
28
}
30
29
31
30
type NercConf struct {
32
- Input string `yaml:"input"`
33
- Templates string `yaml:"templates"`
34
- Output string `yaml:"output"`
35
- Variables map [string ]interface {} `yaml:"variables"`
31
+ Input string `yaml:"input"`
32
+ Templates string `yaml:"templates"`
33
+ Output string `yaml:"output"`
34
+ StaticVariables map [string ]interface {} `yaml:"staticVariables"`
35
+ CSVMapping map [string ]int `yaml:"csvMapping"`
36
36
}
37
37
38
38
func main () {
@@ -144,12 +144,11 @@ func csvToConfigs(r *csv.Reader, nercConf NercConf) {
144
144
145
145
func writeConf (row []string , template string , i int , nercConf NercConf ) {
146
146
templateVars := make (map [string ]interface {})
147
- for k , v := range nercConf .Variables {
148
- if reflect .TypeOf (v ).Kind () == reflect .Int {
149
- templateVars [k ] = row [v .(int )]
150
- } else {
151
- templateVars [k ] = v
152
- }
147
+ for k , v := range nercConf .StaticVariables {
148
+ templateVars [k ] = v
149
+ }
150
+ for k , v := range nercConf .CSVMapping {
151
+ templateVars [k ] = row [v ]
153
152
}
154
153
conf := ProcessFile (template , templateVars )
155
154
outputFile := "sku_" + row [0 ] + "_version_" + strconv .Itoa (i ) + ".json"
0 commit comments