repoowners

package module
v0.0.0-...-a31aef0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2019 License: MIT Imports: 11 Imported by: 0

README

go-repoowners

Build Status

repoowners treats OWNERS file and OWNERS_ALIASES file inspired by kubernetes/test-infra/prow/repoowners.

OWNERS spec

OWNERS file defines the approvers and the reviewers for the directory. It is applied to everything within the dir, including the OWNERS file itself and children. OWNERS files do not have its extension, however, they are written in YAML format and the keys are:

  • approvers: a list of GitHub usernames or aliases that can approve a PR.
  • reviewers: a list of GitHub usernames or aliases that can review a PR.
  • required_reviewers: a list of GitHub usernames or aliases that can review a PR and a review by one of them is required.
  • options: a map of options.
    • no_inherit: boolean value which shows exclude parent OWNERS files for the directory and children.

A typical OWNERS file looks like:

---
approvers:
  - alice
  - bob
reviewers:
  - charlie
  - dave
  - ellen

In this case, alice and bob can approve/merge a PR and charlie, dave, and ellen can review a PR. The GitHub usernames are case-insensitive.

OWNERS_ALIAS spec

Each repository may contain an OWNERS_ALIAS file at its repository root. OWNERS_ALIAS file defines groups of GitHub users, they are written in YAML format. This file contains only one key: aliases, a mapping of alias name to a lis of GitHub usernames.

A typical OWNERS_ALIAS file looks like:

---
aliases:
  admins:
    - alice
    - bob
  members:
    - charlie
    - dave
    - ellen

Then OWNERS can be written:

---
approvers:
  - admins
reviewers:
  - members

The alias names and GitHub usernames are case-insensitive.

Documentation

Index

Constants

View Source
const (
	DefaultOwnersFilename  = "OWNERS"
	DefaultAliasesFilename = "OWNERS_ALIASES"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Owners

type Owners struct {
	// contains filtered or unexported fields
}

Owners holds Owners configuration for one repository.

func LoadLocal

func LoadLocal(basePath string) (Owners, error)

func LoadRemote

func LoadRemote(domain, org, repo, branch string) (Owners, error)

func (*Owners) Approvers

func (o *Owners) Approvers(path string) UsernameSet

Approvers returns a set of approvers for given file path.

func (*Owners) IsApprover

func (o *Owners) IsApprover(user, path string) bool

IsApprover returns true if given user is an approver for given file path.

func (*Owners) IsRequiredReviewer

func (o *Owners) IsRequiredReviewer(user, path string) bool

IsRequiredReviewer returns true if given user is a required reviewer for given path.

func (*Owners) IsReviewer

func (o *Owners) IsReviewer(user, path string) bool

IsReviewer returns true if given user is a reviewer for given file path.

func (*Owners) RequiredReviewers

func (o *Owners) RequiredReviewers(path string) UsernameSet

RequiredReviewers returns a set of required reviewers for given file path.

func (*Owners) Reviewers

func (o *Owners) Reviewers(path string) UsernameSet

Reviewers returns a set of reviewers for given file path.

type UsernameSet

type UsernameSet map[string]struct{}

UsernameSet is a set type for usernames.

func (UsernameSet) Add

func (us UsernameSet) Add(usernames ...string)

Add given usernames to the set. This function is mutable.

func (UsernameSet) Copy

func (us UsernameSet) Copy() UsernameSet

Copy returns a new copy of UsernameSet.

func (UsernameSet) Delete

func (us UsernameSet) Delete(usernames ...string)

Delete given usernames from the set. This function is mutable.

func (UsernameSet) Has

func (us UsernameSet) Has(username string) bool

Has returns true if given username is a member of the set.

func (UsernameSet) List

func (us UsernameSet) List() []string

List returns a sorted list which contains members of set.

func (UsernameSet) Pop

func (us UsernameSet) Pop() (string, bool)

Pop returns a username from the set and remove it. Return true if the returned value at first return, is a member of the set, otherwise false as second return value..

func (UsernameSet) String

func (us UsernameSet) String() string

func (UsernameSet) Union

func (us UsernameSet) Union(us2 UsernameSet) UsernameSet

Union get a new set which contains the members of the set and the members of given set. This function is immutable.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL