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) 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) (*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) 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) 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) UploadReleaseAsset(owner, repo string, releaseID int64, fileName string) (*github.ReleaseAsset, error)
- type NewIssueOptions
- type Options
- type TagsPerBranch
Constants ¶
const ( // TokenEnvKey is the default GitHub token environemt variable key TokenEnvKey = "GITHUB_TOKEN" // GitHubURL Prefix for github URLs GitHubURL = "https://github.com/" )
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 ¶
func PrepareFork(branchName, upstreamOrg, upstreamRepo, myOrg, myRepo string) (repo *git.Repo, err error)
PrepareFork prepares a branch from a repo fork
func VerifyFork ¶
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.PullRequestListOptions, ) ([]*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, ) (*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) }
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 (*GitHub) BranchExists ¶
BranchExists checks if a branch exists in a given repo
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, ) (*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) 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 ¶
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) 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) UploadReleaseAsset ¶
func (g *GitHub) UploadReleaseAsset( owner, repo string, releaseID int64, fileName string, ) (*github.ReleaseAsset, error)
UploadReleaseAsset uploads a file onto the release assets
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 TagsPerBranch ¶
TagsPerBranch is an abstraction over a simple branch to latest tag association