Skip to content

Commit

Permalink
feat: 模板文件支持 Helm 语法模式优化
Browse files Browse the repository at this point in the history
  • Loading branch information
LidolLxf committed Sep 23, 2024
1 parent fce11ff commit a846194
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,16 @@ func (t *TemplateAction) PreviewTemplateFile(ctx context.Context, req *clusterRe
return nil, err
}

// helm 语法模式 模板文件内容进行helm template 渲染
// helm 语法模式 模板文件内容进行helm template 渲染, 简单语法模式自动跳过
content, errRender := renderHelmTemplate(templates, req.GetValues())
if errRender != nil {
return map[string]interface{}{"items": []string{}, "error": errRender.Error()}, nil
}
for k, v := range templates {
helmPath := path.Join(v.TemplateSpace, v.TemplateName)
templates[k].Content = content[helmPath]
if _, ok := content[helmPath]; ok {
templates[k].Content = content[helmPath]
}
}

// render templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ type RenderMode string
const (
// HelmRenderMode helm 语法模式
HelmRenderMode RenderMode = "Helm"
// SimpleRenderMode 单一语法模式,默认
// SimpleRenderMode 简单语法模式,使用字符串替换渲染
SimpleRenderMode RenderMode = "Simple"
)

Expand Down

0 comments on commit a846194

Please sign in to comment.