Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
caioq committed Oct 22, 2024
1 parent 66891a8 commit 58de05e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 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 @@ -131,13 +131,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
9 changes: 6 additions & 3 deletions backend/plugins/github/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func (p Github) PrepareTaskData(taskCtx plugin.TaskContext, options map[string]i
if err = regexEnricher.TryAdd(devops.ENV_NAME_PATTERN, op.ScopeConfig.EnvNamePattern); err != nil {
return nil, errors.BadInput.Wrap(err, "invalid value for `envNamePattern`")
}

}
taskData.RegexEnricher = regexEnricher

Expand Down Expand Up @@ -292,7 +291,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 @@ -304,7 +306,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 @@ -136,13 +136,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 58de05e

Please sign in to comment.