gha

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRepositoryOwner is returned when the client config has no
	// repository owner
	ErrNoRepositoryOwner = errors.New("no repository owner provided")
	// ErrNoRepositoryName is returned when the client config has no
	// repository name
	ErrNoRepositoryName = errors.New("no repository name provided")
	// ErrNoRef is returned when the client config has no branch ref
	ErrNoRef = errors.New("no branch ref provided")
	// ErrClientPageSizeTooLarge is returned when the page list is larger than
	// 100
	ErrClientPageSizeTooLarge = errors.New("client page size maximum can be 100")
	// ErrWrongSeverity is returned when the severity level can't be parsed
	ErrWrongSeverity = errors.New("wrong severity value")
	// ErrNoOauth2TokenProvided is returned when no oauth2 token is provided
	ErrNoOauth2TokenProvided = errors.New("no oauth2 token provided")
	// ErrWrongRequestTimeoutDuration is returned when the request duration
	// can't be parsed
	ErrWrongRequestTimeoutDuration = errors.New("wrong request duration")
	// ErrCouldNotParsePageSize is returned when there is no
	ErrCouldNotParsePageSize = errors.New("could not parse page size")
)
View Source
var ErrWrongCredentials = errors.New("authentication error from Github API, token wrong, expired or no permissions")

ErrWrongCredentials is returned when either the credentials are wrong, they are expired or they don't have the correct permissions

Functions

func ParseIssues

func ParseIssues(alerts []*github.Alert) []*v1proto.Issue

Types

type APIClient

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

RepoAlertsClient is a client invoking the Github API to fetch a list of alerts for a repository

func NewClient

func NewClient(ctx context.Context, config *ClientConfig) *APIClient

NewClient returns a client that can be used to query the Github API and will use exponential backoff to manage failed API calls

func (*APIClient) ListRepoAlerts

func (a *APIClient) ListRepoAlerts(
	ctx context.Context,
) ([]*github.Alert, error)

ListRepoAlerts uses the underlying repoLister implementation and an exponential backoff algorithm to wait when it gets an erroneous result

type ClientConfig

type ClientConfig struct {
	// RepositoryOwner is the owner of the GitHub repository
	RepositoryOwner string

	// RepositoryName is the name of the GitHub repository
	RepositoryName string

	// Token is the GitHub token used to authenticate
	Token string

	// Toolname is the name of tool to fetch results for
	Toolname string

	// Ref is the reference of the branch or the pull request to use. It should
	// be either of the form `refs/heads/<branch name>`, branch name or
	// `refs/pulls/<pull request id>`
	Ref string

	// Severity if specified, causes only code scanning alerts with this
	// severity will be returned. Possible values are: critical, high, medium,
	// low, warning, note, error
	Severity string

	// RequestTimeout is how long to wait for github to respond
	RequestTimeoutStr string

	// RequestTimeout is the parsed max duration of each request. Max is 5m
	// default is 30s
	RequestTimeout time.Duration

	// PageSizeStr defines how many alerts to ask from github at once
	PageSizeStr string

	// PageSize is the maximum number of results to request from the API per
	// request. If PageSizeStr is set, it will be converted into an integer and
	// override this value. Max value is 100
	PageSize int
}

ClientConfig is used to gather all the importat

func (*ClientConfig) Parse

func (c *ClientConfig) Parse() error

Jump to

Keyboard shortcuts

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