{"modulePath":"github.com/abayer/test-infra","version":"v0.0.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Functions\n\n```go\nfunc DescribeUser(u *github.User) string\n```\nDescribeUser returns the Login string, which may be nil.\n\n```go\nfunc GetLabelsWithPrefix(labels []github.Label, prefix string) []string\n```\nGetLabelsWithPrefix will return a slice of all label names in \\`labels\\` which start with given prefix.\n\n```go\nfunc SetCombinedStatusLifetime(lifetime time.Duration)\n```\nSetCombinedStatusLifetime will set the lifetime of CombinedStatus responses. Even though we would likely use conditional API calls hitting the CombinedStatus API every time we want to get a specific value is just too mean to github. This defaults to \\`combinedStatusLifetime\\` seconds. If you are doing local testing you may want to make this (much) shorter\n\n## Types\n\n```go\ntype Config struct {\n\n\t// BotName is the login for the authenticated user\n\tBotName string\n\n\tOrg     string\n\tProject string\n\tUrl     string\n\n\t// Filters used when munging issues\n\tState  string\n\tLabels []string\n\n\tHTTPCacheDir  string\n\tHTTPCacheSize uint64\n\n\tMinPRNumber int\n\tMaxPRNumber int\n\n\t// If true, don't make any mutating API calls\n\tDryRun bool\n\n\t// Base sleep time for retry loops. Defaults to 1 second.\n\tBaseWaitTime time.Duration\n\n\t// Webhook configuration\n\tHookHandler *WebHook\n\t// contains filtered or unexported fields\n}\n```\nConfig is how we are configured to talk to github and provides access methods for doing so.\n\n```go\nfunc (config *Config) AddLabel(label *github.Label) error\n```\nAddLabel adds a single github label to the repository.\n\n```go\nfunc (config *Config) Collaborators() (sets.String, error)\n```\nCollaborators is a set of all logins who can be listed as assignees, reviewers or approvers for issues and pull requests in this repo\n\n```go\nfunc (config *Config) ForEachIssueDo(fn MungeFunction) error\n```\nForEachIssueDo will run for each Issue in the project that matches:\n\n  - pr.Number \u003e= minPRNumber\n  - pr.Number \\\u003c= maxPRNumber\n\n```go\nfunc (config *Config) GetBranchCommits(branch string, limit int) ([]*github.RepositoryCommit, error)\n```\nGetBranchCommits gets recent commits for the given branch.\n\n```go\nfunc (config *Config) GetDebugStats() DebugStats\n```\nGetDebugStats returns information about the bot iself. Things like how many API calls has it made, how many of each type, etc.\n\n```go\nfunc (config *Config) GetLabels() ([]*github.Label, error)\n```\nGetLabels grabs all labels from a particular repository so you don't have to worry about paging.\n\n```go\nfunc (config *Config) GetObject(num int) (*MungeObject, error)\n```\nGetObject will return an object (with only the issue filled in)\n\n```go\nfunc (config *Config) GetTokenUsage() int\n```\nGetTokenUsage returns the api token usage of the current github user.\n\n```go\nfunc (config *Config) GetUser(login string) (*github.User, error)\n```\nGetUser will return information about the github user with the given login name\n\n```go\nfunc (config *Config) ListAllIssues(listOpts *github.IssueListByRepoOptions) ([]*github.Issue, error)\n```\nListAllIssues grabs all issues matching the options, so you don't have to worry about paging. Enforces some constraints, like min/max PR number and having a valid user.\n\n```go\nfunc (config *Config) ListMilestones(state string) ([]*github.Milestone, bool)\n```\nListMilestones will return all milestones of the given \\`state\\`\n\n```go\nfunc (config *Config) NewIssue(title, body string, labels []string, owners []string) (*MungeObject, error)\n```\nNewIssue will file a new issue and return an object for it. If \"owners\" is not empty, the issue will be assigned to the owners.\n\n```go\nfunc (config *Config) NextExpectedUpdate(t time.Time)\n```\nNextExpectedUpdate will set the debug information concerning when the mungers are likely to run again.\n\n```go\nfunc (config *Config) PreExecute() error\n```\nPreExecute will initialize the Config. It MUST be run before the config may be used to get information from Github.\n\n```go\nfunc (config *Config) RegisterOptions(opts *options.Options) sets.String\n```\nRegisterOptions registers options for the github client and returns any that require a restart if they are changed.\n\n```go\nfunc (config *Config) ResetAPICount()\n```\nResetAPICount will both reset the counters of how many api calls have been made but will also print the information from the last run.\n\n```go\nfunc (config *Config) ServeDebugStats(path string)\n```\nServeDebugStats will serve out debug information at the path\n\n```go\nfunc (config *Config) SetBranchProtection(name string, contexts []string) error\n```\nSetBranchProtection protects a branch and sets the required contexts\n\n```go\nfunc (config *Config) SetClient(client *github.Client)\n```\nSetClient should ONLY be used by testing. Normal commands should use PreExecute()\n\n```go\nfunc (config *Config) Token() string\n```\nToken returns the token.\n\n```go\nfunc (config *Config) UsersWithAccess() ([]*github.User, []*github.User, error)\n```\nUsersWithAccess 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\n\n```go\ntype DebugStats struct {\n\tAnalytics      analytics\n\tAPIPerSec      float64\n\tAPICount       int\n\tCachedAPICount int\n\tNextLoopTime   time.Time\n\tLimitRemaining int\n\tLimitResetTime time.Time\n}\n```\nDebugStats is a structure that tells information about how we have interacted with github\n\n```go\ntype HTTPHandlerInstaller interface {\n\tHandle(pattern string, handler http.Handler)\n}\n```\nHTTPHandlerInstaller is anything that can hook up HTTP requests to handlers.\n\n```go\ntype MungeFunction func(*MungeObject) error\n```\nMungeFunction is the type that must be implemented and passed to ForEachIssueDo\n\n```go\ntype MungeObject struct {\n\tIssue *github.Issue\n\n\tAnnotations map[string]string //annotations are things you can set yourself.\n\t// contains filtered or unexported fields\n}\n```\nMungeObject is the object that mungers deal with. It is a combination of different github API objects.\n\n```go\nfunc NewTestObject(config *Config, issue *github.Issue, pr *github.PullRequest, commits []*github.RepositoryCommit, events []*github.IssueEvent) *MungeObject\n```\nNewTestObject should NEVER be used outside of \\_test.go code. It creates a MungeObject with the given fields. Normally these should be filled in lazily as needed\n\n```go\nfunc (obj *MungeObject) AddAssignee(owner string) error\n```\nAddAssignee will assign \\`prNum\\` to the \\`owner\\` where the \\`owner\\` is asignee's github login\n\n```go\nfunc (obj *MungeObject) AddLabel(label string) error\n```\nAddLabel adds a single \\`label\\` to the issue\n\n```go\nfunc (obj *MungeObject) AddLabels(labels []string) error\n```\nAddLabels will add all of the named \\`labels\\` to the issue\n\n```go\nfunc (obj *MungeObject) Branch() (string, bool)\n```\nBranch returns the branch the PR is for. Return \"\" if this is not a PR or it does not have the required information.\n\n```go\nfunc (obj *MungeObject) ClearMilestone() bool\n```\nClearMilestone will remove a milestone if present\n\n```go\nfunc (obj *MungeObject) CloseIssuef(format string, args ...interface{}) error\n```\nCloseIssuef will close the given issue with a message\n\n```go\nfunc (obj *MungeObject) ClosePR() bool\n```\nClosePR will close the Given PR\n\n```go\nfunc (obj *MungeObject) CollectGHReviewStatus() ([]*github.PullRequestReview, []*github.PullRequestReview, bool)\n```\n\n```go\nfunc (obj *MungeObject) Config() *Config\n```\nConfig is a getter for obj.config.\n\n```go\nfunc (obj *MungeObject) DeleteComment(comment *github.IssueComment) error\n```\nDeleteComment will remove the specified comment\n\n```go\nfunc (obj *MungeObject) EditComment(comment *github.IssueComment, body string) error\n```\nEditComment will change the specified comment's body.\n\n```go\nfunc (obj *MungeObject) FirstLabelTime(label string) *time.Time\n```\nFirstLabelTime returns the first time the request label was added to an issue. If the label was never added you will get a nil time.\n\n```go\nfunc (obj *MungeObject) GetCommits() ([]*github.RepositoryCommit, bool)\n```\nGetCommits returns all of the commits for a given PR\n\n```go\nfunc (obj *MungeObject) GetEvents() ([]*github.IssueEvent, bool)\n```\nGetEvents returns a list of all events for a given pr.\n\n```go\nfunc (obj *MungeObject) GetFileContents(file, sha string) (string, error)\n```\nGetFileContents will return the contents of the \\`file\\` in the repo at \\`sha\\` as a string\n\n```go\nfunc (obj *MungeObject) GetHeadAndBase() (headSHA, baseRef string, ok bool)\n```\nGetHeadAndBase returns the head SHA and the base ref, so that you can get the base's sha in a second step. Purpose: if head and base SHA are the same across two merge attempts, we don't need to rerun tests.\n\n```go\nfunc (obj *MungeObject) GetPR() (*github.PullRequest, bool)\n```\nGetPR will return the PR of the object.\n\n```go\nfunc (obj *MungeObject) GetPRFixesList() []int\n```\nGetPRFixesList returns a list of issue numbers that are referenced in the PR body.\n\n```go\nfunc (obj *MungeObject) GetSHAFromRef(ref string) (sha string, ok bool)\n```\nGetSHAFromRef returns the current SHA of the given ref (i.e., branch).\n\n```go\nfunc (obj *MungeObject) GetStatus(context string) (*github.RepoStatus, bool)\n```\nGetStatus returns the actual requested status, or nil if not found\n\n```go\nfunc (obj *MungeObject) GetStatusState(requiredContexts []string) (string, bool)\n```\nGetStatusState gets the current status of a PR.\n\n  - If any member of the 'requiredContexts' list is missing, it is 'incomplete'\n  - If any is 'pending', the PR is 'pending'\n  - If any is 'error', the PR is in 'error'\n  - If any is 'failure', the PR is 'failure'\n  - Otherwise the PR is 'success'\n\n```go\nfunc (obj *MungeObject) GetStatusTime(context string) (*time.Time, bool)\n```\nGetStatusTime returns when the status was set\n\n```go\nfunc (obj *MungeObject) HasLabel(name string) bool\n```\nHasLabel returns if the label \\`name\\` is in the array of \\`labels\\`\n\n```go\nfunc (obj *MungeObject) HasLabels(names []string) bool\n```\nHasLabels returns if all of the label \\`names\\` are in the array of \\`labels\\`\n\n```go\nfunc (obj *MungeObject) IsForBranch(branch string) (bool, bool)\n```\nIsForBranch return true if the object is a PR for a branch with the given name. It return false if it is not a pr, it isn't against the given branch, or we can't tell\n\n```go\nfunc (obj *MungeObject) IsMergeable() (bool, bool)\n```\nIsMergeable 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\n\n```go\nfunc (obj *MungeObject) IsMerged() (bool, bool)\n```\nIsMerged returns if the issue in question was already merged\n\n```go\nfunc (obj *MungeObject) IsPR() bool\n```\nIsPR returns if the obj is a PR or an Issue.\n\n```go\nfunc (obj *MungeObject) IsRobot(user *github.User) bool\n```\nIsRobot determines if the user is the robot running the munger\n\n```go\nfunc (obj *MungeObject) IsStatusSuccess(requiredContexts []string) (bool, bool)\n```\nIsStatusSuccess makes sure that the combined status for all commits in a PR is 'success'\n\n```go\nfunc (obj *MungeObject) LabelCreator(label string) (*github.User, bool)\n```\nLabelCreator returns the user who (last) created the given label\n\n```go\nfunc (obj *MungeObject) LabelSet() sets.String\n```\nLabelSet returns the name of all of the labels applied to the object as a kubernetes string set.\n\n```go\nfunc (obj *MungeObject) LabelTime(label string) (*time.Time, bool)\n```\nLabelTime returns the last time the request label was added to an issue. If the label was never added you will get a nil time.\n\n```go\nfunc (obj *MungeObject) LastModifiedTime() (*time.Time, bool)\n```\nLastModifiedTime returns the time the last commit was made BUG: this should probably return the last time a git push happened or something like that.\n\n```go\nfunc (obj *MungeObject) ListComments() ([]*github.IssueComment, bool)\n```\nListComments returns all comments for the issue/PR in question\n\n```go\nfunc (obj *MungeObject) ListFiles() ([]*github.CommitFile, bool)\n```\nListFiles returns all changed files in a pull-request\n\n```go\nfunc (obj *MungeObject) ListReviewComments() ([]*github.PullRequestComment, bool)\n```\nListReviewComments returns all review (diff) comments for the PR in question\n\n```go\nfunc (obj *MungeObject) ListReviews() ([]*github.PullRequestReview, bool)\n```\nListReviews returns a list of the Pull Request Reviews on a PR.\n\n```go\nfunc (obj *MungeObject) MergeCommit() (*string, bool)\n```\nMergeCommit will return the sha of the merge. PRs which have not merged (or if we hit an error) will return nil\n\n```go\nfunc (obj *MungeObject) MergePR(who string) bool\n```\nMergePR will merge the given PR, duh \"who\" is who is doing the merging, like \"submit-queue\"\n\n```go\nfunc (obj *MungeObject) MergedAt() (*time.Time, bool)\n```\nMergedAt returns the time an issue was merged (for nil if unmerged)\n\n```go\nfunc (obj *MungeObject) ModifiedAfterLabeled(label string) (after bool, ok bool)\n```\nModifiedAfterLabeled returns true if the PR was updated after the last time the label was applied.\n\n```go\nfunc (obj *MungeObject) Number() int\n```\nNumber is short for \\*obj.Issue.Number.\n\n```go\nfunc (obj *MungeObject) OpenPR(numTries int) bool\n```\nOpenPR will attempt to open the given PR. It will attempt to reopen the pr \\`numTries\\` before returning an error and giving up.\n\n```go\nfunc (obj *MungeObject) Org() string\n```\nOrg is getter for obj.config.Org.\n\n```go\nfunc (obj *MungeObject) Priority() int\n```\nPriority returns the priority an issue was labeled with. The labels must take the form 'priority/\\[pP]\\[0-9]+' or math.MaxInt32 if unset\n\nIf a PR has both priority/p0 and priority/p1 it will be considered a p0.\n\n```go\nfunc (obj *MungeObject) Project() string\n```\nProject is getter for obj.config.Project.\n\n```go\nfunc (obj *MungeObject) Refresh() bool\n```\nRefresh will refresh the Issue (and PR if this is a PR) (not the commits or events)\n\n```go\nfunc (obj *MungeObject) ReleaseMilestone() (string, bool)\n```\nReleaseMilestone returns the name of the 'release' milestone or an empty string if none found. Release milestones are determined by the format \"vX.Y\"\n\n```go\nfunc (obj *MungeObject) ReleaseMilestoneDue() (time.Time, bool)\n```\nReleaseMilestoneDue returns the due date for a milestone. It ONLY looks at milestones of the form 'vX.Y' where X and Y are integeters. Return the maximum possible time if there is no milestone or the milestone doesn't look like a release milestone\n\n```go\nfunc (obj *MungeObject) RemoveAssignees(assignees ...string) error\n```\nRemoveAssignees removes the passed-in assignees from the github PR's assignees list\n\n```go\nfunc (obj *MungeObject) RemoveLabel(label string) error\n```\nRemoveLabel will remove the \\`label\\` from the PR\n\n```go\nfunc (obj *MungeObject) SetMilestone(title string) bool\n```\nSetMilestone will set the milestone to the value specified\n\n```go\nfunc (obj *MungeObject) SetStatus(state, url, description, statusContext string) bool\n```\nSetStatus allowes you to set the Github Status\n\n```go\nfunc (obj *MungeObject) WaitForNotPending(requiredContexts []string, prMaxWaitTime time.Duration) bool\n```\nWaitForNotPending will check if the github status is \"pending\" (CI still running) if so it will sleep and try again until all required status hooks have complete returns true if it completed and false if it timed out\n\n```go\nfunc (obj *MungeObject) WaitForPending(requiredContexts []string, prMaxWaitTime time.Duration) bool\n```\nWaitForPending 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 returns true if it completed and false if it timed out\n\n```go\nfunc (obj *MungeObject) WriteComment(msg string) error\n```\nWriteComment will send the \\`msg\\` as a comment to the specified PR\n\n```go\ntype StatusChange struct {\n\t// contains filtered or unexported fields\n}\n```\nStatusChange keeps track of issue/commit for status changes\n\n```go\nfunc NewStatusChange() *StatusChange\n```\nNewStatusChange creates a new status change tracker\n\n```go\nfunc (s *StatusChange) CommitStatusChanged(commit string)\n```\nCommitStatusChanged must be called when the status for this commit has changed\n\n```go\nfunc (s *StatusChange) PopChangedPullRequests() []int\n```\nPopChangedPullRequests returns the list of issues changed since last call\n\n```go\nfunc (s *StatusChange) UpdatePullRequestHead(pullRequestID int, newHead string)\n```\nUpdatePullRequestHead updates the head commit for a pull-request\n\n```go\ntype WebHook struct {\n\tGithubKey string `json:\"-\"`\n\tStatus    *StatusChange\n}\n```\nWebHook listen for events and list changed issues asynchronously\n\n```go\nfunc NewWebHookAndListen(githubKeyFile string, server HTTPHandlerInstaller) *WebHook\n```\nNewWebHookAndListen creates a new WebHook and listen to it\n\n```go\nfunc (webhook *WebHook) PopIssues() []int\n```\nPopIssues returns the list of issues that changed since last time it was called\n\n```go\nfunc (webhook WebHook) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP receives the webhook, and process it\n\n```go\nfunc (webhook *WebHook) UpdatePullRequest(id int, head string)\n```\nUpdatePullRequest will add the pull-request's last commit\n\n```go\ntype WithListOpt func(*github.IssueListCommentsOptions) *github.IssueListCommentsOptions\n```\nWithListOpt configures the options to list comments of github issue.\n\n","path":"github.com/abayer/test-infra/mungegithub/github","name":"github","synopsis":"","isRedistributable":true}
