This is an automated email from the ASF dual-hosted git repository. lynwee pushed a commit to branch dev0613 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 0cf5184bc6973510db9fbc64990f169eac4cc92f Author: d4x1 <[email protected]> AuthorDate: Thu Jun 13 12:00:53 2024 +0800 fix(gitlab): support `ENABLE_SUBTASKS_BY_DEFAULT` --- backend/core/models/pipeline.go | 3 --- backend/plugins/gitlab/api/blueprint_V200_test.go | 4 ++-- backend/plugins/gitlab/api/blueprint_v200.go | 24 ++++++++--------------- backend/plugins/gitlab/api/init.go | 2 ++ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/backend/core/models/pipeline.go b/backend/core/models/pipeline.go index 4a0c944d9..2cdc3413f 100644 --- a/backend/core/models/pipeline.go +++ b/backend/core/models/pipeline.go @@ -29,9 +29,6 @@ type GenericPipelineTask[T any] struct { Options T `json:"options"` } -type GenericPipelineStage[T any] []*GenericPipelineTask[T] -type GenericPipelinePlan[T any] []GenericPipelineStage[T] - // PipelineTask represents a smallest unit of execution inside a PipelinePlan type PipelineTask GenericPipelineTask[map[string]interface{}] diff --git a/backend/plugins/gitlab/api/blueprint_V200_test.go b/backend/plugins/gitlab/api/blueprint_V200_test.go index f81280843..a17a88d0b 100644 --- a/backend/plugins/gitlab/api/blueprint_V200_test.go +++ b/backend/plugins/gitlab/api/blueprint_V200_test.go @@ -36,7 +36,7 @@ func mockGitlabPlugin(t *testing.T) { mockMeta := mockplugin.NewPluginMeta(t) mockMeta.On("RootPkgPath").Return("github.com/apache/incubator-devlake/plugins/gitlab") mockMeta.On("Name").Return("dummy").Maybe() - err := plugin.RegisterPlugin("gitlab", mockMeta) + err := plugin.RegisterPlugin(pluginName, mockMeta) assert.Equal(t, err, nil) } @@ -138,7 +138,7 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) { var expectPlans = coreModels.PipelinePlan{ { { - Plugin: "gitlab", + Plugin: pluginName, Subtasks: []string{ tasks.ConvertProjectMeta.Name, tasks.CollectApiIssuesMeta.Name, diff --git a/backend/plugins/gitlab/api/blueprint_v200.go b/backend/plugins/gitlab/api/blueprint_v200.go index 2596c4ba1..7190567b8 100644 --- a/backend/plugins/gitlab/api/blueprint_v200.go +++ b/backend/plugins/gitlab/api/blueprint_v200.go @@ -114,26 +114,18 @@ func makePipelinePlanV200( for _, scope := range scopeDetails { gitlabProject, scopeConfig := scope.Scope, scope.ScopeConfig var stage coreModels.PipelineStage - var err errors.Error - // get repo - - // gitlab main part - options := make(map[string]interface{}) - options["connectionId"] = connection.ID - options["projectId"] = gitlabProject.GitlabId - options["fullName"] = gitlabProject.PathWithNamespace - // construct subtasks - subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, scopeConfig.Entities) + task, err := helper.MakePipelinePlanTask(pluginName, subtaskMetas, scopeConfig.Entities, GitlabTaskOptions{ + ConnectionId: connection.ID, + ProjectId: gitlabProject.GitlabId, + FullName: gitlabProject.PathWithNamespace, + ScopeConfigId: scopeConfig.ID, + ScopeConfig: scopeConfig, + }) if err != nil { return nil, err } - - stage = append(stage, &coreModels.PipelineTask{ - Plugin: "gitlab", - Subtasks: subtasks, - Options: options, - }) + stage = append(stage, task) // collect git data by gitextractor if CODE was requested if utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CODE) || len(scopeConfig.Entities) == 0 { diff --git a/backend/plugins/gitlab/api/init.go b/backend/plugins/gitlab/api/init.go index 13148bb0c..fd63abcf0 100644 --- a/backend/plugins/gitlab/api/init.go +++ b/backend/plugins/gitlab/api/init.go @@ -25,6 +25,8 @@ import ( "github.com/go-playground/validator/v10" ) +const pluginName = "gitlab" + var vld *validator.Validate var basicRes context.BasicRes
