webhookparser

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

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"`
}

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

func ParseIncomingWebhook

func ParseIncomingWebhook(ctx context.Context, logger vcsclient.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 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