github

package
v0.0.0-...-660dcec Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var MaxGithubRetries = 3

Functions

func ParseSlug

func ParseSlug(slug string) (org, repo string)

ParseSlug splits a repo slug (org/repo) into org + repo strings

Types

type Client

type GitHub

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

GitHub is a wrapper around GitHub related functionality

func New

func New() *GitHub

func NewWithToken

func NewWithToken(token string) (*GitHub, error)

NewWithToken can be used to specify a GitHub token through parameters. Empty string will result in unauthenticated client, which makes unauthenticated requests.

func (*GitHub) AddLabel

func (github *GitHub) AddLabel(owner, repo string, issue int, label string) error

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

func (github *GitHub) GetAPIUser(ctx context.Context) (user *gogithub.User, err error)

GetAPIUser returns the authenticated user from the tken

func (*GitHub) GetComment

func (github *GitHub) GetComment(owner, repo string, commentID int64) (comment *gogithub.IssueComment, err error)

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 *GitHub) ListCheckRunsForRef(
	ctx context.Context, slug, ref string,
) (*gogithub.ListCheckRunsResults, error)

func (*GitHub) ListLabels

func (github *GitHub) ListLabels(owner, repo string) ([]*gogithub.Label, error)

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

func (github *GitHub) MergePullRequest(ctx context.Context, owner, repo string, number int) error

func (*GitHub) RemoveLabel

func (github *GitHub) RemoveLabel(owner, repo string, issue int, label string) error

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

func (*Options) GetItemsPerPage

func (o *Options) GetItemsPerPage() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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