[ Cmii ] [ Octopus ] - 优化项目结构
This commit is contained in:
43
agent-common/message_pusher/push_template.go
Normal file
43
agent-common/message_pusher/push_template.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package message_pusher
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const cmiiDeployTemplate = `
|
||||
{{if .DeployStatus}}
|
||||
部署状态: 成功😍
|
||||
{{- else }}
|
||||
部署状态: 失败👿👿👿
|
||||
{{- end}}
|
||||
命名空间: {{.Namespace}}
|
||||
应用名称: {{.AppName}}
|
||||
副本数量: {{.Replicas}}
|
||||
目标版本: {{.ToTag}}
|
||||
`
|
||||
|
||||
type DeployPush struct {
|
||||
Namespace string
|
||||
AppName string
|
||||
Replicas string
|
||||
DeployStatus bool
|
||||
ToTag string
|
||||
}
|
||||
|
||||
func (d DeployPush) ParseCmiiDeployTemplate() bytes.Buffer {
|
||||
// 解析模板
|
||||
tmpl, err := template.New("cmiiDeployTemplate").Parse(cmiiDeployTemplate)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 应用数据并打印结果
|
||||
var result bytes.Buffer
|
||||
err = tmpl.Execute(&result, d)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user