diff --git a/vcsutils/webhookparser/bitbucketcloud.go b/vcsutils/webhookparser/bitbucketcloud.go index 8523f9b6..4b71b256 100644 --- a/vcsutils/webhookparser/bitbucketcloud.go +++ b/vcsutils/webhookparser/bitbucketcloud.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "net/http" + "strings" "time" "github.com/jfrog/froggit-go/vcsutils" @@ -55,22 +56,32 @@ func (webhook *BitbucketCloudWebhook) parseIncomingWebhook(payload []byte) (*Web func (webhook *BitbucketCloudWebhook) parsePushEvent(bitbucketCloudWebHook *bitbucketCloudWebHook) *WebhookInfo { return &WebhookInfo{ - Repository: bitbucketCloudWebHook.Repository.FullName, - Branch: bitbucketCloudWebHook.Push.Changes[0].New.Name, - Timestamp: bitbucketCloudWebHook.Push.Changes[0].New.Target.Date.UTC().Unix(), - Event: vcsutils.Push, + TargetRepositoryDetails: webhook.parseRepoFullName(bitbucketCloudWebHook.Repository.FullName), + TargetBranch: bitbucketCloudWebHook.Push.Changes[0].New.Name, + Timestamp: bitbucketCloudWebHook.Push.Changes[0].New.Target.Date.UTC().Unix(), + Event: vcsutils.Push, } } func (webhook *BitbucketCloudWebhook) parsePrEvents(bitbucketCloudWebHook *bitbucketCloudWebHook, event vcsutils.WebhookEvent) *WebhookInfo { return &WebhookInfo{ - PullRequestId: bitbucketCloudWebHook.PullRequest.Id, - Repository: bitbucketCloudWebHook.PullRequest.Destination.Repository.FullName, - Branch: bitbucketCloudWebHook.PullRequest.Destination.Branch.Name, - SourceRepository: bitbucketCloudWebHook.PullRequest.Source.Repository.FullName, - SourceBranch: bitbucketCloudWebHook.PullRequest.Source.Branch.Name, - Timestamp: bitbucketCloudWebHook.PullRequest.UpdatedOn.UTC().Unix(), - Event: event, + PullRequestId: bitbucketCloudWebHook.PullRequest.Id, + TargetRepositoryDetails: webhook.parseRepoFullName(bitbucketCloudWebHook.PullRequest.Destination.Repository.FullName), + TargetBranch: bitbucketCloudWebHook.PullRequest.Destination.Branch.Name, + SourceRepositoryDetails: webhook.parseRepoFullName(bitbucketCloudWebHook.PullRequest.Source.Repository.FullName), + SourceBranch: bitbucketCloudWebHook.PullRequest.Source.Branch.Name, + Timestamp: bitbucketCloudWebHook.PullRequest.UpdatedOn.UTC().Unix(), + Event: event, + } +} + +func (webhook *BitbucketCloudWebhook) parseRepoFullName(fullName string) WebHookInfoRepoDetails { + // From https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Repository + // "full_name : The workspace and repository slugs joined with a '/'." + split := strings.Split(fullName, "/") + return WebHookInfoRepoDetails{ + Name: split[1], + Owner: split[0], } } diff --git a/vcsutils/webhookparser/bitbucketcloud_test.go b/vcsutils/webhookparser/bitbucketcloud_test.go index 2d9f032c..4314ae0d 100644 --- a/vcsutils/webhookparser/bitbucketcloud_test.go +++ b/vcsutils/webhookparser/bitbucketcloud_test.go @@ -31,8 +31,9 @@ func TestBitbucketCloudParseIncomingPushWebhook(t *testing.T) { assert.NoError(t, err) // Check values - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketCloudPushExpectedTime, actual.Timestamp) assert.Equal(t, vcsutils.Push, actual.Event) } @@ -52,10 +53,12 @@ func TestBitbucketCloudParseIncomingPrCreateWebhook(t *testing.T) { // Check values assert.Equal(t, bitbucketCloudExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketCloudPrCreateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrCreated, actual.Event) } @@ -75,10 +78,12 @@ func TestBitbucketCloudParseIncomingPrUpdateWebhook(t *testing.T) { // Check values assert.Equal(t, bitbucketCloudExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketCloudPrUpdateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrEdited, actual.Event) } diff --git a/vcsutils/webhookparser/bitbucketserver.go b/vcsutils/webhookparser/bitbucketserver.go index 6b6241b7..5efbcd8a 100644 --- a/vcsutils/webhookparser/bitbucketserver.go +++ b/vcsutils/webhookparser/bitbucketserver.go @@ -74,27 +74,35 @@ func (webhook *BitbucketServerWebhook) parsePushEvent(bitbucketCloudWebHook *bit if err != nil { return nil, err } + repository := bitbucketCloudWebHook.Repository return &WebhookInfo{ - Repository: getFullRepositoryName(bitbucketCloudWebHook.Repository), - Branch: strings.TrimPrefix(bitbucketCloudWebHook.Changes[0].RefId, "refs/heads/"), - Timestamp: eventTime.UTC().Unix(), - Event: vcsutils.Push, + TargetRepositoryDetails: webhook.getRepositoryDetails(repository), + TargetBranch: strings.TrimPrefix(bitbucketCloudWebHook.Changes[0].RefId, "refs/heads/"), + Timestamp: eventTime.UTC().Unix(), + Event: vcsutils.Push, }, nil } +func (webhook *BitbucketServerWebhook) getRepositoryDetails(repository bitbucketv1.Repository) WebHookInfoRepoDetails { + return WebHookInfoRepoDetails{ + Name: repository.Slug, + Owner: strings.TrimPrefix(strings.ToLower(repository.Project.Key), "~"), + } +} + func (webhook *BitbucketServerWebhook) parsePrEvents(bitbucketCloudWebHook *bitbucketServerWebHook, event vcsutils.WebhookEvent) (*WebhookInfo, error) { eventTime, err := time.Parse("2006-01-02T15:04:05-0700", bitbucketCloudWebHook.Date) if err != nil { return nil, err } return &WebhookInfo{ - PullRequestId: bitbucketCloudWebHook.PullRequest.ID, - Repository: getFullRepositoryName(bitbucketCloudWebHook.PullRequest.ToRef.Repository), - Branch: strings.TrimPrefix(bitbucketCloudWebHook.PullRequest.ToRef.ID, "refs/heads/"), - SourceRepository: getFullRepositoryName(bitbucketCloudWebHook.PullRequest.FromRef.Repository), - SourceBranch: strings.TrimPrefix(bitbucketCloudWebHook.PullRequest.FromRef.ID, "refs/heads/"), - Timestamp: eventTime.UTC().Unix(), - Event: event, + PullRequestId: bitbucketCloudWebHook.PullRequest.ID, + TargetRepositoryDetails: webhook.getRepositoryDetails(bitbucketCloudWebHook.PullRequest.ToRef.Repository), + TargetBranch: strings.TrimPrefix(bitbucketCloudWebHook.PullRequest.ToRef.ID, "refs/heads/"), + SourceRepositoryDetails: webhook.getRepositoryDetails(bitbucketCloudWebHook.PullRequest.FromRef.Repository), + SourceBranch: strings.TrimPrefix(bitbucketCloudWebHook.PullRequest.FromRef.ID, "refs/heads/"), + Timestamp: eventTime.UTC().Unix(), + Event: event, }, nil } @@ -107,7 +115,3 @@ type bitbucketServerWebHook struct { RefId string `json:"refId,omitempty"` } `json:"changes,omitempty"` } - -func getFullRepositoryName(repository bitbucketv1.Repository) string { - return strings.ToLower(repository.Project.Key) + "/" + repository.Name -} diff --git a/vcsutils/webhookparser/bitbucketserver_test.go b/vcsutils/webhookparser/bitbucketserver_test.go index b35b8a35..18cd5105 100644 --- a/vcsutils/webhookparser/bitbucketserver_test.go +++ b/vcsutils/webhookparser/bitbucketserver_test.go @@ -38,8 +38,9 @@ func TestBitbucketServerParseIncomingPushWebhook(t *testing.T) { assert.NoError(t, err) // Check values - assert.Equal(t, "~"+expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketServerPushExpectedTime, actual.Timestamp) assert.Equal(t, vcsutils.Push, actual.Event) } @@ -60,10 +61,12 @@ func TestBitbucketServerParseIncomingPrCreateWebhook(t *testing.T) { // Check values assert.Equal(t, bitbucketServerExpectedPrId, actual.PullRequestId) - assert.Equal(t, "~"+expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketServerPrCreateExpectedTime, actual.Timestamp) - assert.Equal(t, "~"+expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrCreated, actual.Event) } @@ -84,10 +87,12 @@ func TestBitbucketServerParseIncomingPrUpdateWebhook(t *testing.T) { // Check values assert.Equal(t, bitbucketServerExpectedPrId, actual.PullRequestId) - assert.Equal(t, "~"+expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, bitbucketServerPrUpdateExpectedTime, actual.Timestamp) - assert.Equal(t, "~"+expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrEdited, actual.Event) } diff --git a/vcsutils/webhookparser/common_test.go b/vcsutils/webhookparser/common_test.go index 2ef63440..230d5a18 100644 --- a/vcsutils/webhookparser/common_test.go +++ b/vcsutils/webhookparser/common_test.go @@ -3,7 +3,8 @@ package webhookparser import "os" const ( - expectedRepoName = "yahavi/hello-world" + expectedOwner = "yahavi" + expectedRepoName = "hello-world" expectedBranch = "main" expectedSourceBranch = "dev" ) diff --git a/vcsutils/webhookparser/github.go b/vcsutils/webhookparser/github.go index 6bc7cd5f..58b1e70e 100644 --- a/vcsutils/webhookparser/github.go +++ b/vcsutils/webhookparser/github.go @@ -48,10 +48,13 @@ func (webhook *GitHubWebhook) parseIncomingWebhook(payload []byte) (*WebhookInfo func (webhook *GitHubWebhook) parsePushEvent(event *github.PushEvent) *WebhookInfo { return &WebhookInfo{ - Repository: event.GetRepo().GetFullName(), - Branch: strings.TrimPrefix(event.GetRef(), "refs/heads/"), - Timestamp: event.GetHeadCommit().GetTimestamp().UTC().Unix(), - Event: vcsutils.Push, + TargetRepositoryDetails: WebHookInfoRepoDetails{ + Name: *event.GetRepo().Name, + Owner: *event.GetRepo().Owner.Login, + }, + TargetBranch: strings.TrimPrefix(event.GetRef(), "refs/heads/"), + Timestamp: event.GetHeadCommit().GetTimestamp().UTC().Unix(), + Event: vcsutils.Push, } } @@ -66,12 +69,18 @@ func (webhook *GitHubWebhook) parsePrEvents(event *github.PullRequestEvent) *Web return nil } return &WebhookInfo{ - PullRequestId: event.GetPullRequest().GetNumber(), - Repository: event.GetPullRequest().GetBase().GetRepo().GetFullName(), - Branch: event.GetPullRequest().GetBase().GetRef(), - SourceRepository: event.GetPullRequest().GetHead().GetRepo().GetFullName(), - SourceBranch: event.GetPullRequest().GetHead().GetRef(), - Timestamp: event.GetPullRequest().GetUpdatedAt().UTC().Unix(), - Event: webhookEvent, + PullRequestId: event.GetPullRequest().GetNumber(), + TargetRepositoryDetails: WebHookInfoRepoDetails{ + Name: *event.GetPullRequest().GetBase().GetRepo().Name, + Owner: *event.GetPullRequest().GetBase().GetRepo().Owner.Login, + }, + TargetBranch: event.GetPullRequest().GetBase().GetRef(), + SourceRepositoryDetails: WebHookInfoRepoDetails{ + Name: *event.GetPullRequest().GetHead().GetRepo().Name, + Owner: *event.GetPullRequest().GetHead().GetRepo().Owner.Login, + }, + SourceBranch: event.GetPullRequest().GetHead().GetRef(), + Timestamp: event.GetPullRequest().GetUpdatedAt().UTC().Unix(), + Event: webhookEvent, } } diff --git a/vcsutils/webhookparser/github_test.go b/vcsutils/webhookparser/github_test.go index 75cbbed3..eda4a278 100644 --- a/vcsutils/webhookparser/github_test.go +++ b/vcsutils/webhookparser/github_test.go @@ -43,8 +43,9 @@ func TestGitHubParseIncomingPushWebhook(t *testing.T) { assert.NoError(t, err) // Check values - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, githubPushExpectedTime, actual.Timestamp) assert.Equal(t, vcsutils.Push, actual.Event) } @@ -66,10 +67,12 @@ func TestGitHubParseIncomingPrCreateWebhook(t *testing.T) { // Check values assert.Equal(t, gitHubExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, githubPrCreateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrCreated, actual.Event) } @@ -91,10 +94,12 @@ func TestGitHubParseIncomingPrUpdateWebhook(t *testing.T) { // Check values assert.Equal(t, gitHubExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, githubPrUpdateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrEdited, actual.Event) } diff --git a/vcsutils/webhookparser/gitlab.go b/vcsutils/webhookparser/gitlab.go index 3265af3d..cd5cb5a2 100644 --- a/vcsutils/webhookparser/gitlab.go +++ b/vcsutils/webhookparser/gitlab.go @@ -53,10 +53,18 @@ func (webhook *GitLabWebhook) parseIncomingWebhook(payload []byte) (*WebhookInfo func (webhook *GitLabWebhook) parsePushEvent(event *gitlab.PushEvent) *WebhookInfo { return &WebhookInfo{ - Repository: event.Project.PathWithNamespace, - Branch: strings.TrimPrefix(event.Ref, "refs/heads/"), - Timestamp: event.Commits[0].Timestamp.Local().Unix(), - Event: vcsutils.Push, + TargetRepositoryDetails: webhook.parseRepoDetails(event.Project.PathWithNamespace), + TargetBranch: strings.TrimPrefix(event.Ref, "refs/heads/"), + Timestamp: event.Commits[0].Timestamp.Local().Unix(), + Event: vcsutils.Push, + } +} + +func (webhook *GitLabWebhook) parseRepoDetails(pathWithNamespace string) WebHookInfoRepoDetails { + split := strings.Split(pathWithNamespace, "/") + return WebHookInfoRepoDetails{ + Name: split[1], + Owner: split[0], } } @@ -72,12 +80,12 @@ func (webhook *GitLabWebhook) parsePrEvents(event *gitlab.MergeEvent) (*WebhookI return nil, err } return &WebhookInfo{ - PullRequestId: event.ObjectAttributes.IID, - SourceRepository: event.ObjectAttributes.Source.PathWithNamespace, - SourceBranch: event.ObjectAttributes.SourceBranch, - Repository: event.ObjectAttributes.Target.PathWithNamespace, - Branch: event.ObjectAttributes.TargetBranch, - Timestamp: eventTime.UTC().Unix(), - Event: webhookEvent, + PullRequestId: event.ObjectAttributes.IID, + SourceRepositoryDetails: webhook.parseRepoDetails(event.ObjectAttributes.Source.PathWithNamespace), + SourceBranch: event.ObjectAttributes.SourceBranch, + TargetRepositoryDetails: webhook.parseRepoDetails(event.ObjectAttributes.Target.PathWithNamespace), + TargetBranch: event.ObjectAttributes.TargetBranch, + Timestamp: eventTime.UTC().Unix(), + Event: webhookEvent, }, nil } diff --git a/vcsutils/webhookparser/gitlab_test.go b/vcsutils/webhookparser/gitlab_test.go index 1e31c64c..ef28517a 100644 --- a/vcsutils/webhookparser/gitlab_test.go +++ b/vcsutils/webhookparser/gitlab_test.go @@ -33,8 +33,9 @@ func TestGitLabParseIncomingPushWebhook(t *testing.T) { assert.NoError(t, err) // Check values - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, gitlabPushExpectedTime, actual.Timestamp) assert.Equal(t, vcsutils.Push, actual.Event) } @@ -55,10 +56,12 @@ func TestGitLabParseIncomingPrCreateWebhook(t *testing.T) { // Check values assert.Equal(t, gitlabExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, gitlabPrCreateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrCreated, actual.Event) } @@ -79,10 +82,12 @@ func TestGitLabParseIncomingPrUpdateWebhook(t *testing.T) { // Check values assert.Equal(t, gitlabExpectedPrId, actual.PullRequestId) - assert.Equal(t, expectedRepoName, actual.Repository) - assert.Equal(t, expectedBranch, actual.Branch) + assert.Equal(t, expectedRepoName, actual.TargetRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.TargetRepositoryDetails.Owner) + assert.Equal(t, expectedBranch, actual.TargetBranch) assert.Equal(t, gitlabPrUpdateExpectedTime, actual.Timestamp) - assert.Equal(t, expectedRepoName, actual.SourceRepository) + assert.Equal(t, expectedRepoName, actual.SourceRepositoryDetails.Name) + assert.Equal(t, expectedOwner, actual.SourceRepositoryDetails.Owner) assert.Equal(t, expectedSourceBranch, actual.SourceBranch) assert.Equal(t, vcsutils.PrEdited, actual.Event) } diff --git a/vcsutils/webhookparser/webhookparser.go b/vcsutils/webhookparser/webhookparser.go index 898e2710..cc076105 100644 --- a/vcsutils/webhookparser/webhookparser.go +++ b/vcsutils/webhookparser/webhookparser.go @@ -11,13 +11,13 @@ const EventHeaderKey = "X-Event-Key" // This struct is used for parsing an incoming webhook request from the VCS provider. type WebhookInfo struct { // The target repository for pull requests and push - Repository string `json:"repository,omitempty"` + TargetRepositoryDetails WebHookInfoRepoDetails `json:"target_repository_details,omitempty"` // The target branch for pull requests and push - Branch string `json:"branch,omitempty"` + TargetBranch string `json:"branch,omitempty"` // Pull request id PullRequestId int `json:"pull_request_id,omitempty"` // The source repository for pull requests - SourceRepository string `json:"source_repository,omitempty"` + SourceRepositoryDetails WebHookInfoRepoDetails `json:"source_repository_details,omitempty"` // The source branch for pull requests SourceBranch string `json:"source_branch,omitempty"` // Seconds from epoch @@ -26,6 +26,11 @@ type WebhookInfo struct { Event vcsutils.WebhookEvent `json:"event,omitempty"` } +type WebHookInfoRepoDetails struct { + Name string `json:"name,omitempty"` + Owner string `json:"owner,omitempty"` +} + type WebhookParser interface { // Validate the webhook payload with the expected token and return the payload validatePayload(token []byte) ([]byte, error)