You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/12/01 09:35:19 UTC
(incubator-devlake) branch kw-5519-jenkins created (now 1dcccdd3f)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a change to branch kw-5519-jenkins
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
at 1dcccdd3f refactor: extract MakePipelinePlanTask function
This branch includes the following new commits:
new 1a9d3a71e fix: sensitive information should be removed for Create Scope api
new 87d05f77e fix: shoud not panic when scope config is missing
new c9d6bf1ab refactor: rename gitlab remote api file
new 1dcccdd3f refactor: extract MakePipelinePlanTask function
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(incubator-devlake) 01/04: fix: sensitive information should be removed for Create Scope api
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch kw-5519-jenkins
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 1a9d3a71e9479132f0d28f494da174d560de7a32
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Dec 1 17:27:33 2023 +0800
fix: sensitive information should be removed for Create Scope api
---
backend/helpers/pluginhelper/api/model_api_helper.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/backend/helpers/pluginhelper/api/model_api_helper.go b/backend/helpers/pluginhelper/api/model_api_helper.go
index af4905eb6..f0f72bda3 100644
--- a/backend/helpers/pluginhelper/api/model_api_helper.go
+++ b/backend/helpers/pluginhelper/api/model_api_helper.go
@@ -73,6 +73,7 @@ func (self *ModelApiHelper[M]) Post(input *plugin.ApiResourceInput) (*plugin.Api
if err != nil {
return nil, err
}
+ model = self.Sanitize(model)
return &plugin.ApiResourceOutput{
Status: http.StatusCreated,
Body: model,
(incubator-devlake) 02/04: fix: shoud not panic when scope config is missing
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch kw-5519-jenkins
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 87d05f77eb8f01e23f3a25cb3a9bb55ff286c08f
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Dec 1 17:28:14 2023 +0800
fix: shoud not panic when scope config is missing
---
backend/helpers/srvhelper/scope_service_helper.go | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/backend/helpers/srvhelper/scope_service_helper.go b/backend/helpers/srvhelper/scope_service_helper.go
index 27e2257b1..a375c446a 100644
--- a/backend/helpers/srvhelper/scope_service_helper.go
+++ b/backend/helpers/srvhelper/scope_service_helper.go
@@ -159,15 +159,18 @@ func (scopeSrv *ScopeSrvHelper[C, S, SC]) getScopeConfig(scopeConfigId uint64) *
if scopeConfigId < 1 {
return nil
}
- scopeConfig := new(SC)
- errors.Must(scopeSrv.db.First(
- scopeConfig,
+ var scopeConfig SC
+ err := scopeSrv.db.First(
+ &scopeConfig,
dal.Where(
"id = ?",
scopeConfigId,
),
- ))
- return scopeConfig
+ )
+ if err != nil {
+ return nil
+ }
+ return &scopeConfig
}
func (scopeSrv *ScopeSrvHelper[C, S, SC]) getAllBlueprinsByScope(connectionId uint64, scopeId string) []*models.Blueprint {
(incubator-devlake) 03/04: refactor: rename gitlab remote api file
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch kw-5519-jenkins
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit c9d6bf1abf4cd1d928673fb20681bd638d95aae4
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Dec 1 17:32:08 2023 +0800
refactor: rename gitlab remote api file
---
backend/plugins/gitlab/api/{remote.go => remote_api.go} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/backend/plugins/gitlab/api/remote.go b/backend/plugins/gitlab/api/remote_api.go
similarity index 100%
rename from backend/plugins/gitlab/api/remote.go
rename to backend/plugins/gitlab/api/remote_api.go
(incubator-devlake) 04/04: refactor: extract MakePipelinePlanTask function
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch kw-5519-jenkins
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 1dcccdd3f2a213ac70e24723d6e9abe6a8ee214f
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Dec 1 17:34:50 2023 +0800
refactor: extract MakePipelinePlanTask function
---
backend/helpers/pluginhelper/api/pipeline_plan.go | 31 ++++++++++++++++++++++
backend/plugins/github/api/blueprint_v200.go | 24 +++++------------
.../github/api/{remote.go => remote_api.go} | 0
backend/plugins/github/tasks/task_data.go | 9 -------
4 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/pipeline_plan.go b/backend/helpers/pluginhelper/api/pipeline_plan.go
index ce920b168..4c11f6ef3 100644
--- a/backend/helpers/pluginhelper/api/pipeline_plan.go
+++ b/backend/helpers/pluginhelper/api/pipeline_plan.go
@@ -21,6 +21,7 @@ import (
"fmt"
"github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/models"
plugin "github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/core/utils"
)
@@ -52,3 +53,33 @@ func MakePipelinePlanSubtasks(subtaskMetas []plugin.SubTaskMeta, entities []stri
}
return subtasks, nil
}
+
+func MakePipelinePlanTask(
+ pluginName string,
+ subtaskMetas []plugin.SubTaskMeta,
+ entities []string,
+ options interface{},
+) (*models.PipelineTask, errors.Error) {
+ subtasks, err := MakePipelinePlanSubtasks(subtaskMetas, entities)
+ if err != nil {
+ return nil, err
+ }
+ op, err := encodeTaskOptions(options)
+ if err != nil {
+ return nil, err
+ }
+ return &models.PipelineTask{
+ Plugin: pluginName,
+ Subtasks: subtasks,
+ Options: op,
+ }, nil
+}
+
+func encodeTaskOptions(op interface{}) (map[string]interface{}, errors.Error) {
+ var result map[string]interface{}
+ err := Decode(op, &result, nil)
+ if err != nil {
+ return nil, err
+ }
+ return result, nil
+}
diff --git a/backend/plugins/github/api/blueprint_v200.go b/backend/plugins/github/api/blueprint_v200.go
index aaf85b147..156b10730 100644
--- a/backend/plugins/github/api/blueprint_v200.go
+++ b/backend/plugins/github/api/blueprint_v200.go
@@ -111,11 +111,7 @@ func makeDataSourcePipelinePlanV200(
GithubId: githubRepo.GithubId,
Name: githubRepo.FullName,
}
- options, err := tasks.EncodeTaskOptions(op)
- if err != nil {
- return nil, err
- }
- stage, err = addGithub(subtaskMetas, connection, scopeConfig.Entities, stage, options)
+ stage, err := addGithub(subtaskMetas, connection, scopeConfig.Entities, stage, op)
if err != nil {
return nil, err
}
@@ -196,7 +192,7 @@ func addGithub(
connection *models.GithubConnection,
entities []string,
stage coreModels.PipelineStage,
- options map[string]interface{},
+ options *tasks.GithubOptions,
) (coreModels.PipelineStage, errors.Error) {
// construct github(graphql) task
if connection.EnableGraphql {
@@ -206,28 +202,20 @@ func addGithub(
return nil, err
}
if pluginGq, ok := p.(plugin.PluginTask); ok {
- subtasks, err := helper.MakePipelinePlanSubtasks(pluginGq.SubTaskMetas(), entities)
+ task, err := helper.MakePipelinePlanTask("github_graphql", pluginGq.SubTaskMetas(), entities, options)
if err != nil {
return nil, err
}
- stage = append(stage, &coreModels.PipelineTask{
- Plugin: "github_graphql",
- Subtasks: subtasks,
- Options: options,
- })
+ stage = append(stage, task)
} else {
return nil, errors.BadInput.New("plugin github_graphql does not support SubTaskMetas")
}
} else {
- subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, entities)
+ task, err := helper.MakePipelinePlanTask("github", subtaskMetas, entities, options)
if err != nil {
return nil, err
}
- stage = append(stage, &coreModels.PipelineTask{
- Plugin: "github",
- Subtasks: subtasks,
- Options: options,
- })
+ stage = append(stage, task)
}
return stage, nil
}
diff --git a/backend/plugins/github/api/remote.go b/backend/plugins/github/api/remote_api.go
similarity index 100%
rename from backend/plugins/github/api/remote.go
rename to backend/plugins/github/api/remote_api.go
diff --git a/backend/plugins/github/tasks/task_data.go b/backend/plugins/github/tasks/task_data.go
index 714dbbd95..f87d57694 100644
--- a/backend/plugins/github/tasks/task_data.go
+++ b/backend/plugins/github/tasks/task_data.go
@@ -67,15 +67,6 @@ func DecodeTaskOptions(options map[string]interface{}) (*GithubOptions, errors.E
return &op, nil
}
-func EncodeTaskOptions(op *GithubOptions) (map[string]interface{}, errors.Error) {
- var result map[string]interface{}
- err := helper.Decode(op, &result, nil)
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
func ValidateTaskOptions(op *GithubOptions) errors.Error {
if op.Name == "" {
op.Name = strings.Trim(fmt.Sprintf("%s/%s", op.Owner, op.Repo), " ")