This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 0006e810 fix: cycle import of api and api/blueprints
0006e810 is described below

commit 0006e8105d70318aff5eeee38d405fa181a32aa0
Author: zhangliang <[email protected]>
AuthorDate: Thu Sep 8 22:09:56 2022 +0800

    fix: cycle import of api and api/blueprints
---
 api/api.go                   | 2 --
 api/blueprints/blueprints.go | 9 ++++-----
 api/pipelines/pipelines.go   | 5 ++---
 api/push/push.go             | 5 ++---
 api/shared/api_output.go     | 2 ++
 api/task/task.go             | 5 ++---
 6 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/api/api.go b/api/api.go
index 737ca3d0..1ef47e10 100644
--- a/api/api.go
+++ b/api/api.go
@@ -100,5 +100,3 @@ func CreateApiService() {
                panic(err)
        }
 }
-
-const BadRequestBody = "bad request body format"
diff --git a/api/blueprints/blueprints.go b/api/blueprints/blueprints.go
index 5bbba7bf..bf4f1ad2 100644
--- a/api/blueprints/blueprints.go
+++ b/api/blueprints/blueprints.go
@@ -18,12 +18,11 @@ limitations under the License.
 package blueprints
 
 import (
-       "github.com/apache/incubator-devlake/api"
-       "github.com/apache/incubator-devlake/errors"
        "net/http"
        "strconv"
 
        "github.com/apache/incubator-devlake/api/shared"
+       "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/models"
        "github.com/apache/incubator-devlake/services"
        "github.com/gin-gonic/gin"
@@ -43,7 +42,7 @@ func Post(c *gin.Context) {
 
        err := c.ShouldBind(blueprint)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
 
@@ -68,7 +67,7 @@ func Index(c *gin.Context) {
        var query services.BlueprintQuery
        err := c.ShouldBindQuery(&query)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
        blueprints, count, err := services.GetBlueprints(&query)
@@ -168,7 +167,7 @@ func Patch(c *gin.Context) {
        var body map[string]interface{}
        err = c.ShouldBind(&body)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
        blueprint, err := services.PatchBlueprint(id, body)
diff --git a/api/pipelines/pipelines.go b/api/pipelines/pipelines.go
index ad23b81c..e8f9db39 100644
--- a/api/pipelines/pipelines.go
+++ b/api/pipelines/pipelines.go
@@ -18,14 +18,13 @@ limitations under the License.
 package pipelines
 
 import (
-       "github.com/apache/incubator-devlake/api"
-       "github.com/apache/incubator-devlake/errors"
        "net/http"
        "os"
        "path/filepath"
        "strconv"
 
        "github.com/apache/incubator-devlake/api/shared"
+       "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/models"
        "github.com/apache/incubator-devlake/services"
        "github.com/gin-gonic/gin"
@@ -96,7 +95,7 @@ func Index(c *gin.Context) {
        var query services.PipelineQuery
        err := c.ShouldBindQuery(&query)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
        pipelines, count, err := services.GetPipelines(&query)
diff --git a/api/push/push.go b/api/push/push.go
index 6b19099c..10f35860 100644
--- a/api/push/push.go
+++ b/api/push/push.go
@@ -19,11 +19,10 @@ package push
 
 import (
        "fmt"
-       "github.com/apache/incubator-devlake/api"
-       "github.com/apache/incubator-devlake/errors"
        "net/http"
 
        "github.com/apache/incubator-devlake/api/shared"
+       "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/services"
        "github.com/gin-gonic/gin"
 )
@@ -53,7 +52,7 @@ func Post(c *gin.Context) {
        var rowsToInsert []map[string]interface{}
        err = c.ShouldBindJSON(&rowsToInsert)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
        rowsAffected, err := services.InsertRow(tableName, rowsToInsert)
diff --git a/api/shared/api_output.go b/api/shared/api_output.go
index cecb77ab..a2cefd56 100644
--- a/api/shared/api_output.go
+++ b/api/shared/api_output.go
@@ -26,6 +26,8 @@ import (
        "net/http"
 )
 
+const BadRequestBody = "bad request body format"
+
 type ApiBody struct {
        Success bool   `json:"success"`
        Message string `json:"message"`
diff --git a/api/task/task.go b/api/task/task.go
index a57997cc..9a75bc3a 100644
--- a/api/task/task.go
+++ b/api/task/task.go
@@ -18,12 +18,11 @@ limitations under the License.
 package task
 
 import (
-       "github.com/apache/incubator-devlake/api"
-       "github.com/apache/incubator-devlake/errors"
        "net/http"
        "strconv"
 
        "github.com/apache/incubator-devlake/api/shared"
+       "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/services"
        "github.com/gin-gonic/gin"
 )
@@ -58,7 +57,7 @@ func Index(c *gin.Context) {
        var query services.TaskQuery
        err := c.ShouldBindQuery(&query)
        if err != nil {
-               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
api.BadRequestBody, errors.AsUserMessage()))
+               shared.ApiOutputError(c, errors.BadInput.Wrap(err, 
shared.BadRequestBody, errors.AsUserMessage()))
                return
        }
        err = c.ShouldBindUri(&query)

Reply via email to