likyh commented on code in PR #3052:
URL: https://github.com/apache/incubator-devlake/pull/3052#discussion_r973741525


##########
plugins/webhook/api/cicd_pipeline.go:
##########
@@ -18,41 +18,202 @@ limitations under the License.
 package api
 
 import (
+       "fmt"
        "github.com/apache/incubator-devlake/errors"
+       "github.com/apache/incubator-devlake/models/domainlayer"
+       "github.com/apache/incubator-devlake/models/domainlayer/devops"
+       "github.com/apache/incubator-devlake/models/domainlayer/ticket"
        "github.com/apache/incubator-devlake/plugins/core"
+       "github.com/apache/incubator-devlake/plugins/core/dal"
+       "github.com/apache/incubator-devlake/plugins/helper"
        "github.com/apache/incubator-devlake/plugins/webhook/models"
+       "github.com/go-playground/validator/v10"
        "net/http"
        "time"
 )
 
-type WebhookPipelineRequest struct {
-       Id           string     `validate:"required"`
-       Result       string     `validate:"oneof=SUCCESS FAILURE ABORT"`
+type WebhookTaskRequest struct {
+       // PipelineName can be filled by any string unique in one pipeline
+       PipelineName string `mapstructure:"pipeline_name" validate:"required"`
+
+       Name         string     `validate:"required"` // Name should be unique 
in one pipeline
+       Result       string     `validate:"oneof=SUCCESS FAILURE ABORT 
IN_PROGRESS"`
        Status       string     `validate:"oneof=IN_PROGRESS DONE"`
        Type         string     `validate:"oneof=CI CD CI/CD"`

Review Comment:
   fixed



##########
plugins/webhook/api/cicd_pipeline.go:
##########
@@ -18,41 +18,202 @@ limitations under the License.
 package api
 
 import (
+       "fmt"
        "github.com/apache/incubator-devlake/errors"
+       "github.com/apache/incubator-devlake/models/domainlayer"
+       "github.com/apache/incubator-devlake/models/domainlayer/devops"
+       "github.com/apache/incubator-devlake/models/domainlayer/ticket"
        "github.com/apache/incubator-devlake/plugins/core"
+       "github.com/apache/incubator-devlake/plugins/core/dal"
+       "github.com/apache/incubator-devlake/plugins/helper"
        "github.com/apache/incubator-devlake/plugins/webhook/models"
+       "github.com/go-playground/validator/v10"
        "net/http"
        "time"
 )
 
-type WebhookPipelineRequest struct {
-       Id           string     `validate:"required"`
-       Result       string     `validate:"oneof=SUCCESS FAILURE ABORT"`
+type WebhookTaskRequest struct {
+       // PipelineName can be filled by any string unique in one pipeline
+       PipelineName string `mapstructure:"pipeline_name" validate:"required"`
+
+       Name         string     `validate:"required"` // Name should be unique 
in one pipeline
+       Result       string     `validate:"oneof=SUCCESS FAILURE ABORT 
IN_PROGRESS"`
        Status       string     `validate:"oneof=IN_PROGRESS DONE"`
        Type         string     `validate:"oneof=CI CD CI/CD"`
-       CreatedDate  time.Time  `mapstructure:"created_date" 
validate:"required"`
+       StartedDate  time.Time  `mapstructure:"created_date" 
validate:"required"`
        FinishedDate *time.Time `mapstructure:"finished_date"`
 
-       Repo      string `validate:"required"`
+       RepoId    string `mapstructure:"repo_id" validate:"required"` // RepoId 
should be unique string
        Branch    string
        CommitSha string `mapstructure:"commit_sha"`
 }
 
-// PostCicdPipeline
+// PostCicdTask
 // @Summary create pipeline by webhook
-// @Description Create pipeline by webhook, example: 
{"id":"A123123","result":"one of SUCCESS/FAILURE/ABORT","status":"one of 
IN_PROGRESS/DONE","type":"CI/CD","created_date":"2020-01-01T12:00:00+00:00","finished_date":"2020-01-01T12:59:59+00:00","repo":"devlake","branch":"main","commit_sha":"015e3d3b480e417aede5a1293bd61de9b0fd051d"}
+// @Description Create pipeline by webhook.<br/>
+// @Description example1: 
{"pipeline_name":"A123","name":"unit-test","result":"IN_PROGRESS","status":"IN_PROGRESS","type":"CI","created_date":"2020-01-01T12:00:00+00:00","finished_date":"2020-01-01T12:59:59+00:00","repo_id":"devlake","branch":"main","commit_sha":"015e3d3b480e417aede5a1293bd61de9b0fd051d"}<br/>

Review Comment:
   fixed, `oneof` contains not empty



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to