webhookparser

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// EventHeaderKey represents the event type of incoming webhook from Bitbucket
	EventHeaderKey = "X-Event-Key"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type WebHookInfoBranchStatus added in v1.6.0

type WebHookInfoBranchStatus string
const (
	WebhookInfoBranchStatusCreated WebHookInfoBranchStatus = "created"
	WebhookInfoBranchStatusUpdated WebHookInfoBranchStatus = "updated"
	WebhookInfoBranchStatusDeleted WebHookInfoBranchStatus = "deleted"
)

type WebHookInfoCommit added in v1.6.0

type WebHookInfoCommit struct {
	Hash    string `json:"hash,omitempty"`
	Message string `json:"message,omitempty"`
	Url     string `json:"url,omitempty"`
}

WebHookInfoCommit represents a commit info of an incoming webhook

type WebHookInfoFile added in v1.6.0

type WebHookInfoFile struct {
	Path string `json:"path,omitempty"`
}

type WebHookInfoRepoDetails added in v1.1.0

type WebHookInfoRepoDetails struct {
	Name  string `json:"name,omitempty"`
	Owner string `json:"owner,omitempty"`
}

WebHookInfoRepoDetails represents repository info of an incoming webhook

type WebHookInfoUser added in v1.6.0

type WebHookInfoUser struct {
	Login       string `json:"login,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	Email       string `json:"email,omitempty"`
	AvatarUrl   string `json:"avatar_url,omitempty"`
}

type WebhookInfo

type WebhookInfo struct {
	// The target repository for pull requests and push
	TargetRepositoryDetails WebHookInfoRepoDetails `json:"target_repository_details,omitempty"`
	// The target branch for pull requests and push
	TargetBranch string `json:"branch,omitempty"`
	// Pull request id
	PullRequestId int `json:"pull_request_id,omitempty"`
	// The source repository for pull requests
	SourceRepositoryDetails WebHookInfoRepoDetails `json:"source_repository_details,omitempty"`
	// The source branch for pull requests
	SourceBranch string `json:"source_branch,omitempty"`
	// Seconds from epoch
	Timestamp int64 `json:"timestamp,omitempty"`
	// The event type
	Event vcsutils.WebhookEvent `json:"event,omitempty"`
	// Last commit (Push event only)
	Commit WebHookInfoCommit `json:"commit,omitempty"`
	// Before commit (Push event only)
	BeforeCommit WebHookInfoCommit `json:"before_commit,omitempty"`
	// Branch status (Push event only)
	BranchStatus WebHookInfoBranchStatus `json:"branch_status,omitempty"`
	// User who triggered the commit (Push event only)
	TriggeredBy WebHookInfoUser `json:"triggered_by,omitempty"`
	// Committer (Push event only)
	Committer WebHookInfoUser `json:"committer,omitempty"`
	// Commit author (Push event only)
	Author WebHookInfoUser `json:"author,omitempty"`
	// CompareUrl is HTML URL to see git comparison between commits (Push event only)
	CompareUrl string `json:"compare_url,omitempty"`
	// PullRequest encapsulates information of the pull request.
	PullRequest *WebhookInfoPullRequest `json:"pull_request,omitempty"`
	// Tag encapsulates information about the tag event.
	Tag *WebhookInfoTag `json:"tag,omitempty"`
}

WebhookInfo used for parsing an incoming webhook request from the VCS provider.

func ParseIncomingWebhook

func ParseIncomingWebhook(ctx context.Context, logger vcsutils.Log, origin WebhookOrigin, request *http.Request) (*WebhookInfo, error)

ParseIncomingWebhook parses incoming webhook HTTP request into WebhookInfo struct. ctx - Go context logger - Used to log any trace about the parsing origin - Information about the hook origin request - Received HTTP request

type WebhookInfoPullRequest added in v1.7.1

type WebhookInfoPullRequest struct {
	// ID is a unique identifier of the pull request.
	ID int `json:"id,omitempty"`
	// Title is a title(name) of the pull request.
	Title string `json:"title,omitempty"`
	// CompareUrl is a hyperlink to the pull request.
	CompareUrl string `json:"url,omitempty"`
	// Timestamp of the last update (Unix timestamp).
	Timestamp int64 `json:"timestamp,omitempty"`
	// Author is an info about pull request author.
	Author WebHookInfoUser `json:"author,omitempty"`
	// TriggeredBy
	TriggeredBy WebHookInfoUser `json:"triggered_by,omitempty"`
	// SkipDecryption
	SkipDecryption bool `json:"skip_decryption,omitempty"`
	// TargetRepository contains details about target repository (destination of the changes).
	TargetRepository WebHookInfoRepoDetails `json:"target_repository,omitempty"`
	// TargetBranch is a name of the branch of the TargetRepository.
	TargetBranch string `json:"target_branch,omitempty"`
	// TargetHash is a commit SHA of the target branch.
	TargetHash string `json:"target_hash,omitempty"`
	// SourceRepository contains details about source repository.
	SourceRepository WebHookInfoRepoDetails `json:"source_repository,omitempty"`
	// SourceBranch is a name of the branch of the SourceRepository.
	SourceBranch string `json:"source_branch,omitempty"`
	// SourceHash is a commit SHA of the source branch.
	SourceHash string `json:"source_hash,omitempty"`
}

WebhookInfoPullRequest contains information about a pull request event received via a webhook.

type WebhookInfoTag added in v1.7.2

type WebhookInfoTag struct {
	// Name is a name of the tag.
	Name string `json:"name,omitempty"`
	// Hash is an SHA of the tag.
	Hash string `json:"hash,omitempty"`
	// TargetHash is an SHA of the commit the tag points to.
	TargetHash string `json:"target_hash,omitempty"`
	// Message is a message used during tag creation if any.
	Message string `json:"message,omitempty"`
	// Repository contains details about repository.
	Repository WebHookInfoRepoDetails `json:"repository,omitempty"`
	// Author
	Author WebHookInfoUser `json:"author,omitempty"`
}

WebhookInfoTag contains information about a tag event received via a webhook.

type WebhookOrigin added in v1.6.0

type WebhookOrigin struct {
	// Git provider
	VcsProvider vcsutils.VcsProvider
	// URL of the Git service
	OriginURL string
	// Token is used to authenticate incoming webhooks. If empty, signature will not be verified.
	// The token is a random key generated in the CreateWebhook command.
	Token []byte
}

WebhookOrigin provides information about the hook to parse.

Jump to

Keyboard shortcuts

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