Documentation
¶
Index ¶
- func HashPayload(secret string, payloadBody []byte) string
- func IsValidPayload(secret, headerHash string, payload []byte) bool
- func Validate(secret, headerHash string, payload []byte) error
- type BranchResponse
- type Client
- func (c *Client) CanUserWriteToRepo(user git.User) (bool, error)
- func (c *Client) DeleteLabel(_ git.IssueType, id int, label string) error
- func (c *Client) DeleteWebhook(id int) error
- func (c *Client) GetBranch(branch string) (*git.Branch, error)
- func (c *Client) GetPullRequest(id int) (*git.PullRequest, error)
- func (c *Client) GetUserInfo(userName string) (*git.User, error)
- func (c *Client) Init() error
- func (c *Client) ListCommitStatuses(ref string) ([]git.CommitStatus, error)
- func (c *Client) ListPullRequests(onlyOpen bool) ([]git.PullRequest, error)
- func (c *Client) ListWebhook() ([]git.WebhookEntry, error)
- func (c *Client) MergePullRequest(id int, sha string, method git.MergeMethod, message string) error
- func (c *Client) ParseWebhook(header http.Header, jsonString []byte) (*git.Webhook, error)
- func (c *Client) RegisterComment(_ git.IssueType, issueNo int, body string) error
- func (c *Client) RegisterWebhook(url string) error
- func (c *Client) SetCommitStatus(sha string, status git.CommitStatus) error
- func (c *Client) SetLabel(_ git.IssueType, id int, label string) error
- type Comment
- type CommentBody
- type CommitStatusRequest
- type CommitStatusResponse
- type IssueCommentWebhook
- type LabelBody
- type MergeRequest
- type PullRequest
- type PullRequestReviewCommentWebhook
- type PullRequestReviewWebhook
- type PullRequestWebhook
- type PushWebhook
- type RegistrationWebhookBody
- type RegistrationWebhookBodyConfig
- type Repo
- type User
- type UserInfo
- type UserPermission
- type WebhookEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashPayload ¶
HashPayload hashes the payload
func IsValidPayload ¶
IsValidPayload validates the webhook payload
Types ¶
type BranchResponse ¶ added in v0.3.0
type BranchResponse struct { Name string `json:"name"` Commit struct { Sha string `json:"sha"` } `json:"commit"` }
BranchResponse is a respond struct for branch request
type Client ¶
type Client struct { IntegrationConfig *cicdv1.IntegrationConfig K8sClient client.Client // contains filtered or unexported fields }
Client is a gitlab client struct
func (*Client) CanUserWriteToRepo ¶ added in v0.2.0
CanUserWriteToRepo decides if the user has write permission on the repo
func (*Client) DeleteLabel ¶ added in v0.3.0
DeleteLabel deletes label from the issue id
func (*Client) DeleteWebhook ¶
DeleteWebhook deletes registered webhook
func (*Client) GetPullRequest ¶ added in v0.3.0
func (c *Client) GetPullRequest(id int) (*git.PullRequest, error)
GetPullRequest gets PR given id
func (*Client) GetUserInfo ¶ added in v0.1.4
GetUserInfo gets a user's information
func (*Client) ListCommitStatuses ¶ added in v0.3.0
func (c *Client) ListCommitStatuses(ref string) ([]git.CommitStatus, error)
ListCommitStatuses lists commit status of the specific commit
func (*Client) ListPullRequests ¶ added in v0.3.0
func (c *Client) ListPullRequests(onlyOpen bool) ([]git.PullRequest, error)
ListPullRequests gets pull request list
func (*Client) ListWebhook ¶
func (c *Client) ListWebhook() ([]git.WebhookEntry, error)
ListWebhook lists registered webhooks
func (*Client) MergePullRequest ¶ added in v0.3.0
MergePullRequest merges a pull request
func (*Client) ParseWebhook ¶
ParseWebhook parses a webhook body for github
func (*Client) RegisterComment ¶ added in v0.2.0
RegisterComment registers comment to an issue
func (*Client) RegisterWebhook ¶
RegisterWebhook registers our webhook server to the remote git server
func (*Client) SetCommitStatus ¶
func (c *Client) SetCommitStatus(sha string, status git.CommitStatus) error
SetCommitStatus sets commit status for the specific commit
type Comment ¶ added in v0.2.0
type Comment struct { Body string `json:"body"` User User `json:"user"` CreatedAt *metav1.Time `json:"created_at"` UpdatedAt *metav1.Time `json:"updated_at"` }
Comment is a comment payload
type CommentBody ¶ added in v0.2.0
type CommentBody struct {
Body string `json:"body"`
}
CommentBody is a body structure for creating new comment
type CommitStatusRequest ¶ added in v0.3.0
type CommitStatusRequest struct { State string `json:"state"` TargetURL string `json:"target_url"` Description string `json:"description"` Context string `json:"context"` }
CommitStatusRequest is an API body for setting commits' status
type CommitStatusResponse ¶ added in v0.3.0
type CommitStatusResponse struct { Context string `json:"context"` State string `json:"state"` Description string `json:"description"` TargetURL string `json:"target_url"` }
CommitStatusResponse is a response body of getting commit status
type IssueCommentWebhook ¶ added in v0.2.0
type IssueCommentWebhook struct { Action string `json:"action"` Comment Comment `json:"comment"` Issue struct { PullRequest struct { URL string `json:"url"` } `json:"pull_request"` } `json:"issue"` Repo Repo `json:"repository"` Sender User `json:"sender"` }
IssueCommentWebhook is a github-specific issue_comment webhook body
type LabelBody ¶ added in v0.3.0
type LabelBody struct {
Name string `json:"name"`
}
LabelBody is a body structure for setting a label to issues/prs
type MergeRequest ¶ added in v0.3.0
type MergeRequest struct { CommitTitle string `json:"commit_title"` CommitMessage string `json:"commit_message"` MergeMethod string `json:"merge_method"` Sha string `json:"sha"` }
MergeRequest is a request struct to merge a pull request
type PullRequest ¶ added in v0.2.0
type PullRequest struct { Title string `json:"title"` Number int `json:"number"` State string `json:"state"` URL string `json:"html_url"` Mergeable bool `json:"mergeable"` User User `json:"user"` Draft bool `json:"draft"` Head struct { Ref string `json:"ref"` Sha string `json:"sha"` } `json:"head"` Base struct { Ref string `json:"ref"` Sha string `json:"sha"` } `json:"base"` Labels []struct { Name string `json:"name"` } `json:"labels"` }
PullRequest is a pull request info
type PullRequestReviewCommentWebhook ¶ added in v0.2.0
type PullRequestReviewCommentWebhook struct { Action string `json:"action"` Comment Comment `json:"comment"` PullRequest PullRequest `json:"pull_request"` Repo Repo `json:"repository"` Sender User `json:"sender"` }
PullRequestReviewCommentWebhook is a github-specific pull_request_review_comment webhook body
type PullRequestReviewWebhook ¶ added in v0.2.0
type PullRequestReviewWebhook struct { Action string `json:"action"` Review struct { Body string `json:"body"` SubmittedAt *metav1.Time `json:"submitted_at"` State string `json:"state"` User User `json:"user"` } `json:"review"` PullRequest PullRequest `json:"pull_request"` Repo Repo `json:"repository"` Sender User `json:"sender"` }
PullRequestReviewWebhook is a github-specific pull_request_review webhook body
type PullRequestWebhook ¶
type PullRequestWebhook struct { Action string `json:"action"` Number int `json:"number"` Sender User `json:"sender"` PullRequest PullRequest `json:"pull_request"` Repo Repo `json:"repository"` // Changed label Label LabelBody `json:"label"` }
PullRequestWebhook is a github-specific pull-request event webhook body
type PushWebhook ¶
type PushWebhook struct { Ref string `json:"ref"` Repo Repo `json:"repository"` Sender User `json:"sender"` Sha string `json:"after"` }
PushWebhook is a github-specific push event webhook body
type RegistrationWebhookBody ¶
type RegistrationWebhookBody struct { Name string `json:"name"` Active bool `json:"active"` Events []string `json:"events"` Config RegistrationWebhookBodyConfig `json:"config"` }
RegistrationWebhookBody is a request body for registering webhook to remote git server
type RegistrationWebhookBodyConfig ¶
type RegistrationWebhookBodyConfig struct { URL string `json:"url"` ContentType string `json:"content_type"` InsecureSsl string `json:"insecure_ssl"` Secret string `json:"secret"` }
RegistrationWebhookBodyConfig is a config for the webhook
type Repo ¶
type Repo struct { Name string `json:"full_name"` URL string `json:"html_url"` Owner struct { ID string `json:"login"` } `json:"owner"` Private bool `json:"private"` }
Repo structure for webhook event
type UserInfo ¶ added in v0.1.4
type UserInfo struct { ID int `json:"id"` UserName string `json:"login"` Email string `json:"email"` }
UserInfo is a body of user get API
type UserPermission ¶ added in v0.2.0
type UserPermission struct {
Permission string `json:"permission"`
}
UserPermission is a user's permission on a repository
type WebhookEntry ¶
type WebhookEntry struct { ID int `json:"id"` Config struct { URL string `json:"url"` } `json:"config"` }
WebhookEntry is a body of list of registered webhooks