Documentation ¶
Index ¶
- func GetLabelsWithPrefix(labels []github.Label, prefix string) []string
- func HasLabel(labels []github.Label, name string) bool
- func HasLabels(labels []github.Label, names []string) bool
- type GithubConfig
- func (config *GithubConfig) AddLabels(prNum int, labels []string) error
- func (config *GithubConfig) AddRootFlags(cmd *cobra.Command)
- func (config *GithubConfig) AssignPR(prNum int, owner string) error
- func (config *GithubConfig) ClosePR(pr *github.PullRequest) error
- func (config *GithubConfig) ForEachIssueDo(labels []string, fn IssueFunction) error
- func (config *GithubConfig) ForEachPRDo(labels []string, fn PRFunction) error
- func (config *GithubConfig) GetAllEventsForPR(prNum int) ([]github.IssueEvent, error)
- func (config *GithubConfig) GetFileContents(file, sha string) (string, error)
- func (config *GithubConfig) GetFilledCommits(prNum int) ([]github.RepositoryCommit, error)
- func (config *GithubConfig) GetPR(prNum int) (*github.PullRequest, error)
- func (config *GithubConfig) GetStatus(pr *github.PullRequest, requiredContexts []string) (string, error)
- func (config *GithubConfig) IsPRMergeable(pr *github.PullRequest) (bool, error)
- func (config *GithubConfig) IsStatusSuccess(pr *github.PullRequest, requiredContexts []string) bool
- func (config *GithubConfig) LastModifiedTime(prNum int) (*time.Time, error)
- func (config *GithubConfig) MergePR(prNum int, who string) error
- func (config *GithubConfig) OpenPR(pr *github.PullRequest, numTries int) error
- func (config *GithubConfig) PreExecute() error
- func (config *GithubConfig) RemoveLabel(prNum int, label string) error
- func (config *GithubConfig) ResetAPICount()
- func (config *GithubConfig) SetClient(client *github.Client)
- func (config *GithubConfig) UsersWithAccess() (pushUsers sets.String, pullUsers sets.String, err error)
- func (config *GithubConfig) WaitForNotPending(pr *github.PullRequest) error
- func (config *GithubConfig) WaitForPending(pr *github.PullRequest) error
- func (config *GithubConfig) WriteComment(prNum int, msg string) error
- type IssueFunction
- type PRFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLabelsWithPrefix ¶
GetLabelsWithPrefix will return a slice of all label names in `labels` which start with given prefix.
Types ¶
type GithubConfig ¶
type GithubConfig struct { Org string Project string RateLimit float32 RateLimitBurst int Token string TokenFile string MinPRNumber int MaxPRNumber int // If true, don't make any mutating API calls DryRun bool // contains filtered or unexported fields }
GithubConfig is how we are configured to talk to github and provides access methods for doing so.
func (*GithubConfig) AddLabels ¶
func (config *GithubConfig) AddLabels(prNum int, labels []string) error
AddLabels will add all of the named `labels` to the PR
func (*GithubConfig) AddRootFlags ¶
func (config *GithubConfig) AddRootFlags(cmd *cobra.Command)
AddRootFlags will add all of the flags needed for the github config to the cobra command
func (*GithubConfig) AssignPR ¶
func (config *GithubConfig) AssignPR(prNum int, owner string) error
AssignPR will assign `prNum` to the `owner` where the `owner` is asignee's github login
func (*GithubConfig) ClosePR ¶
func (config *GithubConfig) ClosePR(pr *github.PullRequest) error
ClosePR will close the Given PR
func (*GithubConfig) ForEachIssueDo ¶
func (config *GithubConfig) ForEachIssueDo(labels []string, fn IssueFunction) error
ForEachIssueDo will call the provided IssueFunction once for each issue which has the labels provided in `labels`
func (*GithubConfig) ForEachPRDo ¶
func (config *GithubConfig) ForEachPRDo(labels []string, fn PRFunction) error
ForEachPRDo will call the provided PRFunction once for each issue which has the labels provided in `labels`
func (*GithubConfig) GetAllEventsForPR ¶
func (config *GithubConfig) GetAllEventsForPR(prNum int) ([]github.IssueEvent, error)
GetAllEventsForPR returns a list of all events for a given pr.
func (*GithubConfig) GetFileContents ¶
func (config *GithubConfig) GetFileContents(file, sha string) (string, error)
GetFileContents will return the contents of the `file` in the repo at `sha` as a string
func (*GithubConfig) GetFilledCommits ¶
func (config *GithubConfig) GetFilledCommits(prNum int) ([]github.RepositoryCommit, error)
GetFilledCommits returns all of the commits for a given PR
func (*GithubConfig) GetPR ¶
func (config *GithubConfig) GetPR(prNum int) (*github.PullRequest, error)
GetPR will return a pull request based on the provided number. This may be useful if some of the information in the provided PR was not filled out when it was retrieved.
func (*GithubConfig) GetStatus ¶
func (config *GithubConfig) GetStatus(pr *github.PullRequest, requiredContexts []string) (string, error)
GetStatus gets the current status of a PR.
- If any member of the 'requiredContexts' list is missing, it is 'incomplete'
- If any is 'pending', the PR is 'pending'
- If any is 'error', the PR is in 'error'
- If any is 'failure', the PR is 'failure'
- Otherwise the PR is 'success'
func (*GithubConfig) IsPRMergeable ¶
func (config *GithubConfig) IsPRMergeable(pr *github.PullRequest) (bool, error)
IsPRMergeable will return if the PR is mergeable. It will pause and get the PR again if github did not respond the first time. So the hopefully github will have a response the second time. If we have no answer twice, we return false
func (*GithubConfig) IsStatusSuccess ¶
func (config *GithubConfig) IsStatusSuccess(pr *github.PullRequest, requiredContexts []string) bool
IsStatusSuccess makes sure that the combined status for all commits in a PR is 'success'
func (*GithubConfig) LastModifiedTime ¶
func (config *GithubConfig) LastModifiedTime(prNum int) (*time.Time, error)
LastModifiedTime returns the time the last commit was made BUG: this should probably return the last time a git push happened or something like that.
func (*GithubConfig) MergePR ¶
func (config *GithubConfig) MergePR(prNum int, who string) error
MergePR will merge the given PR, duh "who" is who is doing the merging, like "submit-queue"
func (*GithubConfig) OpenPR ¶
func (config *GithubConfig) OpenPR(pr *github.PullRequest, numTries int) error
OpenPR will attempt to open the given PR. If will attempt to reopen the pr `numTries` before returning an error and giving up.
func (*GithubConfig) PreExecute ¶
func (config *GithubConfig) PreExecute() error
PreExecute will initialize the GithubConfig. It MUST be run before the config may be used to get information from Github
func (*GithubConfig) RemoveLabel ¶
func (config *GithubConfig) RemoveLabel(prNum int, label string) error
RemoveLabel will remove the `label` from the PR
func (*GithubConfig) ResetAPICount ¶
func (config *GithubConfig) ResetAPICount()
ResetAPICount will both reset the counters of how many api calls have been made but will also print the information from the last run.
func (*GithubConfig) SetClient ¶
func (config *GithubConfig) SetClient(client *github.Client)
SetClient should ONLY be used by testing. Normal commands should use PreExecute()
func (*GithubConfig) UsersWithAccess ¶
func (config *GithubConfig) UsersWithAccess() (pushUsers sets.String, pullUsers sets.String, err error)
UsersWithAccess returns two sets of users. The first set are users with push access. The second set is the specific set of user with pull access. If the repo is public all users will have pull access, but some with have it explicitly
func (*GithubConfig) WaitForNotPending ¶
func (config *GithubConfig) WaitForNotPending(pr *github.PullRequest) error
WaitForNotPending will check if the github status is "pending" (CI still running) if so it will sleep and try again until all status hooks have complete
func (*GithubConfig) WaitForPending ¶
func (config *GithubConfig) WaitForPending(pr *github.PullRequest) error
WaitForPending will wait for a PR to move into Pending. This is useful because the request to test a PR again is asynchronous with the PR actually moving into a pending state TODO: add a timeout
func (*GithubConfig) WriteComment ¶
func (config *GithubConfig) WriteComment(prNum int, msg string) error
WriteComment will send the `msg` as a comment to the specified PR
type IssueFunction ¶
IssueFunction is the type that must be implemented and passed to ForEachIssueDo
type PRFunction ¶
type PRFunction func(*github.PullRequest, *github.Issue) error
PRFunction is the type that must be implemented and passed to ForEachPRDo