Skip to content

Commit 6a29606

Browse files
authored
Merge pull request #1270 from merico-dev/fix-pipeline-default-option-error
fix: reposcaffolding source repo auth error
2 parents c4a8d2a + 0dcb062 commit 6a29606

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

internal/pkg/configmanager/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ func (a *app) getRepoTemplateTool() (*Tool, error) {
7777
return nil, fmt.Errorf("configmanager[app] parse repo failed: %w", err)
7878
}
7979
if a.RepoTemplate != nil {
80+
// templateRepo doesn't need auth info
8081
templateRepo, err := a.RepoTemplate.BuildRepoInfo()
82+
templateRepo.NeedAuth = false
8183
if err != nil {
8284
return nil, fmt.Errorf("configmanager[app] parse repoTemplate failed: %w", err)
8385
}

internal/pkg/configmanager/configmanager_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ var _ = Describe("LoadConfig", func() {
202202
"sourceRepo": RawOptions{
203203
"repoType": "github",
204204
"url": "github.com/devstream-io/dtm-scaffolding-golang",
205-
"needAuth": true,
206205
"org": "devstream-io",
207206
"repo": "dtm-scaffolding-golang",
208207
"branch": "main",

internal/pkg/configmanager/pipelinetemplate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,27 @@ func (p *pipelineRaw) newPipelineFromTemplate(templateMap map[string]string, glo
6969
if err := mergo.Merge(&t.Options, p.Options, mergo.WithOverride); err != nil {
7070
return nil, fmt.Errorf("%s merge template options faield: %+v", p.TemplateName, err)
7171
}
72-
// set default options
73-
if t.Options == nil {
74-
t.Options = RawOptions{}
75-
}
7672
return &t, nil
7773
}
7874

7975
func (t *pipelineTemplate) generatePipelineTool(app *app) (*Tool, error) {
8076
const configLocationKey = "configLocation"
81-
// 1. get configurator by template type
77+
// 1.set default options
78+
if t.Options == nil {
79+
t.Options = RawOptions{}
80+
}
81+
// 2. get configurator by template type
8282
pipelineConfigurator, exist := optionConfiguratorMap[t.Type]
8383
if !exist {
8484
return nil, fmt.Errorf("pipeline type [%s] not supported for now", t.Type)
8585
}
86-
// 2. set default configLocation
86+
// 3. set default configLocation
8787
if _, configLocationExist := t.Options[configLocationKey]; !configLocationExist {
8888
if pipelineConfigurator.hasDefaultConfig() {
8989
t.Options[configLocationKey] = pipelineConfigurator.defaultConfigLocation
9090
}
9191
}
92-
// 3. generate tool options
92+
// 4. generate tool options
9393
pipelineFinalOptions := pipelineConfigurator.optionGeneratorFunc(t.Options, app)
9494
return newTool(t.Type, app.Name, pipelineFinalOptions), nil
9595
}

0 commit comments

Comments
 (0)