From aa0cc3fa1eb698eaacaf8154e9084dc1daa27095 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 31 May 2024 11:08:29 +0800 Subject: [PATCH 1/3] refactor: align webhook deployment API request body and db schema --- backend/plugins/webhook/api/deployments.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/backend/plugins/webhook/api/deployments.go b/backend/plugins/webhook/api/deployments.go index 917749861b7..53b9896d40f 100644 --- a/backend/plugins/webhook/api/deployments.go +++ b/backend/plugins/webhook/api/deployments.go @@ -39,18 +39,18 @@ import ( ) type WebhookDeploymentReq struct { - Id string `mapstructure:"id"` + Id string `mapstructure:"id" validate:"required"` DisplayTitle string `mapstructure:"displayTitle"` - PipelineId string `mapstructure:"pipelineId" validate:"required"` + PipelineId string `mapstructure:"pipelineId"` Result string `mapstructure:"result"` Environment string `validate:"omitempty,oneof=PRODUCTION STAGING TESTING DEVELOPMENT"` Name string `mapstructure:"name"` // DeploymentCommits is used for multiple commits in one deployment DeploymentCommits []WebhookDeploymentCommitReq `mapstructure:"deploymentCommits" validate:"omitempty,dive"` - CreatedDate *time.Time `mapstructure:"createdTime"` + CreatedDate *time.Time `mapstructure:"createdDate"` // QueuedDate *time.Time `mapstructure:"queue_time"` - StartedDate *time.Time `mapstructure:"startedTime" validate:"required"` - FinishedDate *time.Time `mapstructure:"endedTime"` + StartedDate *time.Time `mapstructure:"startedDate" validate:"required"` + FinishedDate *time.Time `mapstructure:"finishedDate"` } type WebhookDeploymentCommitReq struct { @@ -63,10 +63,10 @@ type WebhookDeploymentCommitReq struct { CommitMsg string `mapstructure:"commitMsg"` Result string `mapstructure:"result"` Status string `mapstructure:"status"` - CreatedDate *time.Time `mapstructure:"createdTime"` + CreatedDate *time.Time `mapstructure:"createdDate"` // QueuedDate *time.Time `mapstructure:"queue_time"` - StartedDate *time.Time `mapstructure:"startedTime"` - FinishedDate *time.Time `mapstructure:"endedTime"` + StartedDate *time.Time `mapstructure:"startedDate" validate:"required"` + FinishedDate *time.Time `mapstructure:"finishedDate"` } // PostDeployments @@ -121,9 +121,6 @@ func CreateDeploymentAndDeploymentCommits(connection *models.WebhookConnection, } // set default values for optional fields deploymentId := request.Id - if deploymentId == "" { - deploymentId = request.PipelineId - } scopeId := fmt.Sprintf("%s:%d", "webhook", connection.ID) if request.CreatedDate == nil { request.CreatedDate = request.StartedDate From 65a8c487677b1b72749891b9630fd935ccaa6be0 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 31 May 2024 11:10:25 +0800 Subject: [PATCH 2/3] refactor: webhook issues api request body spelling --- .../webhook/api/{incident.go => issues.go} | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) rename backend/plugins/webhook/api/{incident.go => issues.go} (85%) diff --git a/backend/plugins/webhook/api/incident.go b/backend/plugins/webhook/api/issues.go similarity index 85% rename from backend/plugins/webhook/api/incident.go rename to backend/plugins/webhook/api/issues.go index 456c899a569..96c695a2826 100644 --- a/backend/plugins/webhook/api/incident.go +++ b/backend/plugins/webhook/api/issues.go @@ -35,27 +35,27 @@ import ( type WebhookIssueRequest struct { Url string `mapstructure:"url"` - IssueKey string `mapstructure:"issue_key" validate:"required"` + IssueKey string `mapstructure:"issueKey" validate:"required"` Title string `mapstructure:"title" validate:"required"` Description string `mapstructure:"description"` - EpicKey string `mapstructure:"epic_key"` + EpicKey string `mapstructure:"epicKey"` Type string `mapstructure:"type"` Status string `mapstructure:"status" validate:"oneof=TODO DONE IN_PROGRESS"` - OriginalStatus string `mapstructure:"original_status" validate:"required"` - StoryPoint float64 `mapstructure:"story_point"` - ResolutionDate *time.Time `mapstructure:"resolution_date"` - CreatedDate *time.Time `mapstructure:"created_date" validate:"required"` - UpdatedDate *time.Time `mapstructure:"updated_date"` - LeadTimeMinutes uint `mapstructure:"lead_time_minutes"` - ParentIssueKey string `mapstructure:"parent_issue_key"` + OriginalStatus string `mapstructure:"originalStatus" validate:"required"` + StoryPoint float64 `mapstructure:"storyPoint"` + ResolutionDate *time.Time `mapstructure:"resolutionDate"` + CreatedDate *time.Time `mapstructure:"createdDate" validate:"required"` + UpdatedDate *time.Time `mapstructure:"updatedDate"` + LeadTimeMinutes uint `mapstructure:"leadTimeMinutes"` + ParentIssueKey string `mapstructure:"parentIssueKey"` Priority string `mapstructure:"priority"` - OriginalEstimateMinutes int64 `mapstructure:"original_estimate_minutes"` - TimeSpentMinutes int64 `mapstructure:"time_spent_minutes"` - TimeRemainingMinutes int64 `mapstructure:"time_remaining_minutes"` - CreatorId string `mapstructure:"creator_id"` - CreatorName string `mapstructure:"creator_name"` - AssigneeId string `mapstructure:"assignee_id"` - AssigneeName string `mapstructure:"assignee_name"` + OriginalEstimateMinutes int64 `mapstructure:"originalEstimateMinutes"` + TimeSpentMinutes int64 `mapstructure:"timeSpentMinutes"` + TimeRemainingMinutes int64 `mapstructure:"timeRemainingMinutes"` + CreatorId string `mapstructure:"creatorId"` + CreatorName string `mapstructure:"creatorName"` + AssigneeId string `mapstructure:"assigneeId"` + AssigneeName string `mapstructure:"assigneeName"` Severity string `mapstructure:"severity"` Component string `mapstructure:"component"` //IconURL string From 2747cad96462dc725ac45febc03fa5db0f644185 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 31 May 2024 11:14:47 +0800 Subject: [PATCH 3/3] refactor: removing unused pipelineId from webhook deployment api --- backend/plugins/webhook/api/deployments.go | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/plugins/webhook/api/deployments.go b/backend/plugins/webhook/api/deployments.go index 53b9896d40f..005186004ad 100644 --- a/backend/plugins/webhook/api/deployments.go +++ b/backend/plugins/webhook/api/deployments.go @@ -41,7 +41,6 @@ import ( type WebhookDeploymentReq struct { Id string `mapstructure:"id" validate:"required"` DisplayTitle string `mapstructure:"displayTitle"` - PipelineId string `mapstructure:"pipelineId"` Result string `mapstructure:"result"` Environment string `validate:"omitempty,oneof=PRODUCTION STAGING TESTING DEVELOPMENT"` Name string `mapstructure:"name"`