重构架构
This commit is contained in:
38
pkg/templating/types.go
Normal file
38
pkg/templating/types.go
Normal 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"`
|
||||
}
|
||||
Reference in New Issue
Block a user