...

Source file src/edge-infra.dev/pkg/f8n/devinfra/repo/owners/file.go

Documentation: edge-infra.dev/pkg/f8n/devinfra/repo/owners

     1  package owners
     2  
     3  import (
     4  	"regexp"
     5  
     6  	"edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/approval"
     7  	"edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/common"
     8  	"edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/predicate"
     9  )
    10  
    11  const (
    12  	FileName = "OWNERS"
    13  	Regex    = `.*`
    14  )
    15  
    16  // File defines the structure of the OWNERS files used to manage code
    17  // ownership for a repository.
    18  type File struct {
    19  	// Approval is an array of Policy-bot apporval policies: https://github.com/palantir/policy-bot#approval-policies
    20  	Approval []interface{} `yaml:"approval"`
    21  
    22  	// Rules is an array of Policy-bot approval rules: https://github.com/palantir/policy-bot#approval-rules
    23  	Rules []*approval.Rule `yaml:"rules"`
    24  }
    25  
    26  func DefaultFile(users, teams []string, path string) *File {
    27  	rules := []*approval.Rule{}
    28  	rule := &approval.Rule{
    29  		Name: path,
    30  		Predicates: predicate.Predicates{
    31  			ChangedFiles: &predicate.ChangedFiles{
    32  				Paths: []common.Regexp{common.NewCompiledRegexp(regexp.MustCompile(Regex))},
    33  			},
    34  		},
    35  		Requires: approval.Requires{
    36  			Count: 1,
    37  			Actors: common.Actors{
    38  				Users: users,
    39  				Teams: teams,
    40  			},
    41  		},
    42  	}
    43  	rules = append(rules, rule)
    44  
    45  	return &File{
    46  		Rules: rules,
    47  		Approval: []interface{}{
    48  			path,
    49  		},
    50  	}
    51  }
    52  

View as plain text