From 2b28df27504f64ddb8760fa4dd5015d83af8b71d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:36:40 +0800 Subject: [PATCH] fix: gitlab server extract deployment may fail (#6754) (#6756) Co-authored-by: Klesh Wong --- backend/plugins/gitlab/models/deployment.go | 20 +++++++++---------- .../gitlab/tasks/deployment_extractor.go | 16 +++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/backend/plugins/gitlab/models/deployment.go b/backend/plugins/gitlab/models/deployment.go index c2dad5d46d0..d3a01a06458 100644 --- a/backend/plugins/gitlab/models/deployment.go +++ b/backend/plugins/gitlab/models/deployment.go @@ -29,9 +29,9 @@ type GitlabDeployment struct { ConnectionId uint64 `json:"connection_id" gorm:"primaryKey"` GitlabId int `json:"gitlab_id" gorm:"primaryKey"` - CreatedDate time.Time `json:"created_date"` - UpdatedDate time.Time `json:"updated_date"` - Status string `json:"status"` //created, running, success, failed, canceled, or blocked + CreatedDate time.Time `json:"created_date"` + UpdatedDate *time.Time `json:"updated_date"` + Status string `json:"status"` //created, running, success, failed, canceled, or blocked DeploymentId int `json:"id" gorm:"primaryKey"` Iid int `json:"iid"` @@ -78,13 +78,13 @@ type GitlabDeployment struct { DeployableUserWebsiteURL string `json:"deployable_user_website_url" gorm:"type:varchar(255)"` DeployableUserOrganization string `json:"deployable_user_organization" gorm:"type:varchar(255)"` - DeployablePipelineCreatedAt time.Time `json:"deployable_pipeline_created_at"` - DeployablePipelineID int `json:"deployable_pipeline_id"` - DeployablePipelineRef string `json:"deployable_pipeline_ref" gorm:"type:varchar(255)"` - DeployablePipelineSha string `json:"deployable_pipeline_sha" gorm:"type:varchar(255)"` - DeployablePipelineStatus string `json:"deployable_pipeline_status" gorm:"type:varchar(255)"` - DeployablePipelineUpdatedAt time.Time `json:"deployable_pipeline_updated_at"` - DeployablePipelineWebURL string `json:"deployable_pipeline_web_url" gorm:"type:varchar(255)"` + DeployablePipelineCreatedAt *time.Time `json:"deployable_pipeline_created_at"` + DeployablePipelineID int `json:"deployable_pipeline_id"` + DeployablePipelineRef string `json:"deployable_pipeline_ref" gorm:"type:varchar(255)"` + DeployablePipelineSha string `json:"deployable_pipeline_sha" gorm:"type:varchar(255)"` + DeployablePipelineStatus string `json:"deployable_pipeline_status" gorm:"type:varchar(255)"` + DeployablePipelineUpdatedAt *time.Time `json:"deployable_pipeline_updated_at"` + DeployablePipelineWebURL string `json:"deployable_pipeline_web_url" gorm:"type:varchar(255)"` UserAvatarURL string `json:"user_avatar_url" gorm:"type:varchar(255)"` UserID int `json:"user_id"` diff --git a/backend/plugins/gitlab/tasks/deployment_extractor.go b/backend/plugins/gitlab/tasks/deployment_extractor.go index 264037415db..d8b2727c834 100644 --- a/backend/plugins/gitlab/tasks/deployment_extractor.go +++ b/backend/plugins/gitlab/tasks/deployment_extractor.go @@ -70,7 +70,7 @@ func ExtractDeployment(taskCtx plugin.SubTaskContext) errors.Error { type GitlabDeploymentResp struct { CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + UpdatedAt *time.Time `json:"updated_at"` Status string `json:"status"` Deployable GitlabDeploymentDeployable `json:"deployable"` Environment GitlabDeploymentEnvironment `json:"environment"` @@ -178,13 +178,13 @@ type GitlabDeploymentFullUser struct { } type GitlabDeploymentPipeline struct { - CreatedAt time.Time `json:"created_at"` - ID int `json:"id"` - Ref string `json:"ref"` - Sha string `json:"sha"` - Status string `json:"status"` - UpdatedAt time.Time `json:"updated_at"` - WebURL string `json:"web_url"` + CreatedAt *time.Time `json:"created_at"` + ID int `json:"id"` + Ref string `json:"ref"` + Sha string `json:"sha"` + Status string `json:"status"` + UpdatedAt *time.Time `json:"updated_at"` + WebURL string `json:"web_url"` } type GitlabDeploymentDeployable struct {