Skip to content

Commit 431676b

Browse files
daniel-hutaosteinliber
authored andcommitted
fix: change according code review comment and fix the golangci-lint error
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
1 parent 9da6c46 commit 431676b

4 files changed

Lines changed: 17 additions & 49 deletions

File tree

internal/pkg/configmanager/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ type Config struct {
2020
}
2121

2222
func (c *Config) getToolsFromApps() (Tools, error) {
23+
err := c.renderPipelineTemplateMap()
24+
if err != nil {
25+
return nil, err
26+
}
27+
2328
var tools Tools
2429
for _, a := range c.Apps {
2530
appTools, err := c.getToolsWithVarsFromApp(a)
@@ -50,15 +55,10 @@ func (c *Config) getToolsWithVarsFromApp(a app) (Tools, error) {
5055
return nil, fmt.Errorf("app parse yaml failed: %w", err)
5156
}
5257

53-
err = c.renderPipelineTemplateMap()
54-
if err != nil {
55-
return nil, err
56-
}
57-
5858
rawApp.setDefault()
5959
appVars := mapz.Merge(c.Vars, rawApp.Spec)
6060

61-
// 3. generate app repo and tempalte repo from scmInfo
61+
// 3. generate app repo and template repo from scmInfo
6262
repoScaffoldingTool, err := rawApp.getRepoTemplateTool(appVars)
6363
if err != nil {
6464
return nil, fmt.Errorf("app[%s] get repo failed: %w", rawApp.Name, err)

internal/pkg/configmanager/pipelineTemplate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (p *pipelineRaw) getOptions(piplineType string, repo *scm.SCMInfo) RawOptio
8383
func (p *pipelineRaw) newPipelineFromTemplate(templateMap map[string]string, globalVars map[string]any) (*pipelineTemplate, error) {
8484
var t pipelineTemplate
8585
if p.TemplateName == "" {
86-
return nil, fmt.Errorf("%s.templateName is required", p.TemplateName)
86+
return nil, fmt.Errorf("templateName is required")
8787
}
8888
templateStr, ok := templateMap[p.TemplateName]
8989
if !ok {

internal/pkg/configmanager/variables.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import (
66
)
77

88
func renderConfigWithVariables(fileContent string, variables map[string]interface{}) ([]byte, error) {
9-
log.Debugf("renderConfigWithVariables got str: %s", fileContent)
10-
log.Debugf("Vars: ---")
11-
for k, v := range variables {
12-
log.Debugf("%s: %s", k, v)
13-
}
14-
log.Debugf("---")
9+
logFunc(fileContent, variables)
1510

1611
str, err := template.New().
1712
FromContent(fileContent).
@@ -25,3 +20,12 @@ func renderConfigWithVariables(fileContent string, variables map[string]interfac
2520

2621
return []byte(str), nil
2722
}
23+
24+
func logFunc(fileContent string, variables map[string]interface{}) {
25+
log.Debugf("renderConfigWithVariables got str: %s", fileContent)
26+
log.Debugf("Vars: ---")
27+
for k, v := range variables {
28+
log.Debugf("%s: %s", k, v)
29+
}
30+
log.Debugf("---")
31+
}

internal/pkg/show/config/embed_gen.go

Lines changed: 0 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)