MCPcopy Index your code
hub / github.com/apache/devlake / PrepareTaskData

Method PrepareTaskData

backend/plugins/bitbucket/impl/impl.go:141–182  ·  view source on GitHub ↗
(taskCtx plugin.TaskContext, options map[string]interface{})

Source from the content-addressed store, hash-verified

139}
140
141func (p Bitbucket) PrepareTaskData(taskCtx plugin.TaskContext, options map[string]interface{}) (interface{}, errors.Error) {
142 logger := taskCtx.GetLogger()
143 logger.Debug("%v", options)
144 op, err := tasks.DecodeAndValidateTaskOptions(options)
145 if err != nil {
146 return nil, err
147 }
148 connectionHelper := helper.NewConnectionHelper(
149 taskCtx,
150 nil,
151 p.Name(),
152 )
153 connection := &models.BitbucketConnection{}
154 err = connectionHelper.FirstById(connection, op.ConnectionId)
155 if err != nil {
156 return nil, errors.Default.Wrap(err, "unable to get bitbucket connection by the given connection ID")
157 }
158
159 apiClient, err := tasks.CreateApiClient(taskCtx, connection)
160 if err != nil {
161 return nil, errors.Default.Wrap(err, "unable to get bitbucket API client instance")
162 }
163 err = EnrichOptions(taskCtx, op, apiClient.ApiClient)
164 if err != nil {
165 return nil, err
166 }
167
168 regexEnricher := helper.NewRegexEnricher()
169 if err := regexEnricher.TryAdd(devops.DEPLOYMENT, op.DeploymentPattern); err != nil {
170 return nil, errors.BadInput.Wrap(err, "invalid value for `deploymentPattern`")
171 }
172 if err := regexEnricher.TryAdd(devops.PRODUCTION, op.ProductionPattern); err != nil {
173 return nil, errors.BadInput.Wrap(err, "invalid value for `productionPattern`")
174 }
175 taskData := &tasks.BitbucketTaskData{
176 Options: op,
177 ApiClient: apiClient,
178 RegexEnricher: regexEnricher,
179 }
180
181 return taskData, nil
182}
183
184func (p Bitbucket) RootPkgPath() string {
185 return "github.com/apache/incubator-devlake/plugins/bitbucket/" // the "/" fixes an issue where records from "bitbucket_server" are counted as "bitbucket" records and vice versa

Callers

nothing calls this directly

Calls 7

NameMethod · 0.95
TryAddMethod · 0.95
FirstByIdMethod · 0.80
WrapMethod · 0.80
EnrichOptionsFunction · 0.70
GetLoggerMethod · 0.65
DebugMethod · 0.65

Tested by

no test coverage detected