Change jsonVariationMap to array of struct

This more structured data is easier to query

Test: m json-module-graph & look at the graph
Change-Id: I44ba6a8df12208705f37ee6908ad5391a6f404a1
This commit is contained in:
Liz Kammer 2022-04-07 16:28:32 -04:00
parent 0d2386c60a
commit 8097d1a0e6

View file

@ -2268,7 +2268,7 @@ func (c *Context) updateDependencies() (errs []error) {
return
}
type jsonVariationMap map[string]string
type jsonVariationMap []Variation
type jsonModuleName struct {
Name string
@ -2290,7 +2290,17 @@ type JsonModule struct {
}
func toJsonVariationMap(vm variationMap) jsonVariationMap {
return jsonVariationMap(vm)
m := make(jsonVariationMap, 0, len(vm))
for k, v := range vm {
m = append(m, Variation{k, v})
}
sort.Slice(m, func(i, j int) bool {
if m[i].Mutator != m[j].Mutator {
return m[i].Mutator < m[j].Mutator
}
return m[i].Variation < m[j].Variation
})
return m
}
func jsonModuleNameFromModuleInfo(m *moduleInfo) *jsonModuleName {