Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
caioq committed Nov 5, 2024
1 parent ba47179 commit a244a43
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
4 changes: 1 addition & 3 deletions backend/plugins/gitextractor/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,16 @@ func (p GitExtractor) PrepareTaskData(taskCtx plugin.TaskContext, options map[st
return nil, err
}


if op.PluginName != "" {
pluginInstance, err := plugin.GetPlugin(op.PluginName)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("failed to get plugin instance for plugin: %s", op.PluginName))

}

if pluginGit, ok := pluginInstance.(DynamicGitUrl); ok {
gitUrl, err := pluginGit.GetDynamicGitUrl(taskCtx, op.ConnectionId, op.Url)
if err != nil {
return nil, errors.Default.Wrap(err, "failed to get Git URL")
return nil, errors.Default.Wrap(err, "failed to get Git URL")
}

op.Url = gitUrl
Expand Down
4 changes: 2 additions & 2 deletions backend/plugins/gitextractor/parser/taskdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ type GitExtractorOptions struct {
SkipCommitStat *bool `json:"skipCommitStat" mapstructure:"skipCommitStat" comment:"skip all commit stat including added/deleted lines and commit files as well"`
SkipCommitFiles *bool `json:"skipCommitFiles" mapstructure:"skipCommitFiles"`
NoShallowClone bool `json:"noShallowClone" mapstructure:"noShallowClone"`
ConnectionId uint64 `json:"connectionId" mapstructure:"connectionId,omitempty"`
PluginName string `json:"pluginName" mapstructure:"pluginName,omitempty"`
ConnectionId uint64 `json:"connectionId" mapstructure:"connectionId,omitempty"`
PluginName string `json:"pluginName" mapstructure:"pluginName,omitempty"`
}
12 changes: 6 additions & 6 deletions backend/plugins/github/api/blueprint_v200.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ func makeDataSourcePipelinePlanV200(
stage = append(stage, &coreModels.PipelineTask{
Plugin: "gitextractor",
Options: map[string]interface{}{
"url": cloneUrl.String(),
"name": githubRepo.FullName,
"fullName": githubRepo.FullName,
"repoId": didgen.NewDomainIdGenerator(&models.GithubRepo{}).Generate(connection.ID, githubRepo.GithubId),
"proxy": connection.Proxy,
"url": cloneUrl.String(),
"name": githubRepo.FullName,
"fullName": githubRepo.FullName,
"repoId": didgen.NewDomainIdGenerator(&models.GithubRepo{}).Generate(connection.ID, githubRepo.GithubId),
"proxy": connection.Proxy,
"connectionId": githubRepo.ConnectionId,
"pluginName": "github",
"pluginName": "github",
},
})

Expand Down
8 changes: 6 additions & 2 deletions backend/plugins/github/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ func (p Github) GetDynamicGitUrl(taskCtx plugin.TaskContext, connectionId uint64
return "", err
}

connection.PrepareApiClient(apiClient)
err = connection.PrepareApiClient(apiClient)
if err != nil {
return "", err
}

newUrl, err := replaceAcessTokenInUrl(repoUrl, connection.Token)
if err != nil {
Expand All @@ -274,7 +277,8 @@ func (p Github) GetDynamicGitUrl(taskCtx plugin.TaskContext, connectionId uint64

func EnrichOptions(taskCtx plugin.TaskContext,
op *tasks.GithubOptions,
apiClient *helper.ApiClient) errors.Error {
apiClient *helper.ApiClient,
) errors.Error {
var githubRepo models.GithubRepo
// validate the op and set name=owner/repo if this is from advanced mode or bpV100
err := tasks.ValidateTaskOptions(op)
Expand Down
12 changes: 6 additions & 6 deletions backend/plugins/gitlab/api/blueprint_v200.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ func makePipelinePlanV200(
stage = append(stage, &coreModels.PipelineTask{
Plugin: "gitextractor",
Options: map[string]interface{}{
"url": cloneUrl.String(),
"name": gitlabProject.Name,
"fullName": gitlabProject.PathWithNamespace,
"repoId": didgen.NewDomainIdGenerator(&models.GitlabProject{}).Generate(connection.ID, gitlabProject.GitlabId),
"proxy": connection.Proxy,
"url": cloneUrl.String(),
"name": gitlabProject.Name,
"fullName": gitlabProject.PathWithNamespace,
"repoId": didgen.NewDomainIdGenerator(&models.GitlabProject{}).Generate(connection.ID, gitlabProject.GitlabId),
"proxy": connection.Proxy,
"connectionId": gitlabProject.ConnectionId,
"pluginName": "gitlab",
"pluginName": "gitlab",
},
})
}
Expand Down

0 comments on commit a244a43

Please sign in to comment.