-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
repoowners.go
653 lines (564 loc) · 20.8 KB
/
repoowners.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
/*
Copyright 2017 The Kubernetes 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.
*/
package repoowners
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"github.com/ghodss/yaml"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/test-infra/prow/git"
"k8s.io/test-infra/prow/github"
prowConf "k8s.io/test-infra/prow/config"
)
const (
ownersFileName = "OWNERS"
aliasesFileName = "OWNERS_ALIASES"
// Github's api uses "" (empty) string as basedir by convention but it's clearer to use "/"
baseDirConvention = ""
)
var defaultDirBlacklist = sets.NewString(".git", "_output")
type dirOptions struct {
NoParentOwners bool `json:"no_parent_owners,omitempty"`
}
// Config holds roles+usernames and labels for a directory considered as a unit of independent code
type Config struct {
Approvers []string `json:"approvers,omitempty"`
Reviewers []string `json:"reviewers,omitempty"`
RequiredReviewers []string `json:"required_reviewers,omitempty"`
Labels []string `json:"labels,omitempty"`
}
// SimpleConfig holds options and Config applied to everything under the containing directory
type SimpleConfig struct {
Options dirOptions `json:"options,omitempty"`
Config `json:",inline"`
}
// Empty checks if a SimpleConfig could be considered empty
func (s *SimpleConfig) Empty() bool {
return len(s.Approvers) == 0 && len(s.Reviewers) == 0 && len(s.RequiredReviewers) == 0 && len(s.Labels) == 0
}
// FullConfig contains Filters which apply specific Config to files matching its regexp
type FullConfig struct {
Options dirOptions `json:"options,omitempty"`
Filters map[string]Config `json:"filters,omitempty"`
}
type githubClient interface {
ListCollaborators(org, repo string) ([]github.User, error)
GetRef(org, repo, ref string) (string, error)
}
type cacheEntry struct {
sha string
aliases RepoAliases
owners *RepoOwners
}
type configGetter interface {
Config() *prowConf.Config
}
// Interface is an interface to work with OWNERS files.
type Interface interface {
LoadRepoAliases(org, repo, base string) (RepoAliases, error)
LoadRepoOwners(org, repo, base string) (RepoOwnerInterface, error)
}
// Client is an implementation of the Interface.
var _ Interface = &Client{}
// Client is the repoowners client
type Client struct {
configGetter configGetter
git *git.Client
ghc githubClient
logger *logrus.Entry
mdYAMLEnabled func(org, repo string) bool
skipCollaborators func(org, repo string) bool
lock sync.Mutex
cache map[string]cacheEntry
}
// NewClient is the constructor for Client
func NewClient(
gc *git.Client,
ghc *github.Client,
configGetter *prowConf.Agent,
mdYAMLEnabled func(org, repo string) bool,
skipCollaborators func(org, repo string) bool,
) *Client {
return &Client{
git: gc,
ghc: ghc,
logger: logrus.WithField("client", "repoowners"),
cache: make(map[string]cacheEntry),
mdYAMLEnabled: mdYAMLEnabled,
skipCollaborators: skipCollaborators,
configGetter: configGetter,
}
}
// RepoAliases defines groups of people to be used in OWNERS files
type RepoAliases map[string]sets.String
// RepoOwnerInterface is an interface to work with repoowners
type RepoOwnerInterface interface {
FindApproverOwnersForFile(path string) string
FindReviewersOwnersForFile(path string) string
FindLabelsForFile(path string) sets.String
IsNoParentOwners(path string) bool
LeafApprovers(path string) sets.String
Approvers(path string) sets.String
LeafReviewers(path string) sets.String
Reviewers(path string) sets.String
RequiredReviewers(path string) sets.String
}
// RepoOwners implements RepoOwnerInterface
var _ RepoOwnerInterface = &RepoOwners{}
// RepoOwners contains the parsed OWNERS config
type RepoOwners struct {
RepoAliases
approvers map[string]map[*regexp.Regexp]sets.String
reviewers map[string]map[*regexp.Regexp]sets.String
requiredReviewers map[string]map[*regexp.Regexp]sets.String
labels map[string]map[*regexp.Regexp]sets.String
options map[string]dirOptions
baseDir string
enableMDYAML bool
dirBlacklist sets.String
log *logrus.Entry
}
// LoadRepoAliases returns an up-to-date RepoAliases struct for the specified repo.
// If the repo does not have an aliases file then an empty alias map is returned with no error.
// Note: The returned RepoAliases should be treated as read only.
func (c *Client) LoadRepoAliases(org, repo, base string) (RepoAliases, error) {
log := c.logger.WithFields(logrus.Fields{"org": org, "repo": repo, "base": base})
cloneRef := fmt.Sprintf("%s/%s", org, repo)
fullName := fmt.Sprintf("%s:%s", cloneRef, base)
sha, err := c.ghc.GetRef(org, repo, fmt.Sprintf("heads/%s", base))
if err != nil {
return nil, fmt.Errorf("failed to get current SHA for %s: %v", fullName, err)
}
c.lock.Lock()
defer c.lock.Unlock()
entry, ok := c.cache[fullName]
if !ok || entry.sha != sha {
// entry is non-existent or stale.
gitRepo, err := c.git.Clone(cloneRef)
if err != nil {
return nil, fmt.Errorf("failed to clone %s: %v", cloneRef, err)
}
defer gitRepo.Clean()
if err := gitRepo.Checkout(base); err != nil {
return nil, err
}
entry.aliases = loadAliasesFrom(gitRepo.Dir, log)
entry.sha = sha
c.cache[fullName] = entry
}
return entry.aliases, nil
}
// LoadRepoOwners returns an up-to-date RepoOwners struct for the specified repo.
// Note: The returned *RepoOwners should be treated as read only.
func (c *Client) LoadRepoOwners(org, repo, base string) (RepoOwnerInterface, error) {
log := c.logger.WithFields(logrus.Fields{"org": org, "repo": repo, "base": base})
cloneRef := fmt.Sprintf("%s/%s", org, repo)
fullName := fmt.Sprintf("%s:%s", cloneRef, base)
mdYaml := c.mdYAMLEnabled(org, repo)
sha, err := c.ghc.GetRef(org, repo, fmt.Sprintf("heads/%s", base))
if err != nil {
return nil, fmt.Errorf("failed to get current SHA for %s: %v", fullName, err)
}
c.lock.Lock()
defer c.lock.Unlock()
entry, ok := c.cache[fullName]
if !ok || entry.sha != sha || entry.owners == nil || entry.owners.enableMDYAML != mdYaml {
gitRepo, err := c.git.Clone(cloneRef)
if err != nil {
return nil, fmt.Errorf("failed to clone %s: %v", cloneRef, err)
}
defer gitRepo.Clean()
if err := gitRepo.Checkout(base); err != nil {
return nil, err
}
if entry.aliases == nil || entry.sha != sha {
// aliases must be loaded
entry.aliases = loadAliasesFrom(gitRepo.Dir, log)
}
blacklistConfig := c.configGetter.Config().OwnersDirBlacklist
dirBlacklist := defaultDirBlacklist.Union(sets.NewString(blacklistConfig.Default...))
if bl, ok := blacklistConfig.Repos[org]; ok {
dirBlacklist.Insert(bl...)
}
if bl, ok := blacklistConfig.Repos[org+"/"+repo]; ok {
dirBlacklist.Insert(bl...)
}
entry.owners, err = loadOwnersFrom(gitRepo.Dir, mdYaml, entry.aliases, dirBlacklist, log)
if err != nil {
return nil, fmt.Errorf("failed to load RepoOwners for %s: %v", fullName, err)
}
entry.sha = sha
c.cache[fullName] = entry
}
if c.skipCollaborators(org, repo) {
log.Debugf("Skipping collaborator checks for %s/%s", org, repo)
return entry.owners, nil
}
var owners *RepoOwners
// Filter collaborators. We must filter the RepoOwners struct even if it came from the cache
// because the list of collaborators could have changed without the git SHA changing.
collaborators, err := c.ghc.ListCollaborators(org, repo)
if err != nil {
log.WithError(err).Errorf("Failed to list collaborators while loading RepoOwners. Skipping collaborator filtering.")
owners = entry.owners
} else {
owners = entry.owners.filterCollaborators(collaborators)
}
return owners, nil
}
// ExpandAlias returns members of an alias
func (a RepoAliases) ExpandAlias(alias string) sets.String {
if a == nil {
return nil
}
return a[github.NormLogin(alias)]
}
// ExpandAliases returns members of multiple aliases, duplicates are pruned
func (a RepoAliases) ExpandAliases(logins sets.String) sets.String {
if a == nil {
return logins
}
// Make logins a copy of the original set to avoid modifying the original.
logins = logins.Union(nil)
for _, login := range logins.List() {
if expanded := a.ExpandAlias(login); len(expanded) > 0 {
logins.Delete(login)
logins = logins.Union(expanded)
}
}
return logins
}
func loadAliasesFrom(baseDir string, log *logrus.Entry) RepoAliases {
path := filepath.Join(baseDir, aliasesFileName)
b, err := ioutil.ReadFile(path)
if os.IsNotExist(err) {
log.WithError(err).Infof("No alias file exists at %q. Using empty alias map.", path)
return nil
} else if err != nil {
log.WithError(err).Warnf("Failed to read alias file %q. Using empty alias map.", path)
return nil
}
config := &struct {
Data map[string][]string `json:"aliases,omitempty"`
}{}
if err := yaml.Unmarshal(b, config); err != nil {
log.WithError(err).Errorf("Failed to unmarshal aliases from %q. Using empty alias map.", path)
return nil
}
result := make(RepoAliases)
for alias, expanded := range config.Data {
result[github.NormLogin(alias)] = normLogins(expanded)
}
log.Infof("Loaded %d aliases from %q.", len(result), path)
return result
}
func loadOwnersFrom(baseDir string, mdYaml bool, aliases RepoAliases, dirBlacklist sets.String, log *logrus.Entry) (*RepoOwners, error) {
o := &RepoOwners{
RepoAliases: aliases,
baseDir: baseDir,
enableMDYAML: mdYaml,
log: log,
approvers: make(map[string]map[*regexp.Regexp]sets.String),
reviewers: make(map[string]map[*regexp.Regexp]sets.String),
requiredReviewers: make(map[string]map[*regexp.Regexp]sets.String),
labels: make(map[string]map[*regexp.Regexp]sets.String),
options: make(map[string]dirOptions),
dirBlacklist: dirBlacklist,
}
return o, filepath.Walk(o.baseDir, o.walkFunc)
}
// by default, github's api doesn't root the project directory at "/" and instead uses the empty string for the base dir
// of the project. And the built-in dir function returns "." for empty strings, so for consistency, we use this
// canonicalize to get the directories of files in a consistent format with NO "/" at the root (a/b/c/ -> a/b/c)
func canonicalize(path string) string {
if path == "." {
return baseDirConvention
}
return strings.TrimSuffix(path, "/")
}
func (o *RepoOwners) walkFunc(path string, info os.FileInfo, err error) error {
log := o.log.WithField("path", path)
if err != nil {
log.WithError(err).Error("Error while walking OWNERS files.")
return nil
}
filename := filepath.Base(path)
if info.Mode().IsDir() && o.dirBlacklist.Has(filename) {
return filepath.SkipDir
}
if !info.Mode().IsRegular() {
return nil
}
// '.md' files may contain assignees at the top of the file in a yaml header
// Note that these assignees only apply to the file itself.
if o.enableMDYAML && strings.HasSuffix(filename, ".md") {
// Parse the yaml header from the file if it exists and marshal into the config
simple := &SimpleConfig{}
if err := decodeOwnersMdConfig(path, simple); err != nil {
log.WithError(err).Error("Error decoding OWNERS config from '*.md' file.")
return nil
}
// Set owners for this file (not the directory) using the relative path if they were found
relPath, err := filepath.Rel(o.baseDir, path)
if err != nil {
log.WithError(err).Errorf("Unable to find relative path between baseDir: %q and path.", o.baseDir)
return err
}
o.applyConfigToPath(relPath, nil, &simple.Config)
o.applyOptionsToPath(relPath, simple.Options)
return nil
}
if filename != ownersFileName {
return nil
}
b, err := ioutil.ReadFile(path)
if err != nil {
log.WithError(err).Errorf("Failed to read the OWNERS file.")
return nil
}
relPath, err := filepath.Rel(o.baseDir, path)
if err != nil {
log.WithError(err).Errorf("Unable to find relative path between baseDir: %q and path.", o.baseDir)
return err
}
relPathDir := canonicalize(filepath.Dir(relPath))
simple, err := ParseSimpleConfig(b)
if err != nil || simple.Empty() {
c, err := ParseFullConfig(b)
if err != nil {
log.WithError(err).Errorf("Failed to unmarshal %s into either Simple or FullConfig.", path)
} else {
// it's a FullConfig
for pattern, config := range c.Filters {
var re *regexp.Regexp
if pattern != ".*" {
if re, err = regexp.Compile(pattern); err != nil {
log.WithError(err).Errorf("Invalid regexp %q.", pattern)
continue
}
}
o.applyConfigToPath(relPathDir, re, &config)
}
o.applyOptionsToPath(relPathDir, c.Options)
}
} else {
// it's a SimpleConfig
o.applyConfigToPath(relPathDir, nil, &simple.Config)
o.applyOptionsToPath(relPathDir, simple.Options)
}
return nil
}
// ParseFullConfig will unmarshal OWNERS file's content into a FullConfig
// Returns an error if the content cannot be unmarshalled
func ParseFullConfig(b []byte) (FullConfig, error) {
full := new(FullConfig)
err := yaml.Unmarshal(b, full)
return *full, err
}
// ParseSimpleConfig will unmarshal an OWNERS file's content into a SimpleConfig
// Returns an error if the content cannot be unmarshalled
func ParseSimpleConfig(b []byte) (SimpleConfig, error) {
simple := new(SimpleConfig)
err := yaml.Unmarshal(b, simple)
return *simple, err
}
var mdStructuredHeaderRegex = regexp.MustCompile("^---\n(.|\n)*\n---")
// decodeOwnersMdConfig will parse the yaml header if it exists and unmarshal it into a singleOwnersConfig.
// If no yaml header is found, do nothing
// Returns an error if the file cannot be read or the yaml header is found but cannot be unmarshalled.
func decodeOwnersMdConfig(path string, config *SimpleConfig) error {
fileBytes, err := ioutil.ReadFile(path)
if err != nil {
return err
}
// Parse the yaml header from the top of the file. Will return an empty string if regex does not match.
meta := mdStructuredHeaderRegex.FindString(string(fileBytes))
// Unmarshal the yaml header into the config
return yaml.Unmarshal([]byte(meta), &config)
}
func normLogins(logins []string) sets.String {
normed := sets.NewString()
for _, login := range logins {
normed.Insert(github.NormLogin(login))
}
return normed
}
var defaultDirOptions = dirOptions{}
func (o *RepoOwners) applyConfigToPath(path string, re *regexp.Regexp, config *Config) {
if len(config.Approvers) > 0 {
if o.approvers[path] == nil {
o.approvers[path] = make(map[*regexp.Regexp]sets.String)
}
o.approvers[path][re] = o.ExpandAliases(normLogins(config.Approvers))
}
if len(config.Reviewers) > 0 {
if o.reviewers[path] == nil {
o.reviewers[path] = make(map[*regexp.Regexp]sets.String)
}
o.reviewers[path][re] = o.ExpandAliases(normLogins(config.Reviewers))
}
if len(config.RequiredReviewers) > 0 {
if o.requiredReviewers[path] == nil {
o.requiredReviewers[path] = make(map[*regexp.Regexp]sets.String)
}
o.requiredReviewers[path][re] = o.ExpandAliases(normLogins(config.RequiredReviewers))
}
if len(config.Labels) > 0 {
if o.labels[path] == nil {
o.labels[path] = make(map[*regexp.Regexp]sets.String)
}
o.labels[path][re] = sets.NewString(config.Labels...)
}
}
func (o *RepoOwners) applyOptionsToPath(path string, opts dirOptions) {
if opts != defaultDirOptions {
o.options[path] = opts
}
}
func (o *RepoOwners) filterCollaborators(toKeep []github.User) *RepoOwners {
collabs := sets.NewString()
for _, keeper := range toKeep {
collabs.Insert(github.NormLogin(keeper.Login))
}
filter := func(ownerMap map[string]map[*regexp.Regexp]sets.String) map[string]map[*regexp.Regexp]sets.String {
filtered := make(map[string]map[*regexp.Regexp]sets.String)
for path, reMap := range ownerMap {
filtered[path] = make(map[*regexp.Regexp]sets.String)
for re, unfiltered := range reMap {
filtered[path][re] = unfiltered.Intersection(collabs)
}
}
return filtered
}
result := *o
result.approvers = filter(o.approvers)
result.reviewers = filter(o.reviewers)
return &result
}
// findOwnersForFile returns the OWNERS file path furthest down the tree for a specified file
// using ownerMap to check for entries
func findOwnersForFile(log *logrus.Entry, path string, ownerMap map[string]map[*regexp.Regexp]sets.String) string {
d := path
for ; d != baseDirConvention; d = canonicalize(filepath.Dir(d)) {
relative, err := filepath.Rel(d, path)
if err != nil {
log.WithError(err).WithField("path", path).Errorf("Unable to find relative path between %q and path.", d)
return ""
}
for re, n := range ownerMap[d] {
if re != nil && !re.MatchString(relative) {
continue
}
if len(n) != 0 {
return d
}
}
}
return ""
}
// FindApproverOwnersForFile returns the OWNERS file path furthest down the tree for a specified file
// that contains an approvers section
func (o *RepoOwners) FindApproverOwnersForFile(path string) string {
return findOwnersForFile(o.log, path, o.approvers)
}
// FindReviewersOwnersForFile returns the OWNERS file path furthest down the tree for a specified file
// that contains a reviewers section
func (o *RepoOwners) FindReviewersOwnersForFile(path string) string {
return findOwnersForFile(o.log, path, o.reviewers)
}
// FindLabelsForFile returns a set of labels which should be applied to PRs
// modifying files under the given path.
func (o *RepoOwners) FindLabelsForFile(path string) sets.String {
return o.entriesForFile(path, o.labels, false)
}
// IsNoParentOwners checks if an OWNERS file path refers to an OWNERS file with NoParentOwners enabled.
func (o *RepoOwners) IsNoParentOwners(path string) bool {
return o.options[path].NoParentOwners
}
// entriesForFile returns a set of users who are assignees to the
// requested file. The path variable should be a full path to a filename
// and not directory as the final directory will be discounted if enableMDYAML is true
// leafOnly indicates whether only the OWNERS deepest in the tree (closest to the file)
// should be returned or if all OWNERS in filepath should be returned
func (o *RepoOwners) entriesForFile(path string, people map[string]map[*regexp.Regexp]sets.String, leafOnly bool) sets.String {
d := path
if !o.enableMDYAML || !strings.HasSuffix(path, ".md") {
// if path is a directory, this will remove the leaf directory, and returns "." for topmost dir
d = filepath.Dir(d)
d = canonicalize(path)
}
out := sets.NewString()
for {
relative, err := filepath.Rel(d, path)
if err != nil {
o.log.WithError(err).WithField("path", path).Errorf("Unable to find relative path between %q and path.", d)
return nil
}
for re, s := range people[d] {
if re == nil || re.MatchString(relative) {
out.Insert(s.List()...)
}
}
if leafOnly && out.Len() > 0 {
break
}
if d == baseDirConvention {
break
}
if o.options[d].NoParentOwners {
break
}
d = filepath.Dir(d)
d = canonicalize(d)
}
return out
}
// LeafApprovers returns a set of users who are the closest approvers to the
// requested file. If pkg/OWNERS has user1 and pkg/util/OWNERS has user2 this
// will only return user2 for the path pkg/util/sets/file.go
func (o *RepoOwners) LeafApprovers(path string) sets.String {
return o.entriesForFile(path, o.approvers, true)
}
// Approvers returns ALL of the users who are approvers for the
// requested file (including approvers in parent dirs' OWNERS).
// If pkg/OWNERS has user1 and pkg/util/OWNERS has user2 this
// will return both user1 and user2 for the path pkg/util/sets/file.go
func (o *RepoOwners) Approvers(path string) sets.String {
return o.entriesForFile(path, o.approvers, false)
}
// LeafReviewers returns a set of users who are the closest reviewers to the
// requested file. If pkg/OWNERS has user1 and pkg/util/OWNERS has user2 this
// will only return user2 for the path pkg/util/sets/file.go
func (o *RepoOwners) LeafReviewers(path string) sets.String {
return o.entriesForFile(path, o.reviewers, true)
}
// Reviewers returns ALL of the users who are reviewers for the
// requested file (including reviewers in parent dirs' OWNERS).
// If pkg/OWNERS has user1 and pkg/util/OWNERS has user2 this
// will return both user1 and user2 for the path pkg/util/sets/file.go
func (o *RepoOwners) Reviewers(path string) sets.String {
return o.entriesForFile(path, o.reviewers, false)
}
// RequiredReviewers returns ALL of the users who are required_reviewers for the
// requested file (including required_reviewers in parent dirs' OWNERS).
// If pkg/OWNERS has user1 and pkg/util/OWNERS has user2 this
// will return both user1 and user2 for the path pkg/util/sets/file.go
func (o *RepoOwners) RequiredReviewers(path string) sets.String {
return o.entriesForFile(path, o.requiredReviewers, false)
}