summaryrefslogtreecommitdiff
path: root/generator/app.go
diff options
context:
space:
mode:
authorAaron Crickenberger <spiffxp@google.com>2019-05-06 11:45:30 -0700
committerAaron Crickenberger <spiffxp@google.com>2019-05-06 11:45:46 -0700
commite63cbfae86b679590272733fdc2ce80412525c7a (patch)
treead0a3e849b95008cebad4ca55441f154c9f0c29b /generator/app.go
parent08281a417f3b964aa63755f4353ec204c94bcef9 (diff)
Validate same github id has same name/compay
Diffstat (limited to 'generator/app.go')
-rw-r--r--generator/app.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/generator/app.go b/generator/app.go
index e6e302e9..371add2a 100644
--- a/generator/app.go
+++ b/generator/app.go
@@ -113,6 +113,15 @@ type LeadershipGroup struct {
EmeritusLeads []Person `yaml:"emeritus_leads,omitempty"`
}
+// PrefixToPersonMap returns a map of prefix to persons, useful for iteration over all persons
+func (g *LeadershipGroup) PrefixToPersonMap() map[string][]Person {
+ return map[string][]Person{
+ "chair": g.Chairs,
+ "tech_lead": g.TechnicalLeads,
+ "emeritus_lead": g.EmeritusLeads,
+ }
+}
+
// Group represents either a Special Interest Group (SIG) or a Working Group (WG)
type Group struct {
Dir string
@@ -210,6 +219,7 @@ func (c *Context) Sort() {
// Validate returns a list of errors encountered while validating a Context
func (c *Context) Validate() []error {
errors := []error{}
+ people := make(map[string]Person)
for prefix, groups := range c.PrefixToGroupMap() {
for _, group := range groups {
expectedDir := group.DirName(prefix)
@@ -220,6 +230,17 @@ func (c *Context) Validate() []error {
if expectedLabel != group.Label {
errors = append(errors, fmt.Errorf("%s: expected label: %s, got: %s", group.Dir, expectedLabel, group.Label))
}
+ for prefix, persons := range group.Leadership.PrefixToPersonMap() {
+ for _, person := range persons {
+ if val, ok := people[person.GitHub]; ok {
+ if val.Name != person.Name || val.Company != person.Company {
+ errors = append(errors, fmt.Errorf("%s: %ss: expected person: %v, got: %v", group.Dir, prefix, val, person))
+ }
+ } else {
+ people[person.GitHub] = person
+ }
+ }
+ }
if len(group.StakeholderSIGs) != 0 {
if prefix == "wg" {
for _, name := range group.StakeholderSIGs {
@@ -243,7 +264,6 @@ func (c *Context) Validate() []error {
errors = append(errors, fmt.Errorf("%s: has no subprojects", group.Dir))
}
}
-
}
}
return errors