@@ -163,6 +163,7 @@ type Group struct {
163
163
Name string
164
164
MissionStatement FoldedString `yaml:"mission_statement,omitempty"`
165
165
CharterLink string `yaml:"charter_link,omitempty"`
166
+ ReportingWGs []WGName `yaml:"-"` // populated by Context#Complete()
166
167
StakeholderSIGs []SIGName `yaml:"stakeholder_sigs,omitempty"`
167
168
Label string
168
169
Leadership LeadershipGroup `yaml:"leadership"`
@@ -171,6 +172,12 @@ type Group struct {
171
172
Subprojects []Subproject `yaml:",omitempty"`
172
173
}
173
174
175
+ type WGName string
176
+
177
+ func (n WGName ) DirName () string {
178
+ return DirName ("wg" , string (n ))
179
+ }
180
+
174
181
type SIGName string
175
182
176
183
func (n SIGName ) DirName () string {
@@ -220,13 +227,30 @@ func (c *Context) PrefixToGroupMap() map[string][]Group {
220
227
}
221
228
}
222
229
230
+ // Complete populates derived portions of the Context struct
231
+ func (c * Context ) Complete () {
232
+ // Copy working group names into ReportingWGs list of their stakeholder sigs
233
+ for _ , wg := range c .WorkingGroups {
234
+ for _ , stakeholderSIG := range wg .StakeholderSIGs {
235
+ for i , sig := range c .Sigs {
236
+ if sig .Name == string (stakeholderSIG ) {
237
+ c .Sigs [i ].ReportingWGs = append (c .Sigs [i ].ReportingWGs , WGName (wg .Name ))
238
+ }
239
+ }
240
+ }
241
+ }
242
+ }
243
+
223
244
// Sort sorts all lists within the Context struct
224
245
func (c * Context ) Sort () {
225
246
for _ , groups := range c .PrefixToGroupMap () {
226
247
sort .Slice (groups , func (i , j int ) bool {
227
248
return groups [i ].Dir < groups [j ].Dir
228
249
})
229
250
for _ , group := range groups {
251
+ sort .Slice (group .ReportingWGs , func (i , j int ) bool {
252
+ return group .ReportingWGs [i ] < group .ReportingWGs [j ]
253
+ })
230
254
sort .Slice (group .StakeholderSIGs , func (i , j int ) bool {
231
255
return group .StakeholderSIGs [i ] < group .StakeholderSIGs [j ]
232
256
})
@@ -294,6 +318,17 @@ func (c *Context) Validate() []error {
294
318
}
295
319
}
296
320
}
321
+ if len (group .ReportingWGs ) != 0 {
322
+ if prefix == "sig" {
323
+ for _ , name := range group .ReportingWGs {
324
+ if index (c .WorkingGroups , func (g Group ) bool { return g .Name == string (name ) }) == - 1 {
325
+ errors = append (errors , fmt .Errorf ("%s: invalid reporting working group name %s" , group .Dir , name ))
326
+ }
327
+ }
328
+ } else {
329
+ errors = append (errors , fmt .Errorf ("%s: only SIGs may have reporting WGs" , group .Dir ))
330
+ }
331
+ }
297
332
if len (group .StakeholderSIGs ) != 0 {
298
333
if prefix == "wg" {
299
334
for _ , name := range group .StakeholderSIGs {
@@ -304,6 +339,10 @@ func (c *Context) Validate() []error {
304
339
} else {
305
340
errors = append (errors , fmt .Errorf ("%s: only WGs may have stakeholder_sigs" , group .Dir ))
306
341
}
342
+ } else {
343
+ if prefix == "wg" {
344
+ errors = append (errors , fmt .Errorf ("%s: WGs must have stakeholder_sigs" , group .Dir ))
345
+ }
307
346
}
308
347
if prefix == "sig" {
309
348
if group .CharterLink == "" {
@@ -655,6 +694,8 @@ func main() {
655
694
log .Fatal (err )
656
695
}
657
696
697
+ ctx .Complete ()
698
+
658
699
ctx .Sort ()
659
700
660
701
fmt .Printf ("Validating %s\n " , yamlPath )
0 commit comments