gitprovider

package
v0.0.431 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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.

View Source
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"
)
View Source
const (
	StatusPending = "pending"
	StatusSuccess = "success"
	StatusError   = "error"
	StatusFailure = "failure"
)

These are possible State entries for a Status.

Variables

View Source
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")
)
View Source
var NormLogin = strings.ToLower

NormLogin normalizes GitHub login strings

View Source
var TestBotName = "jenkins-x-bot"

TestBotName is the default bot name used in tests

Functions

func HasLabel

func HasLabel(label string, issueLabels []*scm.Label) bool

HasLabel checks if label is in the label set "issueLabels".

func ImageTooBig

func ImageTooBig(url string) (bool, error)

ImageTooBig checks if image is bigger than github limits

func PushHookBranch

func PushHookBranch(pe *scm.PushHook) string

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 ToClient

func ToClient(client *scm.Client, botName string) *Client

ToClient converts the scm client to an API that the prow plugins expect

func ToTestClient

func ToTestClient(client *scm.Client) *Client

ToTestClient converts the scm client to an API that the prow plugins expect

func (*Client) AddLabel

func (c *Client) AddLabel(owner, repo string, number int, label string, pr bool) error

AddLabel adds a label

func (*Client) AssignIssue

func (c *Client) AssignIssue(owner, repo string, number int, logins []string) error

AssignIssue assigns issue

func (*Client) BotName

func (c *Client) BotName() (string, error)

BotName returns the bot name

func (*Client) ClearMilestone

func (c *Client) ClearMilestone(org, repo string, num int) error

ClearMilestone clears milestone

func (*Client) CloseIssue

func (c *Client) CloseIssue(owner, repo string, number int) error

CloseIssue close issue

func (*Client) ClosePR

func (c *Client) ClosePR(owner, repo string, number int) error

ClosePR closes a pull request

func (*Client) CreateComment

func (c *Client) CreateComment(owner, repo string, number int, pr bool, comment string) error

CreateComment create a comment

func (*Client) CreateGraphQLStatus

func (c *Client) CreateGraphQLStatus(owner, repo, ref string, s *Status) (*scm.Status, error)

CreateGraphQLStatus create a status into a repository

func (*Client) CreateStatus

func (c *Client) CreateStatus(owner, repo, ref string, s *scm.StatusInput) (*scm.Status, error)

CreateStatus create a status into a repository

func (*Client) DeleteComment

func (c *Client) DeleteComment(org, repo string, number, ID int, pr bool) error

DeleteComment delete comments

func (*Client) DeleteRef

func (c *Client) DeleteRef(owner, repo, ref string) error

DeleteRef deletes the ref from repository

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) FindIssues

func (c *Client) FindIssues(query, sort string, asc bool) ([]scm.Issue, error)

FindIssues find issues

func (*Client) GetCombinedStatus

func (c *Client) GetCombinedStatus(owner, repo, ref string) (*scm.CombinedStatus, error)

GetCombinedStatus returns the combined status

func (*Client) GetFile

func (c *Client) GetFile(owner, repo, filepath, commit string) ([]byte, error)

GetFile retruns the file from GitHub

func (*Client) GetIssueLabels

func (c *Client) GetIssueLabels(org, repo string, number int, pr bool) ([]*scm.Label, error)

GetIssueLabels returns the issue labels

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(owner, repo string, number int) (*scm.PullRequest, error)

GetPullRequest returns the pull request

func (*Client) GetPullRequestChanges

func (c *Client) GetPullRequestChanges(org, repo string, number int) ([]*scm.Change, error)

GetPullRequestChanges returns the changes in a pull request

func (*Client) GetRef

func (c *Client) GetRef(owner, repo, ref string) (string, error)

GetRef retruns the ref from repository

func (*Client) GetRepoLabels

func (c *Client) GetRepoLabels(owner, repo string) ([]*scm.Label, error)

GetRepoLabels returns the repository labels

func (*Client) GetSingleCommit

func (c *Client) GetSingleCommit(owner, repo, SHA string) (*scm.Commit, error)

GetSingleCommit returns a single commit

func (*Client) GetUserPermission

func (c *Client) GetUserPermission(org, repo, user string) (string, error)

GetUserPermission returns the user's permission level for a repo

func (*Client) HasPermission

func (c *Client) HasPermission(org, repo, user string, roles ...string) (bool, error)

HasPermission returns true if GetUserPermission() returns any of the roles.

func (*Client) IsCollaborator

func (c *Client) IsCollaborator(owner, repo, login string) (bool, error)

IsCollaborator check if a user is collaborator to a repository

func (*Client) IsMember

func (c *Client) IsMember(org, user string) (bool, error)

IsMember checks if a user is a member of the organisation

func (*Client) ListCollaborators

func (c *Client) ListCollaborators(owner, repo string) ([]scm.User, error)

ListCollaborators list the collaborators to a repository

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(org, repo string, number int) ([]*scm.Comment, error)

ListIssueComments list comments associated with an issue

func (*Client) ListIssueEvents

func (c *Client) ListIssueEvents(org, repo string, number int) ([]*scm.ListedIssueEvent, error)

ListIssueEvents list issue events

func (*Client) ListMilestones

func (c *Client) ListMilestones(org, repo string) ([]Milestone, error)

ListMilestones list milestones

func (*Client) ListPullRequestComments

func (c *Client) ListPullRequestComments(owner, repo string, number int) ([]*scm.Comment, error)

ListPullRequestComments list pull request comments

func (*Client) ListReviews

func (c *Client) ListReviews(owner, repo string, number int) ([]*scm.Review, error)

ListReviews list the reviews

func (*Client) ListStatuses

func (c *Client) ListStatuses(owner, repo, ref string) ([]*scm.Status, error)

ListStatuses list the statuses

func (*Client) ListTeamMembers

func (c *Client) ListTeamMembers(id int, role string) ([]*scm.TeamMember, error)

ListTeamMembers list the team members

func (*Client) ListTeams

func (c *Client) ListTeams(org string) ([]*scm.Team, error)

ListTeams list teams in the organisation

func (*Client) Merge

func (c *Client) Merge(owner, repo string, number int, details MergeDetails) error

Merge reopens a pull request

func (*Client) Query

func (c *Client) Query(ctx context.Context, q interface{}, vars map[string]interface{}) error

Query performs a GraphQL query on the git provider

func (*Client) RemoveLabel

func (c *Client) RemoveLabel(owner, repo string, number int, label string, pr bool) error

RemoveLabel removes labesl

func (*Client) ReopenIssue

func (c *Client) ReopenIssue(owner, repo string, number int) error

ReopenIssue reopen an issue

func (*Client) ReopenPR

func (c *Client) ReopenPR(owner, repo string, number int) error

ReopenPR reopens a pull request

func (*Client) RequestReview

func (c *Client) RequestReview(org, repo string, number int, logins []string) error

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

func (c *Client) SetBotName(botName string)

SetBotName sets the bot name

func (*Client) SetMilestone

func (c *Client) SetMilestone(org, repo string, issueNum, milestoneNum int) error

SetMilestone sets milestone

func (*Client) UnassignIssue

func (c *Client) UnassignIssue(owner, repo string, number int, logins []string) error

UnassignIssue unassigns issue

func (*Client) UnrequestReview

func (c *Client) UnrequestReview(org, repo string, number int, logins []string) error

UnrequestReview unrequest a review

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 Tide.

func (MergeCommitsForbiddenError) Error

type MergeDetails

type MergeDetails struct {
	SHA           string
	MergeMethod   string
	CommitTitle   string
	CommitMessage string
}

MergeDetails optional extra parameters

type Milestone

type Milestone struct {
	Title  string `json:"title"`
	Number int    `json:"number"`
}

Milestone is a milestone defined on a github repository

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

type RateLimits struct {
	Remaining int
	Limit     int
	Reset     int
}

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 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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL