Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(gitlab): add subtask register #4414

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 1 addition & 40 deletions backend/plugins/gitlab/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,46 +94,7 @@ func (p Gitlab) Description() string {
}

func (p Gitlab) SubTaskMetas() []plugin.SubTaskMeta {
return []plugin.SubTaskMeta{
tasks.CollectApiIssuesMeta,
tasks.ExtractApiIssuesMeta,
tasks.CollectApiMergeRequestsMeta,
tasks.ExtractApiMergeRequestsMeta,
tasks.CollectApiMergeRequestDetailsMeta,
tasks.CollectApiMergeRequestDetailsMeta,
tasks.CollectApiMrNotesMeta,
tasks.ExtractApiMrNotesMeta,
tasks.CollectApiMrCommitsMeta,
tasks.ExtractApiMrCommitsMeta,
tasks.CollectApiPipelinesMeta,
tasks.ExtractApiPipelinesMeta,
tasks.CollectApiPipelineDetailsMeta,
tasks.ExtractApiPipelineDetailsMeta,
tasks.CollectApiJobsMeta,
tasks.ExtractApiJobsMeta,
tasks.EnrichMergeRequestsMeta,
tasks.CollectAccountsMeta,
tasks.ExtractAccountsMeta,
tasks.CollectAccountDetailsMeta,
tasks.ExtractAccountDetailsMeta,
tasks.ConvertAccountsMeta,
tasks.ConvertProjectMeta,
tasks.ConvertApiMergeRequestsMeta,
tasks.ConvertMrCommentMeta,
tasks.ConvertApiMrCommitsMeta,
tasks.ConvertIssuesMeta,
tasks.ConvertIssueLabelsMeta,
tasks.ConvertMrLabelsMeta,
tasks.ConvertCommitsMeta,
tasks.ConvertPipelineMeta,
tasks.ConvertPipelineCommitMeta,
tasks.ConvertJobMeta,
tasks.CollectApiCommitsMeta,
tasks.ExtractApiCommitsMeta,
tasks.ExtractApiMergeRequestDetailsMeta,
tasks.CollectTagMeta,
tasks.ExtractTagMeta,
}
return tasks.GetSubTaskMetaList()
}

