summaryrefslogtreecommitdiff
path: root/generator
diff options
context:
space:
mode:
authorKubernetes Prow Robot <k8s-ci-robot@users.noreply.github.com>2022-02-07 22:44:54 -0800
committerGitHub <noreply@github.com>2022-02-07 22:44:54 -0800
commit9fb7dda78a0cffac8051e98caca6e75f9893ff11 (patch)
tree912a80b4f0d87a60f706513266151e9f32e13a60 /generator
parentae6a672d2c3ec6465183e1108f92df80ade17c3d (diff)
parent099a72262139f0f1ef1df2aacc56cb6585f8066f (diff)
Merge pull request #6405 from liggitt/wg-in-sig-readme
Cross-link SIG and WG readmes
Diffstat (limited to 'generator')
-rw-r--r--generator/app.go61
-rw-r--r--generator/sig_readme.tmpl12
-rw-r--r--generator/wg_readme.tmpl2
3 files changed, 70 insertions, 5 deletions
diff --git a/generator/app.go b/generator/app.go
index bae4903e..901a6d28 100644
--- a/generator/app.go
+++ b/generator/app.go
@@ -163,7 +163,8 @@ type Group struct {
Name string
MissionStatement FoldedString `yaml:"mission_statement,omitempty"`
CharterLink string `yaml:"charter_link,omitempty"`
- StakeholderSIGs []string `yaml:"stakeholder_sigs,omitempty"`
+ ReportingWGs []WGName `yaml:"-"` // populated by Context#Complete()
+ StakeholderSIGs []SIGName `yaml:"stakeholder_sigs,omitempty"`
Label string
Leadership LeadershipGroup `yaml:"leadership"`
Meetings []Meeting
@@ -171,11 +172,27 @@ 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 {
+ return DirName("sig", string(n))
+}
+
// DirName returns the directory that a group's documentation will be
// generated into. It is composed of a prefix (sig for SIGs and wg for WGs),
// and a formatted version of the group's name (in kebab case).
func (g *Group) DirName(prefix string) string {
- return fmt.Sprintf("%s-%s", prefix, strings.ToLower(strings.Replace(g.Name, " ", "-", -1)))
+ return DirName(prefix, g.Name)
+}
+
+func DirName(prefix, name string) string {
+ return fmt.Sprintf("%s-%s", prefix, strings.ToLower(strings.Replace(name, " ", "-", -1)))
}
// LabelName returns the expected label for a given group
@@ -210,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() {
@@ -217,7 +248,12 @@ func (c *Context) Sort() {
return groups[i].Dir < groups[j].Dir
})
for _, group := range groups {
- sort.Strings(group.StakeholderSIGs)
+ 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]
+ })
for _, people := range [][]Person{
group.Leadership.Chairs,
group.Leadership.TechnicalLeads,
@@ -282,16 +318,31 @@ 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 {
- if index(c.Sigs, func(g Group) bool { return g.Name == name }) == -1 {
+ if index(c.Sigs, func(g Group) bool { return g.Name == string(name) }) == -1 {
errors = append(errors, fmt.Errorf("%s: invalid stakeholder sig name %s", group.Dir, name))
}
}
} 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 == "" {
@@ -643,6 +694,8 @@ func main() {
log.Fatal(err)
}
+ ctx.Complete()
+
ctx.Sort()
fmt.Printf("Validating %s\n", yamlPath)
diff --git a/generator/sig_readme.tmpl b/generator/sig_readme.tmpl
index 4bb61997..2d7d123b 100644
--- a/generator/sig_readme.tmpl
+++ b/generator/sig_readme.tmpl
@@ -68,6 +68,17 @@ subprojects, and resolve cross-subproject technical issues and decisions.
- Steering Committee Liaison: {{.Contact.Liaison.Name}} (**[@{{.Contact.Liaison.GitHub}}](https://github.com/{{.Contact.Liaison.GitHub}})**)
{{- end }}
+{{- if .ReportingWGs }}
+
+## Working Groups
+
+The following [working groups][working-group-definition] are sponsored by sig-{{.Label}}:
+
+{{- range .ReportingWGs }}
+* [WG {{.}}](/{{.DirName}})
+{{- end }}
+{{ end }}
+
{{- if .Subprojects }}
## Subprojects
@@ -114,3 +125,4 @@ The following [subprojects][subproject-definition] are owned by sig-{{.Label}}:
{{- end }}
[subproject-definition]: https://github.com/kubernetes/community/blob/master/governance.md#subprojects
+[working-group-definition]: https://github.com/kubernetes/community/blob/master/governance.md#working-groups
diff --git a/generator/wg_readme.tmpl b/generator/wg_readme.tmpl
index ea1a9e0e..e366f889 100644
--- a/generator/wg_readme.tmpl
+++ b/generator/wg_readme.tmpl
@@ -8,7 +8,7 @@ The [charter]({{.CharterLink}}) defines the scope and governance of the {{.Name}
{{- if .StakeholderSIGs }}
## Stakeholder SIGs
{{- range .StakeholderSIGs }}
-* SIG {{.}}
+* [SIG {{.}}](/{{.DirName}})
{{- end }}
{{ end }}
{{ if .Meetings -}}