check

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvoidShadowing

type AvoidShadowing struct{}

func NewAvoidShadowing

func NewAvoidShadowing() *AvoidShadowing

func (*AvoidShadowing) Check

func (c *AvoidShadowing) Check(ctx context.Context, in Input) (output Output, err error)

func (AvoidShadowing) Name

func (AvoidShadowing) Name() string

Name returns human readable name of the validator

type Checker

type Checker interface {
	Check(ctx context.Context, in Input) (Output, error)
	Name() string
}

Checker allows to execute check in a generic way

type DuplicatedPattern

type DuplicatedPattern struct{}

DuplicatedPattern validates if CODEOWNERS file does not contain the duplicated lines with the same file pattern.

func NewDuplicatedPattern

func NewDuplicatedPattern() *DuplicatedPattern

NewDuplicatedPattern returns instance of the DuplicatedPattern

func (*DuplicatedPattern) Check

func (d *DuplicatedPattern) Check(ctx context.Context, in Input) (Output, error)

Check searches for doubles paths(patterns) in CODEOWNERS file.

func (DuplicatedPattern) Name

func (DuplicatedPattern) Name() string

Name returns human readable name of the validator.

type FileExist

type FileExist struct{}

func NewFileExist

func NewFileExist() *FileExist

func (*FileExist) Check

func (f *FileExist) Check(ctx context.Context, in Input) (Output, error)

func (*FileExist) Name

func (*FileExist) Name() string

type Input

type Input struct {
	RepoDir           string
	CodeownersEntries []codeowners.Entry
}

type Issue

type Issue struct {
	Severity SeverityType // enum // default error
	LineNo   *uint64
	Message  string
}

type NotOwnedFile

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

func NewNotOwnedFile

func NewNotOwnedFile(cfg NotOwnedFileConfig) *NotOwnedFile

func (*NotOwnedFile) AppendToGitignoreFile

func (c *NotOwnedFile) AppendToGitignoreFile(repoDir string, patterns []string) error

func (*NotOwnedFile) Check

func (c *NotOwnedFile) Check(ctx context.Context, in Input) (output Output, err error)

func (*NotOwnedFile) GitCheckStatus

func (c *NotOwnedFile) GitCheckStatus(repoDir string) ([]byte, error)

func (*NotOwnedFile) GitListFiles

func (c *NotOwnedFile) GitListFiles(repoDir string) (string, error)

func (*NotOwnedFile) GitRemoveIgnoredFiles

func (c *NotOwnedFile) GitRemoveIgnoredFiles(repoDir string) error

func (*NotOwnedFile) GitResetCurrentBranch

func (c *NotOwnedFile) GitResetCurrentBranch(repoDir string) error

func (*NotOwnedFile) ListFormatFunc

func (c *NotOwnedFile) ListFormatFunc(es []string) string

ListFormatFunc is a basic formatter that outputs a bullet point list of the pattern.

func (NotOwnedFile) Name

func (NotOwnedFile) Name() string

Name returns human-readable name of the validator

type NotOwnedFileConfig

type NotOwnedFileConfig struct {
	// TrustWorkspace sets the global gif config
	// to trust a given repository path
	// see: https://github.com/actions/checkout/issues/766
	TrustWorkspace bool     `envconfig:"default=false"`
	SkipPatterns   []string `envconfig:"optional"`
	Subdirectories []string `envconfig:"optional"`
}

type Output

type Output struct {
	Issues []Issue
}

type OutputBuilder

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

func (*OutputBuilder) Output

func (bldr *OutputBuilder) Output() Output

func (*OutputBuilder) ReportIssue

func (bldr *OutputBuilder) ReportIssue(msg string, opts ...ReportIssueOpt) *OutputBuilder

type ReportIssueOpt

type ReportIssueOpt func(*Issue)

func WithEntry

func WithEntry(e codeowners.Entry) ReportIssueOpt

func WithSeverity

func WithSeverity(s SeverityType) ReportIssueOpt

type SeverityType

type SeverityType int
const (
	Error SeverityType = iota + 1
	Warning
)

func (SeverityType) String

func (s SeverityType) String() string

func (*SeverityType) Unmarshal

func (s *SeverityType) Unmarshal(in string) error

Unmarshal provides custom parsing of severity type. Implements envconfig.Unmarshal interface.

type ValidOwner

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

ValidOwner validates each owner

func NewValidOwner

func NewValidOwner(cfg ValidOwnerConfig, ghClient *github.Client, checkScopes bool) (*ValidOwner, error)

NewValidOwner returns new instance of the ValidOwner

func (*ValidOwner) Check

func (v *ValidOwner) Check(ctx context.Context, in Input) (Output, error)

Check if defined owners are the valid ones. Allowed owner syntax: @username @org/team-name user@example.com source: https://help.github.com/articles/about-code-owners/#codeowners-syntax

Checks: - if owner is one of: GitHub user, org team, email address - if GitHub user then check if have GitHub account - if GitHub user then check if he/she is in organization - if org team then check if exists in organization

func (*ValidOwner) CheckSatisfied

func (v *ValidOwner) CheckSatisfied(ctx context.Context) error

CheckSatisfied checks if this check has all requirements satisfied to be successfully executed.

func (ValidOwner) Name

func (ValidOwner) Name() string

Name returns human-readable name of the validator

type ValidOwnerConfig

type ValidOwnerConfig struct {
	// Repository represents the GitHub repository against which
	// the external checks like teams and members validation should be executed.
	// It is in form 'owner/repository'.
	Repository string
	// IgnoredOwners contains a list of owners that should not be validated.
	// Defaults to @ghost.
	// More info about the @ghost user: https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-your-github-user-account/deleting-your-user-account
	// Tip on how @ghost can be used: https://github.community/t5/How-to-use-Git-and-GitHub/CODEOWNERS-file-with-a-NOT-file-type-condition/m-p/31013/highlight/true#M8523
	IgnoredOwners []string `envconfig:"default=@ghost"`
	// AllowUnownedPatterns specifies whether CODEOWNERS may have unowned files. For example:
	//
	//  /infra/oncall-rotator/                    @sre-team
	//  /infra/oncall-rotator/oncall-config.yml
	//
	//  The `/infra/oncall-rotator/oncall-config.yml` this file is not owned by anyone.
	AllowUnownedPatterns bool `envconfig:"default=true"`
	// OwnersMustBeTeams specifies whether owners must be teams in the same org as the repository
	OwnersMustBeTeams bool `envconfig:"default=false"`
}

type ValidSyntax

type ValidSyntax struct{}

ValidSyntax provides a syntax validation for CODEOWNERS file.

If any line in your CODEOWNERS file contains invalid syntax, the file will not be detected and will not be used to request reviews. Invalid syntax includes inline comments and user or team names that do not exist on GitHub.

func NewValidSyntax

func NewValidSyntax() *ValidSyntax

NewValidSyntax returns new ValidSyntax instance.

func (*ValidSyntax) Check

func (v *ValidSyntax) Check(ctx context.Context, in Input) (Output, error)

Check for syntax issues in your CODEOWNERS file.

func (ValidSyntax) Name

func (ValidSyntax) Name() string

Jump to

Keyboard shortcuts

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