repoowners

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormLogins

func NormLogins(logins []string) sets.String

NormLogins normalizes logins

func SaveFullConfig

func SaveFullConfig(full FullConfig, path string) error

SaveFullConfig writes FullConfig to `path`

func SaveSimpleConfig

func SaveSimpleConfig(simple SimpleConfig, path string) error

SaveSimpleConfig writes SimpleConfig to `path`

Types

type Client

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

Client is the repoowners client

func NewClient

func NewClient(
	gc git.ClientFactory,
	ghc github.Client,
	mdYAMLEnabled func(org, repo string) bool,
	skipCollaborators func(org, repo string) bool,
	ownersDirDenylist func() *prowConf.OwnersDirDenylist,
	filenames ownersconfig.Resolver,
) *Client

NewClient is the constructor for Client

func (*Client) ForPlugin

func (c *Client) ForPlugin(plugin string) Interface

ForPlugin clones the client, keeping the underlying delegate the same but adding a log field

func (*Client) LoadRepoOwners

func (c *Client) LoadRepoOwners(org, repo, base string) (RepoOwner, error)

LoadRepoOwners returns an up-to-date RepoOwners struct for the specified repo. Note: The returned *RepoOwners should be treated as read only.

func (*Client) LoadRepoOwnersSha

func (c *Client) LoadRepoOwnersSha(org, repo, base, sha string, updateCache bool) (RepoOwner, error)

func (*Client) Used

func (c *Client) Used() bool

Used determines whether the client has been used

func (*Client) WithFields

func (c *Client) WithFields(fields logrus.Fields) Interface

WithFields clones the client, keeping the underlying delegate the same but adding fields to the logging context

func (*Client) WithGitHubClient

func (c *Client) WithGitHubClient(client github.Client) Interface

WithGitHubClient clones the client, keeping the underlying delegate the same but adding a new GitHub Client. This is useful when making use a context-local client

type Config

type Config struct {
	Approvers         []string `json:"approvers,omitempty"`
	Reviewers         []string `json:"reviewers,omitempty"`
	RequiredReviewers []string `json:"required_reviewers,omitempty"`
	Labels            []string `json:"labels,omitempty"`
}

Config holds roles+usernames and labels for a directory considered as a unit of independent code

type FullConfig

type FullConfig struct {
	Options dirOptions        `json:"options,omitempty"`
	Filters map[string]Config `json:"filters,omitempty"`
}

FullConfig contains Filters which apply specific Config to files matching its regexp

func LoadFullConfig

func LoadFullConfig(b []byte) (FullConfig, error)

LoadFullConfig loads FullConfig from bytes `b`

type Interface

type Interface interface {
	LoadRepoOwners(org, repo, base string) (RepoOwner, error)
	LoadRepoOwnersSha(org, repo, base, sha string, updateCache bool) (RepoOwner, error)

	WithFields(fields logrus.Fields) Interface
	WithGitHubClient(client github.Client) Interface
	ForPlugin(plugin string) Interface
	Used() bool
}

Interface is an interface to work with OWNERS files.

type RepoAliases

type RepoAliases map[string]sets.String

RepoAliases defines groups of people to be used in OWNERS files

func ParseAliasesConfig

func ParseAliasesConfig(b []byte) (RepoAliases, error)

ParseAliasesConfig will unmarshal an OWNERS_ALIASES file's content into RepoAliases. Returns an error if the content cannot be unmarshalled.

func (RepoAliases) ExpandAlias

func (a RepoAliases) ExpandAlias(alias string) sets.String

ExpandAlias returns members of an alias

func (RepoAliases) ExpandAliases

func (a RepoAliases) ExpandAliases(logins sets.String) sets.String

ExpandAliases returns members of multiple aliases, duplicates are pruned

func (RepoAliases) ExpandAllAliases

func (a RepoAliases) ExpandAllAliases() sets.String

ExpandAllAliases returns members of all aliases mentioned, duplicates are pruned

type RepoOwner

type RepoOwner interface {
	FindApproverOwnersForFile(path string) string
	FindReviewersOwnersForFile(path string) string
	FindLabelsForFile(path string) sets.String
	IsNoParentOwners(path string) bool
	IsAutoApproveUnownedSubfolders(directory string) bool
	LeafApprovers(path string) sets.String
	Approvers(path string) layeredsets.String
	LeafReviewers(path string) sets.String
	Reviewers(path string) layeredsets.String
	RequiredReviewers(path string) sets.String
	ParseSimpleConfig(path string) (SimpleConfig, error)
	ParseFullConfig(path string) (FullConfig, error)
	TopLevelApprovers() sets.String
	Filenames() ownersconfig.Filenames
	AllOwners() sets.String
	AllApprovers() sets.String
	AllReviewers() sets.String
}

