Documentation ¶
Index ¶
- Constants
- Variables
- func HasLabel(label string, issueLabels []*scm.Label) bool
- func ImageTooBig(url string) (bool, error)
- func PushHookBranch(pe *scm.PushHook) string
- type Client
- func (c *Client) AddLabel(owner, repo string, number int, label string, pr bool) error
- func (c *Client) AssignIssue(owner, repo string, number int, logins []string) error
- func (c *Client) BotName() (string, error)
- func (c *Client) ClearMilestone(org, repo string, num int) error
- func (c *Client) CloseIssue(owner, repo string, number int) error
- func (c *Client) ClosePR(owner, repo string, number int) error
- func (c *Client) CreateComment(owner, repo string, number int, pr bool, comment string) error
- func (c *Client) CreateGraphQLStatus(owner, repo, ref string, s *Status) (*scm.Status, error)
- func (c *Client) CreateStatus(owner, repo, ref string, s *scm.StatusInput) (*scm.Status, error)
- func (c *Client) DeleteComment(org, repo string, number, ID int, pr bool) error
- func (c *Client) DeleteRef(owner, repo, ref string) error
- func (c *Client) DeleteStaleComments(org, repo string, number int, comments []*scm.Comment, pr bool, ...) error
- func (c *Client) EditComment(owner, repo string, number int, id int, comment string, pr bool) error
- func (c *Client) FindIssues(query, sort string, asc bool) ([]scm.Issue, error)
- func (c *Client) GetCombinedStatus(owner, repo, ref string) (*scm.CombinedStatus, error)
- func (c *Client) GetFile(owner, repo, filepath, commit string) ([]byte, error)
- func (c *Client) GetIssueLabels(org, repo string, number int, pr bool) ([]*scm.Label, error)
- func (c *Client) GetPullRequest(owner, repo string, number int) (*scm.PullRequest, error)
- func (c *Client) GetPullRequestChanges(org, repo string, number int) ([]*scm.Change, error)
- func (c *Client) GetRef(owner, repo, ref string) (string, error)
- func (c *Client) GetRepoLabels(owner, repo string) ([]*scm.Label, error)
- func (c *Client) GetSingleCommit(owner, repo, SHA string) (*scm.Commit, error)
- func (c *Client) GetUserPermission(org, repo, user string) (string, error)
- func (c *Client) HasPermission(org, repo, user string, roles ...string) (bool, error)
- func (c *Client) IsCollaborator(owner, repo, login string) (bool, error)
- func (c *Client) IsMember(org, user string) (bool, error)
- func (c *Client) ListCollaborators(owner, repo string) ([]scm.User, error)
- func (c *Client) ListIssueComments(org, repo string, number int) ([]*scm.Comment, error)
- func (c *Client) ListIssueEvents(org, repo string, number int) ([]*scm.ListedIssueEvent, error)
- func (c *Client) ListMilestones(org, repo string) ([]Milestone, error)
- func (c *Client) ListOrgMembers(org string) ([]*scm.TeamMember, error)
- func (c *Client) ListPullRequestComments(owner, repo string, number int) ([]*scm.Comment, error)
- func (c *Client) ListReviews(owner, repo string, number int) ([]*scm.Review, error)
- func (c *Client) ListStatuses(owner, repo, ref string) ([]*scm.Status, error)
- func (c *Client) ListTeamMembers(id int, role string) ([]*scm.TeamMember, error)
- func (c *Client) ListTeams(org string) ([]*scm.Team, error)
- func (c *Client) Merge(owner, repo string, number int, details MergeDetails) error
- func (c *Client) Query(ctx context.Context, q interface{}, vars map[string]interface{}) error
- func (c *Client) RemoveLabel(owner, repo string, number int, label string, pr bool) error
- func (c *Client) ReopenIssue(owner, repo string, number int) error
- func (c *Client) ReopenPR(owner, repo string, number int) error
- func (c *Client) RequestReview(org, repo string, number int, logins []string) error
- func (c *Client) Search(opts scm.SearchOptions) ([]*scm.SearchIssue, *RateLimits, error)
- func (c *Client) SetBotName(botName string)
- func (c *Client) SetMilestone(org, repo string, issueNum, milestoneNum int) error
- func (c *Client) UnassignIssue(owner, repo string, number int, logins []string) error
- func (c *Client) UnrequestReview(org, repo string, number int, logins []string) error
- type DraftReview
- type DraftReviewComment
- type FileNotFound
- type GenericCommentEvent
- type GenericCommentEventAction
- type IssueEventAction
- type MergeCommitsForbiddenError
- type MergeDetails
- type Milestone
- type MissingUsers
- type ModifiedHeadError
- type PullRequestMergeType
- type RateLimits
- type ReviewAction
- type SCMClient
- type Status
- type UnauthorizedToPushError
- type UnmergablePRBaseChangedError
- type UnmergablePRError
Constants ¶
const ( // RoleAll lists both members and admins RoleAll = "all" // RoleAdmin specifies the user is an org admin, or lists only admins RoleAdmin = "admin" // RoleMaintainer specifies the user is a team maintainer, or lists only maintainers RoleMaintainer = "maintainer" // RoleMember specifies the user is a regular user, or only lists regular users RoleMember = "member" // StatePending specifies the user has an invitation to the org/team. StatePending = "pending" // StateActive specifies the user's membership is active. StateActive = "active" )
const ( // EventGUID is sent by Github in a header of every webhook request. // Used as a log field across prow. EventGUID = "event-GUID" // PrLogField is the number of a PR. // Used as a log field across prow. PrLogField = "pr" // OrgLogField is the organization of a PR. // Used as a log field across prow. OrgLogField = "org" // RepoLogField is the repository of a PR. // Used as a log field across prow. RepoLogField = "repo" // SearchTimeFormat is a time.Time format string for ISO8601 which is the // format that GitHub requires for times specified as part of a search query. SearchTimeFormat = "2006-01-02T15:04:05Z" )
const ( // GenericCommentActionCreated means something was created/opened/submitted GenericCommentActionCreated GenericCommentEventAction = "created" // "opened", "submitted" // GenericCommentActionEdited means something was edited. GenericCommentActionEdited = "edited" // GenericCommentActionDeleted means something was deleted/dismissed. GenericCommentActionDeleted = "deleted" // "dismissed" )
Comments indicate values that are coerced to the specified value.
const ( // IssueActionAssigned means assignees were added. IssueActionAssigned IssueEventAction = "assigned" // IssueActionUnassigned means assignees were added. IssueActionUnassigned = "unassigned" // IssueActionLabeled means labels were added. IssueActionLabeled = "labeled" // IssueActionUnlabeled means labels were removed. IssueActionUnlabeled = "unlabeled" // IssueActionOpened means issue was opened/created. IssueActionOpened = "opened" // IssueActionEdited means issue body was edited. IssueActionEdited = "edited" // IssueActionMilestoned means the milestone was added/changed. IssueActionMilestoned = "milestoned" // IssueActionDemilestoned means a milestone was removed. IssueActionDemilestoned = "demilestoned" // IssueActionClosed means issue was closed. IssueActionClosed = "closed" // IssueActionReopened means issue was reopened. IssueActionReopened = "reopened" )
const ( StatusPending = "pending" StatusSuccess = "success" StatusError = "error" StatusFailure = "failure" )
These are possible State entries for a Status.
Variables ¶
var (
// FoundingYear is the year GitHub was founded. This is just used so that
// we can lower bound dates related to PRs and issues.
FoundingYear, _ = time.Parse(SearchTimeFormat, "2007-01-01T00:00:00Z")
)
var NormLogin = strings.ToLower
NormLogin normalizes GitHub login strings
var TestBotName = "jenkins-x-bot"
TestBotName is the default bot name used in tests
Functions ¶
func ImageTooBig ¶
ImageTooBig checks if image is bigger than github limits
func PushHookBranch ¶
PushHookBranch returns the name of the branch to which the user pushed.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an interface that prow plugins expect on top of go-scm
func ToTestClient ¶
ToTestClient converts the scm client to an API that the prow plugins expect
func (*Client) AssignIssue ¶
AssignIssue assigns issue
func (*Client) ClearMilestone ¶
ClearMilestone clears milestone
func (*Client) CloseIssue ¶
CloseIssue close issue
func (*Client) CreateComment ¶
CreateComment create a comment
func (*Client) CreateGraphQLStatus ¶
CreateGraphQLStatus create a status into a repository
func (*Client) CreateStatus ¶
CreateStatus create a status into a repository
func (*Client) DeleteComment ¶
DeleteComment delete comments
func (*Client) DeleteStaleComments ¶
func (c *Client) DeleteStaleComments(org, repo string, number int, comments []*scm.Comment, pr bool, isStale func(*scm.Comment) bool) error
DeleteStaleComments iterates over comments on an issue/PR, deleting those which the 'isStale' function identifies as stale. If 'comments' is nil, the comments will be fetched from GitHub.
func (*Client) EditComment ¶ added in v0.0.553
EditComment edit a comment
func (*Client) FindIssues ¶
FindIssues find issues
func (*Client) GetCombinedStatus ¶
func (c *Client) GetCombinedStatus(owner, repo, ref string) (*scm.CombinedStatus, error)
GetCombinedStatus returns the combined status
func (*Client) GetIssueLabels ¶
GetIssueLabels returns the issue labels
func (*Client) GetPullRequest ¶
GetPullRequest returns the pull request
func (*Client) GetPullRequestChanges ¶
GetPullRequestChanges returns the changes in a pull request
func (*Client) GetRepoLabels ¶
GetRepoLabels returns the repository labels
func (*Client) GetSingleCommit ¶
GetSingleCommit returns a single commit
func (*Client) GetUserPermission ¶
GetUserPermission returns the user's permission level for a repo
func (*Client) HasPermission ¶
HasPermission returns true if GetUserPermission() returns any of the roles.
func (*Client) IsCollaborator ¶
IsCollaborator check if a user is collaborator to a repository
func (*Client) ListCollaborators ¶
ListCollaborators list the collaborators to a repository
func (*Client) ListIssueComments ¶
ListIssueComments list comments associated with an issue
func (*Client) ListIssueEvents ¶
ListIssueEvents list issue events
func (*Client) ListMilestones ¶
ListMilestones list milestones
func (*Client) ListOrgMembers ¶ added in v0.0.546
func (c *Client) ListOrgMembers(org string) ([]*scm.TeamMember, error)
ListOrgMembers list the org members
func (*Client) ListPullRequestComments ¶
ListPullRequestComments list pull request comments
func (*Client) ListReviews ¶
ListReviews list the reviews
func (*Client) ListStatuses ¶
ListStatuses list the statuses
func (*Client) ListTeamMembers ¶
ListTeamMembers list the team members
func (*Client) Merge ¶
func (c *Client) Merge(owner, repo string, number int, details MergeDetails) error
Merge reopens a pull request
func (*Client) RemoveLabel ¶
RemoveLabel removes labesl
func (*Client) ReopenIssue ¶
ReopenIssue reopen an issue
func (*Client) RequestReview ¶
RequestReview requests a review
func (*Client) Search ¶
func (c *Client) Search(opts scm.SearchOptions) ([]*scm.SearchIssue, *RateLimits, error)
Search query issues/PRs using a query string
func (*Client) SetBotName ¶
SetBotName sets the bot name
func (*Client) SetMilestone ¶
SetMilestone sets milestone
func (*Client) UnassignIssue ¶
UnassignIssue unassigns issue
type DraftReview ¶
type DraftReview struct { // If unspecified, defaults to the most recent commit in the PR. CommitSHA string `json:"commit_id,omitempty"` Body string `json:"body"` // If unspecified, defaults to PENDING. Action ReviewAction `json:"event,omitempty"` Comments []DraftReviewComment `json:"comments,omitempty"` }
DraftReview is what we give GitHub when we want to make a PR Review. This is different than what we receive when we ask for a Review.
type DraftReviewComment ¶
type DraftReviewComment struct { Path string `json:"path"` // Position in the patch, not the line number in the file. Position int `json:"position"` Body string `json:"body"` }
DraftReviewComment is a comment in a draft review.
type FileNotFound ¶
type FileNotFound struct {
// contains filtered or unexported fields
}
FileNotFound happens when github cannot find the file requested by GetFile().
func (*FileNotFound) Error ¶
func (e *FileNotFound) Error() string
Error formats a file not found error
type GenericCommentEvent ¶
type GenericCommentEvent struct { IsPR bool Action scm.Action Body string Link string Number int Repo scm.Repository Author scm.User IssueAuthor scm.User Assignees []scm.User IssueState string IssueBody string IssueLink string GUID string }
GenericCommentEvent is a fake event type that is instantiated for any github event that contains comment like content. The specific events that are also handled as GenericCommentEvents are: - issue_comment events - pull_request_review events - pull_request_review_comment events - pull_request events with action in ["opened", "edited"] - issue events with action in ["opened", "edited"]
Issue and PR "closed" events are not coerced to the "deleted" Action and do not trigger a GenericCommentEvent because these events don't actually remove the comment content from GH.
type GenericCommentEventAction ¶
type GenericCommentEventAction string
GenericCommentEventAction coerces multiple actions into its generic equivalent.
type IssueEventAction ¶
type IssueEventAction string
IssueEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#issuesevent
type MergeCommitsForbiddenError ¶
type MergeCommitsForbiddenError string
MergeCommitsForbiddenError happens when the repo disallows the merge strategy configured for the repo in Keeper.
func (MergeCommitsForbiddenError) Error ¶
func (e MergeCommitsForbiddenError) Error() string
type MergeDetails ¶
MergeDetails optional extra parameters
type MissingUsers ¶
type MissingUsers struct { Users []string // contains filtered or unexported fields }
MissingUsers is an error specifying the users that could not be unassigned.
func (MissingUsers) Error ¶
func (m MissingUsers) Error() string
type ModifiedHeadError ¶
type ModifiedHeadError string
ModifiedHeadError happens when github refuses to merge a PR because the PR changed.
func (ModifiedHeadError) Error ¶
func (e ModifiedHeadError) Error() string
type PullRequestMergeType ¶
type PullRequestMergeType string
PullRequestMergeType inidicates the type of the pull request
const ( MergeMerge PullRequestMergeType = "merge" MergeRebase PullRequestMergeType = "rebase" MergeSquash PullRequestMergeType = "squash" )
Possible types of merges for the GitHub merge API
type RateLimits ¶
RateLimits contains rate limit information
type ReviewAction ¶
type ReviewAction string
ReviewAction is the action that a review can be made with.
const ( Approve ReviewAction = "APPROVE" RequestChanges ReviewAction = "REQUEST_CHANGES" Comment ReviewAction = "COMMENT" )
Possible review actions. Leave Action blank for a pending review.
type SCMClient ¶
type SCMClient interface { // Functions implemented in client.go BotName() (string, error) SetBotName(string) // Functions implemented in content.go GetFile(string, string, string, string) ([]byte, error) // Functions implemented in git.go GetRef(string, string, string) (string, error) DeleteRef(string, string, string) error GetSingleCommit(string, string, string) (*scm.Commit, error) // Functions implemented in issues.go Query(context.Context, interface{}, map[string]interface{}) error Search(scm.SearchOptions) ([]*scm.SearchIssue, *RateLimits, error) ListIssueEvents(string, string, int) ([]*scm.ListedIssueEvent, error) AssignIssue(string, string, int, []string) error UnassignIssue(string, string, int, []string) error AddLabel(string, string, int, string, bool) error RemoveLabel(string, string, int, string, bool) error DeleteComment(string, string, int, int, bool) error DeleteStaleComments(string, string, int, []*scm.Comment, bool, func(*scm.Comment) bool) error ListIssueComments(string, string, int) ([]*scm.Comment, error) GetIssueLabels(string, string, int, bool) ([]*scm.Label, error) CreateComment(string, string, int, bool, string) error ReopenIssue(string, string, int) error FindIssues(string, string, bool) ([]scm.Issue, error) CloseIssue(string, string, int) error EditComment(owner, repo string, number int, id int, comment string, pr bool) error // Functions implemented in organizations.go ListTeams(string) ([]*scm.Team, error) ListTeamMembers(int, string) ([]*scm.TeamMember, error) ListOrgMembers(string) ([]*scm.TeamMember, error) // Functions implemented in pull_requests.go GetPullRequest(string, string, int) (*scm.PullRequest, error) ListPullRequestComments(string, string, int) ([]*scm.Comment, error) GetPullRequestChanges(string, string, int) ([]*scm.Change, error) Merge(string, string, int, MergeDetails) error ReopenPR(string, string, int) error ClosePR(string, string, int) error // Functions implemented in repositories.go GetRepoLabels(string, string) ([]*scm.Label, error) IsCollaborator(string, string, string) (bool, error) ListCollaborators(string, string) ([]scm.User, error) CreateStatus(string, string, string, *scm.StatusInput) (*scm.Status, error) CreateGraphQLStatus(string, string, string, *Status) (*scm.Status, error) ListStatuses(string, string, string) ([]*scm.Status, error) GetCombinedStatus(string, string, string) (*scm.CombinedStatus, error) HasPermission(string, string, string, ...string) (bool, error) GetUserPermission(string, string, string) (string, error) IsMember(string, string) (bool, error) // Functions implemented in reviews.go ListReviews(string, string, int) ([]*scm.Review, error) RequestReview(string, string, int, []string) error UnrequestReview(string, string, int, []string) error // Functions not yet implemented ClearMilestone(string, string, int) error SetMilestone(string, string, int, int) error ListMilestones(string, string) ([]Milestone, error) }
SCMClient is an interface providing all functions on the Client struct.
type Status ¶
type Status struct { State string `json:"state"` TargetURL string `json:"target_url,omitempty"` Description string `json:"description,omitempty"` Context string `json:"context,omitempty"` }
Status is used to set a commit status line.
type UnauthorizedToPushError ¶
type UnauthorizedToPushError string
UnauthorizedToPushError happens when client is not allowed to push to github.
func (UnauthorizedToPushError) Error ¶
func (e UnauthorizedToPushError) Error() string
type UnmergablePRBaseChangedError ¶
type UnmergablePRBaseChangedError string
UnmergablePRBaseChangedError happens when github refuses merging a PR because the base changed.
func (UnmergablePRBaseChangedError) Error ¶
func (e UnmergablePRBaseChangedError) Error() string
type UnmergablePRError ¶
type UnmergablePRError string
UnmergablePRError happens when github refuses to merge a PR for other reasons (merge confclit).
func (UnmergablePRError) Error ¶
func (e UnmergablePRError) Error() string