重构架构

This commit is contained in:
2026-02-20 18:44:43 +08:00
parent aba7b68439
commit cc71248ef4
52 changed files with 1404 additions and 2360 deletions

38
pkg/templating/types.go Normal file
View File

@@ -0,0 +1,38 @@
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"`
}