Use teams array to generate Github Team list
This commit is contained in:
parent
aaab6d7ff7
commit
7f9a5c5376
|
@ -46,8 +46,6 @@ const (
|
|||
var (
|
||||
baseGeneratorDir = ""
|
||||
templateDir = "generator"
|
||||
|
||||
githubTeamNames = []string{"misc", "test-failures", "bugs", "feature-requests", "proposals", "pr-reviews", "api-reviews"}
|
||||
)
|
||||
|
||||
// Lead represents a lead engineer for a particular group. There are usually
|
||||
|
@ -68,11 +66,15 @@ type Meeting struct {
|
|||
|
||||
// Contact represents the various contact points for a group.
|
||||
type Contact struct {
|
||||
Slack string
|
||||
MailingList string `yaml:"mailing_list"`
|
||||
FullGitHubTeams bool `yaml:"full_github_teams"`
|
||||
GithubTeamPrefix string `yaml:"github_team_prefix"`
|
||||
GithubTeamNames []string
|
||||
Slack string
|
||||
MailingList string `yaml:"mailing_list"`
|
||||
GithubTeams []GithubTeams `yaml:"teams"`
|
||||
}
|
||||
|
||||
// GithubTeams represents a specific Github Team.
|
||||
type GithubTeams struct {
|
||||
Name string
|
||||
Description string
|
||||
}
|
||||
|
||||
// Group represents either a Special Interest Group (SIG) or a Working Group (WG)
|
||||
|
@ -96,20 +98,6 @@ func (e *Group) DirName(prefix string) string {
|
|||
return fmt.Sprintf("%s-%s", prefix, strings.ToLower(strings.Replace(e.Name, " ", "-", -1)))
|
||||
}
|
||||
|
||||
// SetupGitHubTeams will iterate over all the possible teams available to a
|
||||
// group (these are defined by the Kubernetes organization) and populate a
|
||||
// list using the group's prefix.
|
||||
func (e *Group) SetupGitHubTeams(prefix string) {
|
||||
ghPrefix := e.Contact.GithubTeamPrefix
|
||||
if ghPrefix == "" {
|
||||
ghPrefix = e.DirName(prefix)
|
||||
}
|
||||
|
||||
for _, gtn := range githubTeamNames {
|
||||
e.Contact.GithubTeamNames = append(e.Contact.GithubTeamNames, fmt.Sprintf("%s-%s", ghPrefix, gtn))
|
||||
}
|
||||
}
|
||||
|
||||
// Context is the context for the sigs.yaml file.
|
||||
type Context struct {
|
||||
Sigs []Group
|
||||
|
@ -239,8 +227,6 @@ func createGroupReadme(groups []Group, prefix string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
group.SetupGitHubTeams(prefix)
|
||||
|
||||
outputPath := filepath.Join(outputDir, indexFilename)
|
||||
readmePath := filepath.Join(baseGeneratorDir, templateDir, fmt.Sprintf("%s_%s", prefix, readmeTemplate))
|
||||
if err := writeTemplate(readmePath, outputPath, group); err != nil {
|
||||
|
|
|
@ -17,11 +17,9 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -150,34 +148,6 @@ func TestGroupDirName(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSetupGithubTeams(t *testing.T) {
|
||||
group := Group{Name: "Foo Bar"}
|
||||
group.SetupGitHubTeams("sig")
|
||||
|
||||
var expected []string
|
||||
for _, ght := range githubTeamNames {
|
||||
expected = append(expected, fmt.Sprintf("sig-foo-bar-%s", ght))
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(group.Contact.GithubTeamNames, expected) {
|
||||
t.Fatalf("%v does not match %v", group.Contact.GithubTeamNames, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCustomPrefixSetupGithubTeams(t *testing.T) {
|
||||
group := Group{Contact: Contact{GithubTeamPrefix: "foo"}}
|
||||
group.SetupGitHubTeams("")
|
||||
|
||||
var expected []string
|
||||
for _, ght := range githubTeamNames {
|
||||
expected = append(expected, fmt.Sprintf("foo-%s", ght))
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(group.Contact.GithubTeamNames, expected) {
|
||||
t.Fatalf("%v does not match %v", group.Contact.GithubTeamNames, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateGroupReadmes(t *testing.T) {
|
||||
baseGeneratorDir = "generated"
|
||||
templateDir = "../../generator"
|
||||
|
|
|
@ -25,9 +25,15 @@ Meeting recordings can be found [here]({{.MeetingRecordingsURL}}).
|
|||
{{- if .Label }}
|
||||
* [Open Community Issues/PRs](https://github.com/kubernetes/community/labels/sig%2F{{.Label}})
|
||||
{{- end }}
|
||||
{{if .Contact.FullGitHubTeams}}
|
||||
{{ if .Contact.GithubTeams }}
|
||||
## GitHub Teams
|
||||
{{range .Contact.GithubTeamNames -}}
|
||||
* [@{{.}}](https://github.com/kubernetes/teams/{{.}})
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
The below teams can be mentioned on issues and PRs in order to get attention from the right people.
|
||||
Note that the links to display team membership will only work if you are a member of the org.
|
||||
|
||||
| Team Name | Details | Description |
|
||||
| --------- |:-------:| ----------- |
|
||||
{{- range .Contact.GithubTeams }}
|
||||
| @kubernetes/{{.Name}} | [link](https://github.com/orgs/kubernetes/teams/{{.Name}}) | {{.Description}} |
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
|
|
@ -25,9 +25,15 @@ Meeting recordings can be found [here]({{.MeetingRecordingsURL}}).
|
|||
{{- if .Label }}
|
||||
* [Open Community Issues/PRs](https://github.com/kubernetes/community/labels/wg%2F{{.Label}})
|
||||
{{- end }}
|
||||
{{if .Contact.FullGitHubTeams}}
|
||||
{{ if .Contact.GithubTeams }}
|
||||
## GitHub Teams
|
||||
{{range .Contact.GithubTeamNames -}}
|
||||
* [@{{.}}](https://github.com/kubernetes/teams/{{.}})
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
The below teams can be mentioned on issues and PRs in order to get attention from the right people.
|
||||
Note that the links to display team membership will only work if you are a member of the org.
|
||||
|
||||
| Team Name | Details | Description |
|
||||
| --------- |:-------:| ----------- |
|
||||
{{- range .Contact.GithubTeams }}
|
||||
| @kubernetes/{{.Name}} | [link](https://github.com/orgs/kubernetes/teams/{{.Name}}) | {{.Description}} |
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue