Documentation ¶
Index ¶
- Constants
- func GetOrgRepo(repo *github.Repository) (string, string)
- func IsCommentCreated(e *github.IssueCommentEvent) bool
- func IsCommentOnPullRequest(e *github.IssueCommentEvent) bool
- func IsIssueOpened(action string) bool
- func IsPROpened(action string) bool
- func IsPRSourceBranchChanged(action string) bool
- func PayloadSignature(payload []byte, key []byte) string
- func ValidatePayload(payload []byte, sig string, tokenGenerator func() []byte) bool
- func ValidateWebhook(w http.ResponseWriter, r *http.Request, tokenGenerator func() []byte) (eType string, guid string, payload []byte, ok bool, status int)
- type Client
- type IssuePRInfo
- type PRInfo
Constants ¶
const ( ActionOpened = "opened" ActionCreated = "created" ActionReopen = "reopened" ActionClosed = "closed" PRActionOpened = "opened" PRActionChangedSourceBranch = "synchronize" )
Variables ¶
This section is empty.
Functions ¶
func GetOrgRepo ¶
func GetOrgRepo(repo *github.Repository) (string, string)
GetOrgRepo return the owner and name of the repository
func IsCommentCreated ¶
func IsCommentCreated(e *github.IssueCommentEvent) bool
IsCommentCreated tells whether the comment is created now.
func IsCommentOnPullRequest ¶
func IsCommentOnPullRequest(e *github.IssueCommentEvent) bool
IsCommentOnPullRequest tells whether the comment is on pull request
func IsIssueOpened ¶
IsIssueOpened tells whether the issue is opened
func IsPRSourceBranchChanged ¶
IsPRSourceBranchChanged tells whether the PR's source branch is changed
func PayloadSignature ¶
PayloadSignature returns the signature that matches the payload.
func ValidatePayload ¶
ValidatePayload ensures that the request payload signature matches the key.
func ValidateWebhook ¶
func ValidateWebhook( w http.ResponseWriter, r *http.Request, tokenGenerator func() []byte, ) (eType string, guid string, payload []byte, ok bool, status int)
ValidateWebhook ensures that the provided request conforms to the format of a GitHub webhook and the payload can be validated with the provided hmac secret. It returns the event type, the event guid, the payload of the request, whether the webhook is valid or not, and finally the resultant HTTP status code
Types ¶
type Client ¶
type Client interface { AddPRLabel(pr PRInfo, label string) error RemovePRLabel(pr PRInfo, label string) error CreatePRComment(pr PRInfo, comment string) error DeletePRComment(org, repo string, ID int64) error GetPRCommits(pr PRInfo) ([]*sdk.RepositoryCommit, error) GetPRComments(pr PRInfo) ([]*sdk.IssueComment, error) UpdatePR(pr PRInfo, request *sdk.PullRequest) (*sdk.PullRequest, error) GetPullRequests(pr PRInfo) ([]*sdk.PullRequest, error) ListCollaborator(pr PRInfo) ([]*sdk.User, error) IsCollaborator(pr PRInfo, login string) (bool, error) RemoveRepoMember(pr PRInfo, login string) error AddRepoMember(pr PRInfo, login, permission string) error GetPullRequestChanges(pr PRInfo) ([]*sdk.CommitFile, error) GetPRLabels(pr PRInfo) ([]string, error) GetRepositoryLabels(pr PRInfo) ([]string, error) UpdatePRComment(pr PRInfo, commentID int64, ic *sdk.IssueComment) error ClosePR(pr PRInfo) error ReopenPR(pr PRInfo) error AssignPR(pr PRInfo, logins []string) error UnAssignPR(pr PRInfo, logins []string) error CloseIssue(pr PRInfo) error ReopenIssue(pr PRInfo) error MergePR(pr PRInfo, commitMessage string, opt *sdk.PullRequestOptions) error GetRepos(org string) ([]*sdk.Repository, error) GetRepo(org, repo string) (*sdk.Repository, error) CreateRepo(org string, r *sdk.Repository) error UpdateRepo(org, repo string, r *sdk.Repository) error CreateRepoLabel(org, repo, label string) error GetRepoLabels(org, repo string) ([]string, error) AssignSingleIssue(is PRInfo, login string) error UnAssignSingleIssue(is PRInfo, login string) error CreateIssueComment(is PRInfo, comment string) error UpdateIssueComment(is PRInfo, commentID int64, c *sdk.IssueComment) error ListIssueComments(is PRInfo) ([]*sdk.IssueComment, error) RemoveIssueLabel(is PRInfo, label string) error AddIssueLabel(is PRInfo, label []string) error GetIssueLabels(is PRInfo) ([]string, error) UpdateIssue(is PRInfo, iss *sdk.IssueRequest) error GetSingleIssue(is PRInfo) (*sdk.Issue, error) ListBranches(org, repo string) ([]*sdk.Branch, error) SetProtectionBranch(org, repo, branch string, pre *sdk.ProtectionRequest) error RemoveProtectionBranch(org, repo, branch string) error GetDirectoryTree(org, repo, branch string, recursive bool) ([]*sdk.TreeEntry, error) GetPathContent(org, repo, path, branch string) (*sdk.RepositoryContent, error) CreateFile(org, repo, path, branch, commitMSG, sha string, content []byte) error GetUserPermissionOfRepo(org, repo, user string) (*sdk.RepositoryPermissionLevel, error) CreateIssue(org, repo string, request *sdk.IssueRequest) (*sdk.Issue, error) GetRef(org, repo, ref string) (*sdk.Reference, error) CreateBranch(org, repo string, reference *sdk.Reference) error ListOperationLogs(pr PRInfo) ([]*sdk.Timeline, error) GetEnterprisesMember(org string) ([]*sdk.User, error) GetSinglePR(org, repo string, number int) (*sdk.PullRequest, error) }
Client interface for GitHub API
type IssuePRInfo ¶
type IssuePRInfo interface { GetOrgRepo() (string, string) // GetNumber will return PR or Issue Number GetNumber() int // GetLabels will return labels on PR or Issue GetLabels() sets.String // GetAuthor will return author of PR or Issue GetAuthor() string }
func GenIssuePRInfo ¶
func GenIssuePRInfo(e interface{}) IssuePRInfo