MCPcopy Create free account
hub / github.com/apache/devlake / makeScopeV200

Function makeScopeV200

backend/plugins/gitlab/api/blueprint_v200.go:71–112  ·  view source on GitHub ↗
(
	connectionId uint64,
	scopeDetails []*srvhelper.ScopeDetail[models.GitlabProject, models.GitlabScopeConfig],
)

Source from the content-addressed store, hash-verified

69}
70
71func makeScopeV200(
72 connectionId uint64,
73 scopeDetails []*srvhelper.ScopeDetail[models.GitlabProject, models.GitlabScopeConfig],
74) ([]plugin.Scope, errors.Error) {
75 sc := make([]plugin.Scope, 0, 3*len(scopeDetails))
76
77 for _, scope := range scopeDetails {
78 gitlabProject, scopeConfig := scope.Scope, scope.ScopeConfig
79 id := didgen.NewDomainIdGenerator(&models.GitlabProject{}).Generate(connectionId, gitlabProject.GitlabId)
80
81 // if no entities specified, use all entities enabled by default
82 if len(scopeConfig.Entities) == 0 {
83 scopeConfig.Entities = plugin.DOMAIN_TYPES
84 }
85
86 if utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CODE_REVIEW) ||
87 utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CODE) ||
88 utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CROSS) {
89 // if we don't need to collect gitex, we need to add repo to scopes here
90 scopeRepo := code.NewRepo(id, gitlabProject.PathWithNamespace)
91
92 if gitlabProject.ForkedFromProjectWebUrl != "" {
93 scopeRepo.ForkedFrom = gitlabProject.ForkedFromProjectWebUrl
94 }
95 sc = append(sc, scopeRepo)
96 }
97
98 // add cicd_scope to scopes
99 if utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_CICD) {
100 scopeCICD := devops.NewCicdScope(id, gitlabProject.PathWithNamespace)
101 sc = append(sc, scopeCICD)
102 }
103
104 // add board to scopes
105 if utils.StringsContains(scopeConfig.Entities, plugin.DOMAIN_TYPE_TICKET) {
106 scopeTicket := ticket.NewBoard(id, gitlabProject.PathWithNamespace)
107 sc = append(sc, scopeTicket)
108 }
109 }
110
111 return sc, nil
112}
113
114func makePipelinePlanV200(
115 subtaskMetas []plugin.SubTaskMeta,

Callers 4

TestMakeScopesFunction · 0.70
MakePipelinePlanV200Function · 0.70

Calls 1

GenerateMethod · 0.80

Tested by 3

TestMakeScopesFunction · 0.56