Documentation
¶
Index ¶
- Constants
- func PrepareFork(branchName, upstreamOrg, upstreamRepo, myOrg, myRepo string, ...) (repo *git.Repo, err error)
- func VerifyFork(branchName, forkOwner, forkRepo, parentOwner, parentRepo string) error
- type Client
- type GitHub
- func (g *GitHub) BranchExists(owner, repo, branchname string) (isBranch bool, err error)
- func (g *GitHub) CheckRateLimit(ctx context.Context) (*github.RateLimits, *github.Response, error)
- func (g *GitHub) Client() Client
- func (g *GitHub) CreateIssue(owner, repo, title, body string, opts *NewIssueOptions) (*github.Issue, error)
- func (g *GitHub) CreatePullRequest(owner, repo, baseBranchName, headBranchName, title, body string, draft bool) (*github.PullRequest, error)
- func (g *GitHub) DeleteReleaseAsset(owner, repo string, assetID int64) error
- func (g *GitHub) DownloadReleaseAssets(owner, repo string, releaseTags []string, outputDir string) (finalErr error)
- func (g *GitHub) GetMilestone(owner, repo, title string) (ms *github.Milestone, exists bool, err error)
- func (g *GitHub) GetReleaseTags(owner, repo string, includePrereleases bool) ([]string, error)
- func (g *GitHub) GetRepository(owner, repo string) (*github.Repository, error)
- func (g *GitHub) LatestGitHubTagsPerBranch() (TagsPerBranch, error)
- func (g *GitHub) ListBranches(owner, repo string) ([]*github.Branch, error)
- func (g *GitHub) ListComments(owner, repo string, issueNumber int, sort Sort, direction SortDirection, ...) ([]*github.IssueComment, error)
- func (g *GitHub) ListIssues(owner, repo string, state IssueState) ([]*github.Issue, error)
- func (g *GitHub) ListReleaseAssets(owner, repo string, releaseID int64) ([]*github.ReleaseAsset, error)
- func (g *GitHub) ListTags(owner, repo string) ([]*github.RepositoryTag, error)
- func (g *GitHub) Options() *Options
- func (g *GitHub) Releases(owner, repo string, includePrereleases bool) ([]*github.RepositoryRelease, error)
- func (g *GitHub) RepoIsForkOf(forkOwner, forkRepo, parentOwner, parentRepo string) (bool, error)
- func (g *GitHub) RequestPullRequestReview(owner, repo string, prNumber int, reviewers, teamReviewers []string) (*github.PullRequest, error)
- func (g *GitHub) SetClient(client Client)
- func (g *GitHub) SetOptions(opts *Options)
- func (g *GitHub) TagExists(owner, repo, tag string) (exists bool, err error)
- func (g *GitHub) UpdateReleasePage(owner, repo string, releaseID int64, tag, commitish, name, body string, ...) (release *github.RepositoryRelease, err error)
- func (g *GitHub) UpdateReleasePageWithOptions(owner, repo string, releaseID int64, tag, commitish string, ...) (release *github.RepositoryRelease, err error)
- func (g *GitHub) UploadReleaseAsset(owner, repo string, releaseID int64, fileName string) (*github.ReleaseAsset, error)
- type IssueState
- type NewIssueOptions
- type Options
- type Sort
- type SortDirection
- type TagsPerBranch
- type UpdateReleasePageOptions
Constants ¶
const ( // TokenEnvKey is the default GitHub token environment variable key. TokenEnvKey = "GITHUB_TOKEN" // GitHubURL Prefix for github URLs. GitHubURL = "https://github.com/" )
const ( SortCreated Sort = "created" SortUpdated Sort = "updated" SortDirectionAscending SortDirection = "asc" SortDirectionDescending SortDirection = "desc" )
const ( // UserForkName is the name we will give to the user's remote when adding // it to repos. UserForkName = "userfork" )
Variables ¶
This section is empty.
Functions ¶
func PrepareFork ¶ added in v0.5.0
func PrepareFork(branchName, upstreamOrg, upstreamRepo, myOrg, myRepo string, useSSH, updateRepo bool, opts *gogit.CloneOptions) (repo *git.Repo, err error)
PrepareFork prepares a branch from a repo fork.
func VerifyFork ¶ added in v0.5.0
VerifyFork does a pre-check of a fork to see if we can create a PR from it.
Types ¶
type Client ¶
type Client interface { GetCommit( context.Context, string, string, string, ) (*github.Commit, *github.Response, error) GetPullRequest( context.Context, string, string, int, ) (*github.PullRequest, *github.Response, error) GetIssue( context.Context, string, string, int, ) (*github.Issue, *github.Response, error) GetRepoCommit( context.Context, string, string, string, ) (*github.RepositoryCommit, *github.Response, error) ListCommits( context.Context, string, string, *github.CommitsListOptions, ) ([]*github.RepositoryCommit, *github.Response, error) ListPullRequestsWithCommit( context.Context, string, string, string, *github.ListOptions, ) ([]*github.PullRequest, *github.Response, error) ListMilestones( context.Context, string, string, *github.MilestoneListOptions, ) ([]*github.Milestone, *github.Response, error) ListReleases( context.Context, string, string, *github.ListOptions, ) ([]*github.RepositoryRelease, *github.Response, error) GetReleaseByTag( context.Context, string, string, string, ) (*github.RepositoryRelease, *github.Response, error) DownloadReleaseAsset( context.Context, string, string, int64, ) (io.ReadCloser, string, error) ListTags( context.Context, string, string, *github.ListOptions, ) ([]*github.RepositoryTag, *github.Response, error) ListBranches( context.Context, string, string, *github.BranchListOptions, ) ([]*github.Branch, *github.Response, error) CreatePullRequest( context.Context, string, string, string, string, string, string, bool, ) (*github.PullRequest, error) CreateIssue( context.Context, string, string, *github.IssueRequest, ) (*github.Issue, error) GetRepository( context.Context, string, string, ) (*github.Repository, *github.Response, error) UpdateReleasePage( context.Context, string, string, int64, *github.RepositoryRelease, ) (*github.RepositoryRelease, error) UpdateIssue( context.Context, string, string, int, *github.IssueRequest, ) (*github.Issue, *github.Response, error) AddLabels( context.Context, string, string, int, []string, ) ([]*github.Label, *github.Response, error) UploadReleaseAsset( context.Context, string, string, int64, *github.UploadOptions, *os.File, ) (*github.ReleaseAsset, error) DeleteReleaseAsset( context.Context, string, string, int64, ) error ListReleaseAssets( context.Context, string, string, int64, *github.ListOptions, ) ([]*github.ReleaseAsset, error) CreateComment( context.Context, string, string, int, string, ) (*github.IssueComment, *github.Response, error) ListIssues( context.Context, string, string, *github.IssueListByRepoOptions, ) ([]*github.Issue, *github.Response, error) ListComments( context.Context, string, string, int, *github.IssueListCommentsOptions, ) ([]*github.IssueComment, *github.Response, error) RequestPullRequestReview( context.Context, string, string, int, []string, []string, ) (*github.PullRequest, error) CheckRateLimit( context.Context, ) (*github.RateLimits, *github.Response, error) }
Client is an interface modeling supported GitHub operations.
func NewRecorder ¶
func NewReplayer ¶
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
GitHub is a wrapper around GitHub related functionality.
func New ¶
func New() *GitHub
New creates a new default GitHub client. Tokens set via the $GITHUB_TOKEN environment variable will result in an authenticated client. If the $GITHUB_TOKEN is not set, then the client will do unauthenticated GitHub requests.
func NewEnterprise ¶
func NewEnterpriseWithToken ¶
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 NewWithTokenWithClient ¶ added in v0.11.1
NewWithTokenWithClient can be used to specify a GitHub token through parameters and set an custom HTTP Client. Empty string will result in unauthenticated client, which makes unauthenticated requests.
func (*GitHub) BranchExists ¶
BranchExists checks if a branch exists in a given repo.
func (*GitHub) CheckRateLimit ¶ added in v0.11.1
RateLimit returns the rate limits for the current client.
func (*GitHub) CreateIssue ¶
func (g *GitHub) CreateIssue( owner, repo, title, body string, opts *NewIssueOptions, ) (*github.Issue, error)
CreateIssue files a new issue in the specified respoitory.
func (*GitHub) CreatePullRequest ¶
func (g *GitHub) CreatePullRequest( owner, repo, baseBranchName, headBranchName, title, body string, draft bool, ) (*github.PullRequest, error)
CreatePullRequest Creates a new pull request in owner/repo:baseBranch to merge changes from headBranchName which is a string containing a branch in the same repository or a user:branch pair.
func (*GitHub) DeleteReleaseAsset ¶
DeleteReleaseAsset deletes an asset from a release.
func (*GitHub) DownloadReleaseAssets ¶
func (g *GitHub) DownloadReleaseAssets(owner, repo string, releaseTags []string, outputDir string) (finalErr error)
DownloadReleaseAssets downloads a set of GitHub release assets to an `outputDir`. Assets to download are derived from the `releaseTags`.
func (*GitHub) GetMilestone ¶
func (g *GitHub) GetMilestone(owner, repo, title string) ( ms *github.Milestone, exists bool, err error, )
GetMilestone returns a milestone object from its string name.
func (*GitHub) GetReleaseTags ¶
GetReleaseTags returns a list of GitHub release tags for the provided `owner` and `repo`. If `includePrereleases` is `true`, then the resulting slice will also contain pre/drafted releases.
func (*GitHub) GetRepository ¶
func (g *GitHub) GetRepository( owner, repo string, ) (*github.Repository, error)
GetRepository gets a repository using the current client.
func (*GitHub) LatestGitHubTagsPerBranch ¶
func (g *GitHub) LatestGitHubTagsPerBranch() (TagsPerBranch, error)
LatestGitHubTagsPerBranch returns the latest GitHub available tag for each branch. The logic how releases are associates with branches is motivated by the changelog generation and bound to the default Kubernetes release strategy, which is also the reason why we do not provide a repo and org parameter here.
Releases are associated in the following way: - x.y.0-alpha.z releases are only associated with the main branch - x.y.0-beta.z releases are only associated with their release-x.y branch - x.y.0 final releases are associated with the main branch and the release-x.y branch.
func (*GitHub) ListBranches ¶
ListBranches gets a repository using the current client.
func (*GitHub) ListComments ¶ added in v0.10.0
func (g *GitHub) ListComments( owner, repo string, issueNumber int, sort Sort, direction SortDirection, since *time.Time, ) ([]*github.IssueComment, error)
ListComments lists all comments on the specified issue. Specifying an issue number of 0 will return all comments on all issues for the repository.
GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments-for-a-repository
func (*GitHub) ListIssues ¶ added in v0.9.5
ListIssues gets the issues from a GitHub repository. State filters issues based on their state. Possible values are: open, closed, all. Default is "open".
func (*GitHub) ListReleaseAssets ¶
func (g *GitHub) ListReleaseAssets( owner, repo string, releaseID int64, ) ([]*github.ReleaseAsset, error)
ListReleaseAssets gets the assets uploaded to a GitHub release.
func (*GitHub) ListTags ¶ added in v0.6.0
func (g *GitHub) ListTags(owner, repo string) ([]*github.RepositoryTag, error)
ListTags gets the tags from a GitHub repository.
func (*GitHub) Releases ¶
func (g *GitHub) Releases(owner, repo string, includePrereleases bool) ([]*github.RepositoryRelease, error)
Releases returns a list of GitHub releases for the provided `owner` and `repo`. If `includePrereleases` is `true`, then the resulting slice will also contain pre/drafted releases. TODO: Create a more descriptive method name and update references.
func (*GitHub) RepoIsForkOf ¶
RepoIsForkOf Function that checks if a repository is a fork of another.
func (*GitHub) RequestPullRequestReview ¶ added in v0.11.0
func (*GitHub) SetOptions ¶
SetOptions gets an options set for the GitHub object.
func (*GitHub) UpdateReleasePage ¶
func (g *GitHub) UpdateReleasePage( owner, repo string, releaseID int64, tag, commitish, name, body string, isDraft, isPrerelease bool, ) (release *github.RepositoryRelease, err error)
UpdateReleasePage updates a release page in GitHub.
func (*GitHub) UpdateReleasePageWithOptions ¶ added in v0.11.0
func (g *GitHub) UpdateReleasePageWithOptions(owner, repo string, releaseID int64, tag, commitish string, opts *UpdateReleasePageOptions, ) (release *github.RepositoryRelease, err error)
UpdateReleasePageWithOptions updates release pages (same as UpdateReleasePage), but does so by taking a UpdateReleasePageOptions parameter. It will _not_ set a release as latest unless the corresponding option is set.
func (*GitHub) UploadReleaseAsset ¶
func (g *GitHub) UploadReleaseAsset( owner, repo string, releaseID int64, fileName string, ) (*github.ReleaseAsset, error)
UploadReleaseAsset uploads a file onto the release assets.
type IssueState ¶ added in v0.9.5
type IssueState string
IssueState is the enum for all available issue states.
const ( // IssueStateAll can be used to list all issues. IssueStateAll IssueState = "all" // IssueStateOpen can be used to list only open issues. IssueStateOpen IssueState = "open" // IssueStateClosed can be used to list only closed issues. IssueStateClosed IssueState = "closed" )
type NewIssueOptions ¶
type NewIssueOptions struct { Milestone string // Name of milestone to set State string // open, closed or all. Defaults to "open" Assignees []string // List of GitHub handles of extra assignees, must be collaborators Labels []string // List of labels to apply. They will be created if new }
NewIssueOptions is a struct of optional fields for new issues.
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 ¶
type Sort ¶ added in v0.10.0
type Sort string
Sort specifies how to sort comments. Possible values are: created, updated.
type SortDirection ¶ added in v0.10.0
type SortDirection string
SortDirection in which to sort comments. Possible values are: asc, desc.
type TagsPerBranch ¶
TagsPerBranch is an abstraction over a simple branch to latest tag association.
type UpdateReleasePageOptions ¶ added in v0.11.0
type UpdateReleasePageOptions struct { // Name is the name/title of the release. Name *string // Body is the body/content of the release (e.g. release notes). Body *string // Draft is marking the release as draft, if set to true. Draft *bool // Prerelease is marking the release as a pre-release, if set to true. Prerelease *bool // Latest is marking the release to be set as latest at the time of updating, if set to true. Latest *bool }
UpdateReleasePageOptions is a struct of optional fields for creating/updating releases.