Documentation
¶
Overview ¶
Package codeowners provides funcionality to evaluate CODEOWNERS file.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultLocations = [...]string{"CODEOWNERS", "docs/CODEOWNERS", ".github/CODEOWNERS"}
DefaultLocations provides default locations for the CODEOWNERS file
Functions ¶
func AvailableCheckers ¶
func AvailableCheckers() []string
AvailableCheckers returns list of registered checkers
func RegisterChecker ¶
RegisterChecker adds checker to be used later when checking CODEOWNERS files
Types ¶
type CheckOptions ¶ added in v0.3.0
type CheckOptions struct {
Directory string
Checkers []string
GithubTokenType string
GithubToken string
}
CheckOptions provides parameters for running a list of checks
type CheckResult ¶
type CheckResult struct {
Position Position
Message string
Severity SeverityLevel
CheckName string
}
CheckResult provides structured way to evaluate results of a CODEOWNERS validation check
func Check ¶
func Check(options CheckOptions) ([]CheckResult, error)
Check evaluates the file contents against the checkers and return the results back.
Example ¶
package main
import (
"fmt"
"github.com/fmenezes/codeowners"
)
func main() {
checks, err := codeowners.Check(codeowners.CheckOptions{
Directory: ".",
Checkers: codeowners.AvailableCheckers(),
})
if err != nil {
panic(err)
}
for _, check := range checks {
fmt.Printf("%s ::%s:: %s [%s]\n", check.Position.Format(), check.Severity.Name(), check.Message, check.CheckName)
}
}
Output: CODEOWNERS 0 ::Error:: No CODEOWNERS file found [NoCodeowners]
type Checker ¶
type Checker interface {
NewValidator(options ValidatorOptions) Validator
}
Checker provides tools for validating CODEOWNER file contents
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder providers functionality to read CODEOWNERS data
Example ¶
package main
import (
"fmt"
"strings"
"github.com/fmenezes/codeowners"
)
func main() {
decoder := codeowners.NewDecoder(strings.NewReader(`* test@example.org
filepattern @owner`))
for decoder.More() {
token, line := decoder.Token()
fmt.Printf("Line: %d\n", line)
fmt.Printf("File Pattern: %s\n", token.Path())
fmt.Printf("Owners: %v\n", token.Owners())
}
}
Output: Line: 1 File Pattern: * Owners: [test@example.org] Line: 2 File Pattern: filepattern Owners: [@owner]
func NewDecoder ¶
NewDecoder generates a new Decoder instance. The reader should contain the contents of the CODEOWNERS file
type Position ¶ added in v0.2.0
Position provides structured way to evaluate where a given validation result is located in the CODEOWNERs file
type SeverityLevel ¶
type SeverityLevel int
SeverityLevel exposes all possible levels of severity check results
const ( Error SeverityLevel = iota // Error serverity level Warning // Warning serverity level )
All possible severiy levels
func (SeverityLevel) Name ¶ added in v0.3.2
func (l SeverityLevel) Name() string
Name returns the string representation of this severity level
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token providers reading capabilities for every CODEOWNERS line
type Validator ¶ added in v0.3.0
type Validator interface {
ValidateLine(lineNo int, line string) []CheckResult
}
Validator provides tools for validating CODEOWNER file contents
Directories
¶
| Path | Synopsis |
|---|---|
|
Package checkers contain pre built checkers to validate CODEOWNER files
|
Package checkers contain pre built checkers to validate CODEOWNER files |
|
cmd
|
|
|
codeownerslint
command
|