diff options
| author | Jordan Liggitt <liggitt@google.com> | 2022-01-27 15:57:17 -0500 |
|---|---|---|
| committer | Jordan Liggitt <liggitt@google.com> | 2022-01-27 15:58:10 -0500 |
| commit | 77521a2706f11fe2199eaa28f79068b9b1f53f09 (patch) | |
| tree | ef3835a7971017fecb1312dd7e4fd201ea699adf /generator/app.go | |
| parent | f1bee9603aaee0b1438c76cc98b86f7529856132 (diff) | |
Link to working groups from SIG readmes
Diffstat (limited to 'generator/app.go')
| -rw-r--r-- | generator/app.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/generator/app.go b/generator/app.go index 04f37fa3..901a6d28 100644 --- a/generator/app.go +++ b/generator/app.go @@ -163,6 +163,7 @@ type Group struct { Name string MissionStatement FoldedString `yaml:"mission_statement,omitempty"` CharterLink string `yaml:"charter_link,omitempty"` + ReportingWGs []WGName `yaml:"-"` // populated by Context#Complete() StakeholderSIGs []SIGName `yaml:"stakeholder_sigs,omitempty"` Label string Leadership LeadershipGroup `yaml:"leadership"` @@ -171,6 +172,12 @@ type Group struct { Subprojects []Subproject `yaml:",omitempty"` } +type WGName string + +func (n WGName) DirName() string { + return DirName("wg", string(n)) +} + type SIGName string func (n SIGName) DirName() string { @@ -220,6 +227,20 @@ func (c *Context) PrefixToGroupMap() map[string][]Group { } } +// Complete populates derived portions of the Context struct +func (c *Context) Complete() { + // Copy working group names into ReportingWGs list of their stakeholder sigs + for _, wg := range c.WorkingGroups { + for _, stakeholderSIG := range wg.StakeholderSIGs { + for i, sig := range c.Sigs { + if sig.Name == string(stakeholderSIG) { + c.Sigs[i].ReportingWGs = append(c.Sigs[i].ReportingWGs, WGName(wg.Name)) + } + } + } + } +} + // Sort sorts all lists within the Context struct func (c *Context) Sort() { for _, groups := range c.PrefixToGroupMap() { @@ -227,6 +248,9 @@ func (c *Context) Sort() { return groups[i].Dir < groups[j].Dir }) for _, group := range groups { + sort.Slice(group.ReportingWGs, func(i, j int) bool { + return group.ReportingWGs[i] < group.ReportingWGs[j] + }) sort.Slice(group.StakeholderSIGs, func(i, j int) bool { return group.StakeholderSIGs[i] < group.StakeholderSIGs[j] }) @@ -294,6 +318,17 @@ func (c *Context) Validate() []error { } } } + if len(group.ReportingWGs) != 0 { + if prefix == "sig" { + for _, name := range group.ReportingWGs { + if index(c.WorkingGroups, func(g Group) bool { return g.Name == string(name) }) == -1 { + errors = append(errors, fmt.Errorf("%s: invalid reporting working group name %s", group.Dir, name)) + } + } + } else { + errors = append(errors, fmt.Errorf("%s: only SIGs may have reporting WGs", group.Dir)) + } + } if len(group.StakeholderSIGs) != 0 { if prefix == "wg" { for _, name := range group.StakeholderSIGs { @@ -304,6 +339,10 @@ func (c *Context) Validate() []error { } else { errors = append(errors, fmt.Errorf("%s: only WGs may have stakeholder_sigs", group.Dir)) } + } else { + if prefix == "wg" { + errors = append(errors, fmt.Errorf("%s: WGs must have stakeholder_sigs", group.Dir)) + } } if prefix == "sig" { if group.CharterLink == "" { @@ -655,6 +694,8 @@ func main() { log.Fatal(err) } + ctx.Complete() + ctx.Sort() fmt.Printf("Validating %s\n", yamlPath) |
