Documentation
¶
Index ¶
- Constants
- Variables
- func ParseSlug(slug string) (org, repo string)
- type Client
- type GitHub
- func (github *GitHub) AddLabel(owner, repo string, issue int, label string) error
- func (github *GitHub) CreateComment(ctx context.Context, slug string, number int, body string) (user *gogithub.IssueComment, err error)
- func (github *GitHub) DeleteComment(ctx context.Context, slug string, commentID int64) (err error)
- func (github *GitHub) GetAPIUser(ctx context.Context) (user *gogithub.User, err error)
- func (github *GitHub) GetComment(owner, repo string, commentID int64) (comment *gogithub.IssueComment, err error)
- func (github *GitHub) GetIssue(ctx context.Context, owner, repo string, issueID int) (pr *gogithub.Issue, err error)
- func (github *GitHub) GetIssueComments(ctx context.Context, slug string, number int) (comments []*gogithub.IssueComment, err error)
- func (github *GitHub) GetPullRequest(ctx context.Context, owner, repo string, prID int) (pr *gogithub.PullRequest, err error)
- func (github *GitHub) ListCheckRunsForRef(ctx context.Context, slug, ref string) (*gogithub.ListCheckRunsResults, error)
- func (github *GitHub) ListLabels(owner, repo string) ([]*gogithub.Label, error)
- func (github *GitHub) ListPullRequestFiles(ctx context.Context, slug string, pr int) (files []*gogithub.CommitFile, err error)
- func (github *GitHub) MergePullRequest(ctx context.Context, owner, repo string, number int) error
- func (github *GitHub) RemoveLabel(owner, repo string, issue int, label string) error
- type Options
Constants ¶
const ( // TokenEnvKey is the default GitHub token environemt variable key TokenEnvKey = "GITHUB_TOKEN" //nolint:gosec // GitHubURL Prefix for github URLs GitHubURL = "https://github.com/" )
Variables ¶
var MaxGithubRetries = 3
Functions ¶
Types ¶
type Client ¶
type Client interface { GetComment( ctx context.Context, owner, repo string, number int64, ) (*gogithub.IssueComment, *gogithub.Response, error) GetIssue( context.Context, string, string, int, ) (*gogithub.Issue, *gogithub.Response, error) GetPullRequest( context.Context, string, string, int, ) (*gogithub.PullRequest, *gogithub.Response, error) ListLabels( context.Context, string, string, *Options, ) ([]*gogithub.Label, error) AddLabel( context.Context, string, string, int, string, ) error RemoveLabel( context.Context, string, string, int, string, ) error MergePullRequest(context.Context, string, string, int) error ListPullRequestFiles( context.Context, string, string, int, *gogithub.ListOptions, ) ([]*gogithub.CommitFile, error) ListCheckRunsForRef( context.Context, string, string, string, *gogithub.ListCheckRunsOptions, ) (*gogithub.ListCheckRunsResults, error) GetIssueComments( context.Context, string, string, int, *gogithub.IssueListCommentsOptions, ) ([]*gogithub.IssueComment, error) GetAPIUser(ctx context.Context) (user *gogithub.User, err error) CreateComment( context.Context, string, string, int, string, ) (*gogithub.IssueComment, error) DeleteComment(context.Context, string, string, int64) (err error) }
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
GitHub is a wrapper around GitHub related functionality
func NewWithToken ¶
NewWithToken can be used to specify a GitHub token through parameters. Empty string will result in unauthenticated client, which makes unauthenticated requests.
func (*GitHub) CreateComment ¶
func (github *GitHub) CreateComment(ctx context.Context, slug string, number int, body string, ) (user *gogithub.IssueComment, err error)
CreatePRComment returns the authenticated user using the GH token
func (*GitHub) DeleteComment ¶
func (github *GitHub) DeleteComment(ctx context.Context, slug string, commentID int64, ) (err error)
CreatePRComment returns the authenticated user using the GH token
func (*GitHub) GetAPIUser ¶
GetAPIUser returns the authenticated user from the tken
func (*GitHub) GetComment ¶
func (*GitHub) GetIssue ¶
func (github *GitHub) GetIssue( ctx context.Context, owner, repo string, issueID int, ) (pr *gogithub.Issue, err error)
GetIssue retrieves an issue from GitHub
func (*GitHub) GetIssueComments ¶
func (github *GitHub) GetIssueComments(ctx context.Context, slug string, number int, ) (comments []*gogithub.IssueComment, err error)
GetIssueComments return the comments of an issue or pr
func (*GitHub) GetPullRequest ¶
func (github *GitHub) GetPullRequest( ctx context.Context, owner, repo string, prID int, ) (pr *gogithub.PullRequest, err error)
GetPullRequest retrieves a PR from GitHub
func (*GitHub) ListCheckRunsForRef ¶
func (*GitHub) ListLabels ¶
Lists the labels in a given repository
func (*GitHub) ListPullRequestFiles ¶
func (github *GitHub) ListPullRequestFiles(ctx context.Context, slug string, pr int, ) (files []*gogithub.CommitFile, err error)
ListPullRequestFiles returns a list of modified files in a pull request
func (*GitHub) MergePullRequest ¶
type Options ¶
type Options struct { // How many items to request in calls to the github API // that require pagination. ItemsPerPage int }
Options is a set of options to configure the behavior of the GitHub package
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions return an options struct with commonly used settings