RepoOwner is an interface to work with repoowners

type RepoOwners

type RepoOwners struct {
	RepoAliases
	// contains filtered or unexported fields
}

RepoOwners contains the parsed OWNERS config.

func (*RepoOwners) AllApprovers

func (o *RepoOwners) AllApprovers() sets.String

AllApprovers returns ALL of the users who are approvers, at least for a file across the structure of the repository. If pkg/OWNERS has user1 as approver and user2 as reviewer, and pkg/util has user3 as approver and user4 as reviewer, the function will return user1, and user3.

func (*RepoOwners) AllOwners

func (o *RepoOwners) AllOwners() sets.String

AllOwners returns ALL of the users who are approvers or reviewers, at least for a file across the structure of the repository. If pkg/OWNERS has user1 as approver and user2 as reviewer, and pkg/util has user3 as approver and user4 as reviewer, the function will return user1, user2, user3, and user4.

func (*RepoOwners) AllReviewers

func (o *RepoOwners) AllReviewers() sets.String

AllReviewers returns ALL of the users who are reviewers, at least for a file across the structure of the repository. If pkg/OWNERS has user1 as approver and user2 as reviewer, and pkg/util has user3 as approver and user4 as reviewer, the function will return user2, and user4.

func (*RepoOwners) Approvers

func (o *RepoOwners) Approvers(path string) layeredsets.String

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 (*RepoOwners) Filenames

func (r *RepoOwners) Filenames() ownersconfig.Filenames

func (*RepoOwners) FindApproverOwnersForFile

func (o *RepoOwners) FindApproverOwnersForFile(path string) string

FindApproverOwnersForFile returns the directory containing the OWNERS file furthest down the tree for a specified file that contains an approvers section

func (*RepoOwners) FindLabelsForFile

func (o *RepoOwners) FindLabelsForFile(path string) sets.String

FindLabelsForFile returns a set of labels which should be applied to PRs modifying files under the given path.

func (*RepoOwners) FindReviewersOwnersForFile

func (o *RepoOwners) FindReviewersOwnersForFile(path string) string

FindReviewersOwnersForFile returns the OWNERS file path furthest down the tree for a specified file that contains a reviewers section

func (*RepoOwners) IsAutoApproveUnownedSubfolders

func (o *RepoOwners) IsAutoApproveUnownedSubfolders(ownersFilePath string) bool

func (*RepoOwners) IsNoParentOwners

func (o *RepoOwners) IsNoParentOwners(path string) bool

IsNoParentOwners checks if an OWNERS file path refers to an OWNERS file with NoParentOwners enabled.

func (*RepoOwners) LeafApprovers

func (o *RepoOwners) LeafApprovers(path string) sets.String

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 (*RepoOwners) LeafReviewers

func (o *RepoOwners) LeafReviewers(path string) sets.String

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 (*RepoOwners) ParseFullConfig

func (o *RepoOwners) ParseFullConfig(path string) (FullConfig, error)

ParseFullConfig will unmarshal the content of the OWNERS file at the path into a FullConfig. If the OWNERS directory is ignorelisted, it returns filepath.SkipDir. Returns an error if the content cannot be unmarshalled.

func (*RepoOwners) ParseSimpleConfig

func (o *RepoOwners) ParseSimpleConfig(path string) (SimpleConfig, error)

ParseSimpleConfig will unmarshal the content of the OWNERS file at the path into a SimpleConfig. If the OWNERS directory is ignorelisted, it returns filepath.SkipDir. Returns an error if the content cannot be unmarshalled.

func (*RepoOwners) RequiredReviewers

func (o *RepoOwners) RequiredReviewers(path string) sets.String

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 (*RepoOwners) Reviewers

func (o *RepoOwners) Reviewers(path string) layeredsets.String

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 (*RepoOwners) TopLevelApprovers

func (o *RepoOwners) TopLevelApprovers() sets.String

type SimpleConfig

type SimpleConfig struct {
	Options dirOptions `json:"options,omitempty"`
	Config  `json:",inline"`
}

SimpleConfig holds options and Config applied to everything under the containing directory

func LoadSimpleConfig

func LoadSimpleConfig(b []byte) (SimpleConfig, error)

LoadSimpleConfig loads SimpleConfig from bytes `b`

func (*SimpleConfig) Empty

func (s *SimpleConfig) Empty() bool

Empty checks if a SimpleConfig could be considered empty

Jump to

Keyboard shortcuts

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