Files
sunhpc-go/pkg/templating/types.go
2026-02-20 18:44:43 +08:00

39 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package templating
// Template 是 YAML 模板的顶层结构
type Template struct {
Description string `yaml:"description,omitempty"`
Copyright string `yaml:"copyright,omitempty"`
Stages map[string][]Step `yaml:"stages"`
}
// Step 表示一个操作步骤
type Step struct {
Type string `yaml:"type"` // "file" 或 "script"
Path string `yaml:"path,omitempty"` // 文件路径(仅 type=file
Content string `yaml:"content"` // 多行内容
Condition string `yaml:"condition,omitempty"` // 条件表达式Go template
}
// Context 是渲染模板时的上下文数据
type Context struct {
Node NodeInfo `json:"node"`
Cluster ClusterInfo `json:"cluster"`
}
// NodeInfo 节点信息
type NodeInfo struct {
Hostname string `json:"hostname"`
OldHostname string `json:"old_hostname,omitempty"`
Domain string `json:"domain"`
IP string `json:"ip"`
}
// ClusterInfo 集群信息
type ClusterInfo struct {
Name string `json:"name"`
Domain string `json:"domain"`
AdminEmail string `json:"admin_email"`
TimeZone string `json:"time_zone"`
}