in config/converge.go [39:97]
func Converge(shards map[string]*configpb.Configuration) (*configpb.Configuration, error) {
if len(shards) == 0 {
return nil, fmt.Errorf("No configurations to converge")
}
result := configpb.Configuration{}
// Go through shards in key string order, so the prefix results are predictable and alphabetical.
var keys []string
for key := range shards {
keys = append(keys, key)
}
sort.Strings(keys)
// Dashboards and Dashboard Groups can't share names with each other
DashboardsAndGroups := make(map[string]void)
TestGroups := make(map[string]void)
for _, key := range keys {
cfg := shards[key]
NewDashboardsAndGroups := make(map[string]void)
NewTestGroups := make(map[string]void)
for _, testgroup := range cfg.TestGroups {
NewTestGroups[testgroup.Name] = insert
}
for _, dashboard := range cfg.Dashboards {
NewDashboardsAndGroups[dashboard.Name] = insert
}
for _, dashboardGroup := range cfg.DashboardGroups {
NewDashboardsAndGroups[dashboardGroup.Name] = insert
}
dashboardRenames := negotiateConversions(key, DashboardsAndGroups, NewDashboardsAndGroups)
testGroupRenames := negotiateConversions(key, TestGroups, NewTestGroups)
for olddash, newdash := range dashboardRenames {
RenameDashboardOrGroup(olddash, newdash, cfg)
}
for oldtest, newtest := range testGroupRenames {
RenameTestGroup(oldtest, newtest, cfg)
}
// Merge protos and cached sets
proto.Merge(&result, cfg)
for _, dash := range cfg.Dashboards {
DashboardsAndGroups[dash.Name] = insert
}
for _, group := range cfg.DashboardGroups {
DashboardsAndGroups[group.Name] = insert
}
for _, test := range cfg.TestGroups {
TestGroups[test.Name] = insert
}
}
return &result, nil
}