Documentation ¶
Overview ¶
Package codeowners includes github codeowners management utilities
Index ¶
- Constants
- func MakeRepositoryAbsolute(repositoryRoot, path string) (string, error)
- type Codeowners
- func (c Codeowners) Debugf(format string, args ...interface{})
- func (c Codeowners) Generate(ctx context.Context, root string, output io.Writer) error
- func (c Codeowners) GenerateFile(ctx context.Context, root string) error
- func (c Codeowners) GetStderr() io.Writer
- func (c Codeowners) GetStdout() io.Writer
- func (c Codeowners) Validate(ctx context.Context, input io.Reader) error
- func (c Codeowners) ValidateFile(ctx context.Context) error
- func (c Codeowners) Verbosef(format string, args ...interface{})
- type Config
- type File
- type GithubClient
- func (ghc GithubClient) CreateURL(path string) string
- func (ghc GithubClient) Do(req *http.Request) (*http.Response, error)
- func (ghc GithubClient) Get(ctx context.Context, path string, output interface{}) error
- func (ghc GithubClient) Post(ctx context.Context, path string, input, output interface{}) error
- func (ghc GithubClient) TeamExists(ctx context.Context, teamName string) error
- func (ghc GithubClient) UserExists(ctx context.Context, username string) error
- type Option
- type Path
- type Source
Constants ¶
const ( // DefaultPath is the default realized codeowners path. DefaultPath = "./.github/CODEOWNERS" // DefaultGithubURL is the default github url. DefaultGithubURL = "https://git.blendlabs.com" // DefaultGithubTokenEnvVar standardizes an environment variable // to read the github api token from. DefaultGithubTokenEnvVar = "GHE_TOKEN" )
const ( // OwnersFile is the per path owners file users can create. OwnersFile = ".codeowners" // OwnersFileHeader is the header that is prefixed to the generated // owners file. OwnersFileHeader = `` /* 365-byte string literal not displayed */ // OwnersGoCommentPrefix is the prefix for owners hints within go files. OwnersGoCommentPrefix = "github:codeowner" // OwnersFileSourceComment is the owners file comment marking the beginning // of a section for a given source. OwnersFileSourceComment = "# source: " // OwnersFileSourceEndComment is the owners file comment marking the end // of a section for a given source. OwnersFileSourceEndComment = "# source-end: " )
Variables ¶
This section is empty.
Functions ¶
func MakeRepositoryAbsolute ¶
MakeRepositoryAbsolute make a path absolute.
Types ¶
type Codeowners ¶
type Codeowners struct { // Config holds the configuration opitons. Config // Stdout is the writer for Verbose and Debug output. // If it is unset, `os.Stdout` will be used. Stdout io.Writer // Stderr is the writer for Error output. // If it is unset, `os.Stderr` will be used. Stderr io.Writer }
Codeowners holds the engine that generates and validates codeowners files.
func New ¶
func New(options ...Option) *Codeowners
New creates a new copyright engine with a given set of config options.
func (Codeowners) Debugf ¶
func (c Codeowners) Debugf(format string, args ...interface{})
Debugf writes to stdout if the `Debug` flag is true.
func (Codeowners) GenerateFile ¶
func (c Codeowners) GenerateFile(ctx context.Context, root string) error
GenerateFile generates the file as nominated by the config path.
func (Codeowners) GetStderr ¶
func (c Codeowners) GetStderr() io.Writer
GetStderr returns standard error.
func (Codeowners) GetStdout ¶
func (c Codeowners) GetStdout() io.Writer
GetStdout returns standard out.
func (Codeowners) ValidateFile ¶
func (c Codeowners) ValidateFile(ctx context.Context) error
ValidateFile validates the file as configured in the config field.
func (Codeowners) Verbosef ¶
func (c Codeowners) Verbosef(format string, args ...interface{})
Verbosef writes to stdout if the `Verbose` flag is true.
type Config ¶
type Config struct { // Path is the owners file path (typically `.github/CODEOWNERS`) Path string `yaml:"path"` // GithubURL is the url of the github instance to communicate with. GithubURL string `yaml:"githubURL"` // GithubToken is the authorization token used to communicate with github. GithubToken string `yaml:"githubToken"` // Quiet controls whether output is suppressed. Quiet *bool `yaml:"quiet"` // Verbose controls whether verbose output is shown. Verbose *bool `yaml:"verbose"` // Debug controls whether debug output is shown. Debug *bool `yaml:"debug"` }
Config are the configuration options for the utility.
func (Config) DebugOrDefault ¶
DebugOrDefault returns a value or a default.
func (Config) GithubURLOrDefault ¶
GithubURLOrDefault returns a value or a default.
func (Config) PathOrDefault ¶
PathOrDefault is the path for the codeowners file or a default.
func (Config) QuietOrDefault ¶
QuietOrDefault returns a value or a default.
func (Config) VerboseOrDefault ¶
VerboseOrDefault returns a value or a default.
type GithubClient ¶
GithubClient is a client to make requests to github via the api.
func (GithubClient) CreateURL ¶
func (ghc GithubClient) CreateURL(path string) string
CreateURL creates a fully qualified url with a given path.
func (GithubClient) Get ¶
func (ghc GithubClient) Get(ctx context.Context, path string, output interface{}) error
Get makes a get request.
func (GithubClient) Post ¶
func (ghc GithubClient) Post(ctx context.Context, path string, input, output interface{}) error
Post makes a post request.
func (GithubClient) TeamExists ¶
func (ghc GithubClient) TeamExists(ctx context.Context, teamName string) error
TeamExists fetches a team and returns if that team exists or not.
func (GithubClient) UserExists ¶
func (ghc GithubClient) UserExists(ctx context.Context, username string) error
UserExists fetches a user and returns if that user exists or not.
type Source ¶
Source is a set of ownership entries.
func ParseGoComments ¶
ParseGoComments parses a files comments.
func ParseSource ¶
ParseSource parses a source from a given path.