package owners import ( "regexp" "edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/approval" "edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/common" "edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/predicate" ) const ( FileName = "OWNERS" Regex = `.*` ) // File defines the structure of the OWNERS files used to manage code // ownership for a repository. type File struct { // Approval is an array of Policy-bot apporval policies: https://github.com/palantir/policy-bot#approval-policies Approval []interface{} `yaml:"approval"` // Rules is an array of Policy-bot approval rules: https://github.com/palantir/policy-bot#approval-rules Rules []*approval.Rule `yaml:"rules"` } func DefaultFile(users, teams []string, path string) *File { rules := []*approval.Rule{} rule := &approval.Rule{ Name: path, Predicates: predicate.Predicates{ ChangedFiles: &predicate.ChangedFiles{ Paths: []common.Regexp{common.NewCompiledRegexp(regexp.MustCompile(Regex))}, }, }, Requires: approval.Requires{ Count: 1, Actors: common.Actors{ Users: users, Teams: teams, }, }, } rules = append(rules, rule) return &File{ Rules: rules, Approval: []interface{}{ path, }, } }