Skip to content

Commit 680390f

Browse files
committed
validate emails / company and add a TODO about awkward data format with de-normalized person entries
1 parent 1eefeb5 commit 680390f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

generator/app.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ func (c *Context) Sort() {
438438
// Validate returns a list of errors encountered while validating a Context
439439
func (c *Context) Validate() []error {
440440
errors := []error{}
441+
// github to Person info
442+
// TODO: this would probably be a better config format? to avoid duplicating
443+
// people with potentially differing info, versus referring to leads by
444+
// github handle within each SIG and then keeping this map alongside the SIGs
445+
// This could break external tooling parsing the file though.
441446
people := make(map[string]Person)
442447
reRawGitHubURL := regexp.MustCompile(regexRawGitHubURL)
443448
reGitHubURL := regexp.MustCompile(regexGitHubURL)
@@ -454,8 +459,24 @@ func (c *Context) Validate() []error {
454459
for prefix, persons := range group.Leadership.PrefixToPersonMap() {
455460
for _, person := range persons {
456461
if val, ok := people[person.GitHub]; ok {
457-
if val.Name != person.Name || (prefix != "emeritus_lead" && val.Company != person.Company) {
458-
errors = append(errors, fmt.Errorf("%s: %ss: expected person: %v, got: %v", group.Dir, prefix, val, person))
462+
// non-emeritus must have email and company set
463+
if prefix != "emeritus_lead" {
464+
// email must be set and consistent
465+
if val.Email == "" {
466+
errors = append(errors, fmt.Errorf("%s: %s: email is empty but should be set", group.Dir, val.GitHub))
467+
} else if val.Email != person.Email {
468+
errors = append(errors, fmt.Errorf("%s: %s email: %q does not match other entries %q", group.Dir, val.GitHub, val.Email, person.Email))
469+
}
470+
// company must be set and consistent
471+
if val.Company == "" {
472+
errors = append(errors, fmt.Errorf("%s: %s: company is empty but should be set", group.Dir, val.Company))
473+
} else if val.Company != person.Company {
474+
errors = append(errors, fmt.Errorf("%s: %s company: %q does not match other entries %q", group.Dir, val.GitHub, val.Company, person.Company))
475+
}
476+
}
477+
// all entries should have github + name, emeritus or not
478+
if val.Name != person.Name {
479+
errors = append(errors, fmt.Errorf("%s: %s: expected person: %v, got: %v", group.Dir, prefix, val, person))
459480
}
460481
} else if prefix != "emeritus_lead" {
461482
people[person.GitHub] = person

0 commit comments

Comments
 (0)