Skip to content

增强模板渲染能力支持类似helm的 include 渲染提前解析的定义模板 #3030

@mumuhhh

Description

@mumuhhh

Your current KubeKey version

4.0.3

Describe this feature

利用预定义模板 减少模板声明

Describe the solution you'd like

例如在模板文件 platform.tpl 中定义

{{- define "images.platform.list" }}
{{- $platform := list }}
{{- range . }}
  {{- $platform = append $platform (printf "linux/%s" .) }}
{{- end }}
{{- $platform | toJson }}
{{- end -}}

之后在其他变量或模板中复用

{{- include "images.platform.list" .download.arch -}}

由于模板解析非线程安全所以应当在project加载之初提前解析加载模板定义
变量解析时 Clone() project持有的模板 再解析渲染变量或者模板文件
@redscholar

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions