Documentation
¶
Index ¶
- func ValidateGitLabWebhookToken(r *http.Request, expectedToken string) bool
- type ConfigFetcher
- type DeliveryDedup
- type GitHubConfigFetcher
- type GitHubPRPayload
- type GitHubWebhookHandler
- type GitLabConfigFetcher
- type GitLabMRPayload
- type GitLabPreviewGroupWebhookHandler
- type GitLabWebhookHandler
- type WebhookConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfigFetcher ¶
type ConfigFetcher interface {
FetchConfig(ctx context.Context, provider, project, ref string) ([]byte, error)
}
ConfigFetcher fetches .diverge.yaml from a source code repository.
type DeliveryDedup ¶ added in v0.9.0
type DeliveryDedup struct {
// contains filtered or unexported fields
}
DeliveryDedup prevents webhook replay attacks by tracking delivery IDs.
func NewDeliveryDedup ¶ added in v0.9.0
func NewDeliveryDedup() *DeliveryDedup
func (*DeliveryDedup) IsDuplicate ¶ added in v0.9.0
func (d *DeliveryDedup) IsDuplicate(id string) bool
type GitHubConfigFetcher ¶
GitHubConfigFetcher fetches .diverge.yaml from the GitHub API.
func (*GitHubConfigFetcher) FetchConfig ¶
type GitHubPRPayload ¶
type GitHubPRPayload struct {
Action string `json:"action"`
PullRequest struct {
Number int `json:"number"`
Head struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
} `json:"head"`
Base struct {
Ref string `json:"ref"`
} `json:"base"`
State string `json:"state"`
} `json:"pull_request"`
Repository struct {
FullName string `json:"full_name"`
} `json:"repository"`
}
type GitHubWebhookHandler ¶
type GitHubWebhookHandler struct {
Client client.Client
Config WebhookConfig
ConfigFetcher ConfigFetcher
DefaultNS string
Dedup *DeliveryDedup
}
func (*GitHubWebhookHandler) ServeHTTP ¶
func (h *GitHubWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type GitLabConfigFetcher ¶
GitLabConfigFetcher fetches .diverge.yaml from the GitLab API.
func (*GitLabConfigFetcher) FetchConfig ¶
type GitLabMRPayload ¶
type GitLabMRPayload struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
ObjectAttributes struct {
ID int `json:"id"`
IID int `json:"iid"`
TargetBranch string `json:"target_branch"`
SourceBranch string `json:"source_branch"`
State string `json:"state"`
Action string `json:"action"`
LastCommit struct {
ID string `json:"id"`
} `json:"last_commit"`
} `json:"object_attributes"`
Project struct {
Name string `json:"name"`
PathWithNamespace string `json:"path_with_namespace"`
} `json:"project"`
}
GitLabMRPayload is a simple struct to decode MR webhook payloads
type GitLabPreviewGroupWebhookHandler ¶
type GitLabPreviewGroupWebhookHandler struct {
Client client.Client
Config WebhookConfig
ConfigFetcher ConfigFetcher
}
func (*GitLabPreviewGroupWebhookHandler) ServeHTTP ¶
func (h *GitLabPreviewGroupWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type GitLabWebhookHandler ¶
type GitLabWebhookHandler struct {
Client client.Client
Config WebhookConfig
ConfigFetcher ConfigFetcher
DefaultNS string
Dedup *DeliveryDedup
}
func (*GitLabWebhookHandler) ServeHTTP ¶
func (h *GitLabWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WebhookConfig ¶
type WebhookConfig struct {
SecretToken string
}
Click to show internal directories.
Click to hide internal directories.