Automate creation of OWNERS_ALIASES (#532)

* Autogen OWNERS_ALIASES

* Add autogen header
This commit is contained in:
Evan Anderson 2021-03-18 23:09:54 -07:00 committed by GitHub
parent a228f32193
commit a286a96be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 2198 additions and 16 deletions

View File

@ -1,15 +1,148 @@
# This file is auto-generated from peribolos
aliases:
api-core-wg-leads:
- dprotaso
autoscaling-wg-leads:
- markusthoemmes
- vagababov
channel-wg-leads:
- matzew
- slinkydeveloper
client-wg-leads:
- navidshaikh
- rhuss
client-writers:
- navidshaikh
- rhuss
conformance-wg-leads:
- tayarani
conformance-writers:
- tayarani
docs-wg-leads: []
docs-writers: []
eventing-triage:
- akashrv
- antoineco
- lberk
- n3wscott
- slinkydeveloper
- zhongduo
eventing-wg-leads:
- devguyio
- grantr
- lionelvillard
- vaikas
eventing-writers:
- akashrv
- antoineco
- devguyio
- grantr
- lberk
- lionelvillard
- matzew
- n3wscott
- slinkydeveloper
- vaikas
- zhongduo
knative-admin:
- RichieEscarez
- bsnchan
- duglin
- evankanderson
- grantr
- knative-prow-releaser-robot
- knative-prow-robot
- knative-test-reporter-robot
- markusthoemmes
- mbehrendt
- pmorie
- rhuss
- ronavn
- thisisnotapril
- vaikas
knative-milestone-maintainers:
- ImJasonH
- ZhiminXiang
- andrew-su
- aslom
- chaodaiG
- chizhg
- csantanapr
- evankanderson
- grantr
- igsong
- julz
- lionelvillard
- markusthoemmes
- n3wscott
- nak3
- navidshaikh
- nlopezgi
- rhuss
- shashwathi
- slinkydeveloper
- tanzeeb
- tcnghia
- vagababov
- vaikas
knative-release-leads:
- RichieEscarez
- evankanderson
- markusthoemmes
knative-robots:
- knative-prow-releaser-robot
- knative-prow-robot
- knative-test-reporter-robot
networking-wg-leads:
- ZhiminXiang
- nak3
- tcnghia
operations-wg-leads:
- houshengbo
operations-writers:
- houshengbo
productivity-wg-leads:
- chizhg
- n3wscott
productivity-writers:
- chizhg
- n3wscott
security-wg-leads:
- evankanderson
- julz
security-writers:
- evankanderson
- julz
serving-writers:
- ZhiminXiang
- dprotaso
- markusthoemmes
- nak3
- tcnghia
- vagababov
source-wg-leads:
- lionelvillard
- n3wscott
- vaikas
steering-committee:
- bsnchan
- mbehrendt
- pmorie
- thisisnotapril
- vaikas
docs-team:
- samodell
- richieescarez
- bsnchan
- mbehrendt
- pmorie
- thisisnotapril
- vaikas
technical-oversight-committee:
- evankanderson
- grantr
- markusthoemmes
- rhuss
- evankanderson
- grantr
- markusthoemmes
- rhuss
trademark-committee:
- bsnchan
- duglin
- ronavn
ux-wg-leads:
- csantanapr
- omerbensaadon
ux-writers:
- csantanapr
- omerbensaadon

View File

@ -1,6 +1,6 @@
# The OWNERS file is used by prow to automatically merge approved PRs.
approvers:
- docs-team
- docs-writers
reviewers:
- docs-team
- docs-writers

32
hack/update-codegen.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
# We put this in a function just in case it's usable elsewhere
function make_aliases() {
# We don't have a top-level `go.mod` because each tool should be small and
# self-contained and we don't release them.
( cd mechanics/tools/gen-aliases; go build . )
# Auto-generate OWNERS_ALIASES from peribolos configs
./mechanics/tools/gen-aliases/gen-aliases
# Clean up the tool so we don't try to check it in.
rm ./mechanics/tools/gen-aliases/gen-aliases
}
make_aliases

View File

@ -0,0 +1,10 @@
module knative.dev/community/mechanics/tools/gen-aliases
go 1.15
require (
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
k8s.io/apimachinery v0.20.2
k8s.io/test-infra v0.0.0-20210311190418-499ccc0c6a48
sigs.k8s.io/yaml v1.2.0
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
package main
import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"k8s.io/apimachinery/pkg/util/sets"
peribolos "k8s.io/test-infra/prow/config/org"
"sigs.k8s.io/yaml"
)
func main() {
if len(os.Args) < 2 {
os.Args = append(os.Args, "knative")
}
org := os.Args[1]
if len(os.Args) < 3 {
os.Args = append(os.Args, filepath.Join("peribolos", os.Args[1]+".yaml"))
}
if len(os.Args) < 4 {
os.Args = append(os.Args, "OWNERS_ALIASES")
}
infile, outfile := os.Args[2], os.Args[3]
f, err := ioutil.ReadFile(infile)
if err != nil {
log.Print("Unable to open ", err)
os.Exit(1)
}
var cfg peribolos.FullConfig
if err := yaml.Unmarshal(f, &cfg); err != nil {
log.Printf("Unable to parse ", err)
os.Exit(1)
}
out := AliasConfig{
Aliases: map[string][]string{},
}
dashes := func(r rune) rune {
if r >= 'a' && r <= 'z' {
return r
}
return '-'
}
for _, team := range expandTeams(cfg.Orgs[org].Teams) {
name := strings.Map(dashes, strings.ToLower(team.Name))
out.Aliases[name] = team.Members.List()
}
output, err := yaml.Marshal(out)
if err != nil {
log.Printf("Could not serialize: ", err)
os.Exit(1)
}
preamble := []byte("# This file is auto-generated from peribolos\n\n")
output = append(preamble, output...)
ioutil.WriteFile(outfile, output, 0644)
log.Print("Wrote ", outfile)
}
func expandTeams(seed map[string]peribolos.Team) []expandedTeam {
var retval []expandedTeam
for name, team := range seed {
children := expandTeams(team.Children)
this := expandedTeam{
Name: name,
Members: sets.NewString(team.Members...),
}
this.Members.Insert(team.Maintainers...)
for _, child := range children {
this.Members = this.Members.Union(child.Members)
}
retval = append(retval, this)
retval = append(retval, children...)
}
return retval
}
type AliasConfig struct {
Aliases map[string][]string `json:"aliases"`
}
type expandedTeam struct {
Name string
Members sets.String
}

View File

@ -1,3 +1,2 @@
approvers:
- evankanderson
- julz
- security-writers