in config/config.go [164:211]
func validateReferencesExist(c *configpb.Configuration) error {
var mErr error
if c == nil {
return multierror.Append(mErr, errors.New("got an empty config.Configuration"))
}
tgNames := map[string]bool{}
for _, tg := range c.GetTestGroups() {
tgNames[tg.GetName()] = true
}
tgInTabs := map[string]bool{}
for _, dash := range c.GetDashboards() {
for _, tab := range dash.DashboardTab {
tabTg := tab.TestGroupName
tgInTabs[tabTg] = true
// Verify that each Test Group referenced by a Dashboard Tab exists.
if _, ok := tgNames[tabTg]; !ok {
mErr = multierror.Append(mErr, MissingEntityError{tabTg, "TestGroup"})
}
}
}
// Likewise, each Test Group must be referenced by a Dashboard Tab, so each Test Group gets displayed.
for tgName := range tgNames {
if _, ok := tgInTabs[tgName]; !ok {
mErr = multierror.Append(mErr, ValidationError{tgName, "TestGroup", "Each Test Group must be referenced by at least 1 Dashboard Tab."})
}
}
dashNames := map[string]bool{}
for _, dash := range c.GetDashboards() {
dashNames[dash.Name] = true
}
dashToDg := map[string]bool{}
for _, dg := range c.GetDashboardGroups() {
for _, name := range dg.DashboardNames {
dgDash := name
if _, ok := dashNames[dgDash]; !ok {
// The Dashboards each Dashboard Group references must exist.
mErr = multierror.Append(mErr, MissingEntityError{dgDash, "Dashboard"})
} else if _, ok = dashToDg[dgDash]; ok {
mErr = multierror.Append(mErr, ValidationError{dgDash, "Dashboard", "A Dashboard cannot be in more than 1 Dashboard Group."})
} else {
dashToDg[dgDash] = true
}
}
}
return mErr
}