| 303 | } |
| 304 | |
| 305 | func (r rewriteHandler) write(file *os.File, configs []ExportedConfig, confMap map[string]interface{}) error { |
| 306 | if confMap == nil { |
| 307 | confMap = make(map[string]interface{}) |
| 308 | } |
| 309 | for _, exportedConfig := range configs { |
| 310 | for k := range exportedConfig.Data { |
| 311 | if _, ok := confMap[k]; ok { |
| 312 | continue |
| 313 | } |
| 314 | confMap[k] = exportedConfig.Data[k] |
| 315 | } |
| 316 | } |
| 317 | file.Seek(0, 0) |
| 318 | data, err := r.codec.Marshal(confMap) |
| 319 | if err != nil { |
| 320 | return err |
| 321 | } |
| 322 | if _, err := file.Write(data); err != nil { |
| 323 | return err |
| 324 | } |
| 325 | fmt.Fprintln(file) |
| 326 | return err |
| 327 | } |