func (p Gitlab) PrepareTaskData(taskCtx plugin.TaskContext, options map[string]interface{}) (interface{}, errors.Error) {
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/account_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (

const RAW_USER_TABLE = "gitlab_api_users"

func init() {
register(CollectAccountsMeta)
}

var CollectAccountsMeta = plugin.SubTaskMeta{
Name: "collectAccounts",
EntryPoint: CollectAccounts,
Expand Down
7 changes: 6 additions & 1 deletion backend/plugins/gitlab/tasks/account_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.
package tasks

import (
"reflect"

"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer"
Expand All @@ -26,9 +28,12 @@ import (
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
gitlabModels "github.com/apache/incubator-devlake/plugins/gitlab/models"
"reflect"
)

func init() {
register(ConvertAccountsMeta)
}

var ConvertAccountsMeta = plugin.SubTaskMeta{
Name: "convertAccounts",
EntryPoint: ConvertAccounts,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/account_detail_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (

const RAW_USER_DETAIL_TABLE = "gitlab_api_user_details"

func init() {
register(CollectAccountDetailsMeta)
}

var CollectAccountDetailsMeta = plugin.SubTaskMeta{
Name: "collectAccountDetails",
EntryPoint: CollectAccountDetails,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/account_detail_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/apache/incubator-devlake/plugins/gitlab/models"
)

func init() {
register(ExtractAccountDetailsMeta)
}

var ExtractAccountDetailsMeta = plugin.SubTaskMeta{
Name: "extractAccountDetails",
EntryPoint: ExtractAccountDetails,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/account_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/apache/incubator-devlake/plugins/gitlab/models"
)

func init() {
register(ExtractAccountsMeta)
}

var ExtractAccountsMeta = plugin.SubTaskMeta{
Name: "extractAccounts",
EntryPoint: ExtractAccounts,
Expand Down
36 changes: 36 additions & 0 deletions backend/plugins/gitlab/tasks/center.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package tasks

import (
"github.com/apache/incubator-devlake/core/plugin"
)

var subTaskMetaMap map[string]plugin.SubTaskMeta

func register(meta plugin.SubTaskMeta) {
subTaskMetaMap[meta.Name] = meta
}

func GetSubTaskMetaList() (subTasks []plugin.SubTaskMeta) {
for _, value := range subTaskMetaMap {
subTasks = append(subTasks, value)
}

return
}
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/commit_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (

const RAW_COMMIT_TABLE = "gitlab_api_commit"

func init() {
register(CollectApiCommitsMeta)
}

var CollectApiCommitsMeta = plugin.SubTaskMeta{
Name: "collectApiCommits",
EntryPoint: CollectApiCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/commit_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
"reflect"
)

func init() {
register(ConvertCommitsMeta)
}

var ConvertCommitsMeta = plugin.SubTaskMeta{
Name: "convertApiCommits",
EntryPoint: ConvertApiCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/commit_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/apache/incubator-devlake/plugins/gitlab/models"
)

func init() {
register(ExtractApiCommitsMeta)
}

var ExtractApiCommitsMeta = plugin.SubTaskMeta{
Name: "extractApiCommits",
EntryPoint: ExtractApiCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/issue_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (

const RAW_ISSUE_TABLE = "gitlab_api_issues"

func init() {
register(CollectApiIssuesMeta)
}

var CollectApiIssuesMeta = plugin.SubTaskMeta{
Name: "collectApiIssues",
EntryPoint: CollectApiIssues,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/issue_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
"strings"
)

func init() {
register(ConvertIssuesMeta)
}

var ConvertIssuesMeta = plugin.SubTaskMeta{
Name: "convertIssues",
EntryPoint: ConvertIssues,
Expand Down
7 changes: 6 additions & 1 deletion backend/plugins/gitlab/tasks/issue_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ package tasks

import (
"encoding/json"
"regexp"

"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/gitlab/models"
"regexp"
)

func init() {
register(ExtractApiIssuesMeta)
}

var ExtractApiIssuesMeta = plugin.SubTaskMeta{
Name: "extractApiIssues",
EntryPoint: ExtractApiIssues,
Expand Down
7 changes: 6 additions & 1 deletion backend/plugins/gitlab/tasks/issue_label_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ limitations under the License.
package tasks

import (
"reflect"

"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/gitlab/models"
"reflect"
)

func init() {
register(ConvertIssueLabelsMeta)
}

var ConvertIssueLabelsMeta = plugin.SubTaskMeta{
Name: "convertIssueLabels",
EntryPoint: ConvertIssueLabels,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/job_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (

const RAW_JOB_TABLE = "gitlab_api_job"

func init() {
register(CollectApiJobsMeta)
}

var CollectApiJobsMeta = plugin.SubTaskMeta{
Name: "collectApiJobs",
EntryPoint: CollectApiJobs,
Expand Down
7 changes: 6 additions & 1 deletion backend/plugins/gitlab/tasks/job_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.
package tasks

import (
"reflect"

"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer"
Expand All @@ -26,9 +28,12 @@ import (
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
gitlabModels "github.com/apache/incubator-devlake/plugins/gitlab/models"
"reflect"
)

func init() {
register(ConvertJobMeta)
}

var ConvertJobMeta = plugin.SubTaskMeta{
Name: "convertJobs",
EntryPoint: ConvertJobs,
Expand Down
5 changes: 5 additions & 0 deletions backend/plugins/gitlab/tasks/job_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tasks

import (
"encoding/json"

"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
Expand All @@ -44,6 +45,10 @@ type ApiJob struct {
FinishedAt *api.Iso8601Time `json:"finished_at"`
}

func init() {
register(ExtractApiJobsMeta)
}

var ExtractApiJobsMeta = plugin.SubTaskMeta{
Name: "extractApiJobs",
EntryPoint: ExtractApiJobs,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (

const RAW_MERGE_REQUEST_TABLE = "gitlab_api_merge_requests"

func init() {
register(CollectApiMergeRequestsMeta)
}

var CollectApiMergeRequestsMeta = plugin.SubTaskMeta{
Name: "collectApiMergeRequests",
EntryPoint: CollectApiMergeRequests,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_comment_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
"reflect"
)

func init() {
register(ConvertMrCommentMeta)
}

var ConvertMrCommentMeta = plugin.SubTaskMeta{
Name: "convertMergeRequestComment",
EntryPoint: ConvertMergeRequestComment,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_commit_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (

const RAW_MERGE_REQUEST_COMMITS_TABLE = "gitlab_api_merge_request_commits"

func init() {
register(CollectApiMrCommitsMeta)
}

var CollectApiMrCommitsMeta = plugin.SubTaskMeta{
Name: "collectApiMergeRequestsCommits",
EntryPoint: CollectApiMergeRequestsCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_commit_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
"reflect"
)

func init() {
register(ConvertApiMrCommitsMeta)
}

var ConvertApiMrCommitsMeta = plugin.SubTaskMeta{
Name: "convertApiMergeRequestsCommits",
EntryPoint: ConvertApiMergeRequestsCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_commit_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/apache/incubator-devlake/plugins/gitlab/models"
)

func init() {
register(ExtractApiMrCommitsMeta)
}

var ExtractApiMrCommitsMeta = plugin.SubTaskMeta{
Name: "extractApiMergeRequestsCommits",
EntryPoint: ExtractApiMergeRequestsCommits,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
"reflect"
)

func init() {
register(ConvertApiMergeRequestsMeta)
}

var ConvertApiMergeRequestsMeta = plugin.SubTaskMeta{
Name: "convertApiMergeRequests",
EntryPoint: ConvertApiMergeRequests,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_detail_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (

const RAW_MERGE_REQUEST_DETAIL_TABLE = "gitlab_api_merge_request_details"

func init() {
register(CollectApiMergeRequestDetailsMeta)
}

var CollectApiMergeRequestDetailsMeta = plugin.SubTaskMeta{
Name: "collectApiMergeRequestDetails",
EntryPoint: CollectApiMergeRequestDetails,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/gitlab/tasks/mr_detail_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"github.com/apache/incubator-devlake/plugins/gitlab/models"
)

func init() {
register(ExtractApiMergeRequestDetailsMeta)
}

var ExtractApiMergeRequestDetailsMeta = plugin.SubTaskMeta{
Name: "extractApiMergeRequestDetails",
EntryPoint: ExtractApiMergeRequestDetails,
Expand Down
Loading