3
0
Files
corteza/pkg/settings/exporter.go
Tomaž Jerman 298ce908c2 Improve setting export/import structure
Properly encode/decode json structures.
2019-10-16 12:47:37 +02:00

25 lines
383 B
Go

package settings
import (
"encoding/json"
"gopkg.in/yaml.v2"
)
// Export transforms a given ValueSet into a yaml exportable structure
func Export(ss ValueSet) (o yaml.MapSlice) {
o = yaml.MapSlice{}
for _, s := range ss {
var v interface{}
json.Unmarshal(s.Value, &v)
setting := yaml.MapItem{
Key: s.Name,
Value: v,
}
o = append(o, setting)
}
return o
}