[Excution] - base function accomplish - 4
This commit is contained in:
@@ -13,6 +13,7 @@ type ExecutionMessage struct {
|
||||
NeedResultReplay bool `json:"needResultReplay"`
|
||||
DurationTask bool `json:"durationTask,default:false"`
|
||||
Type string `json:"type"`
|
||||
BaseFuncContent []string `json:"baseFuncContent"`
|
||||
SingleLineCommand []string `json:"singleLineCommand"`
|
||||
MultiLineCommand [][]string `json:"multiLineCommand"`
|
||||
PipeLineCommand [][]string `json:"pipeLineCommand"`
|
||||
@@ -21,24 +22,35 @@ type ExecutionMessage struct {
|
||||
|
||||
var log = logger2.Log
|
||||
|
||||
var AgentOsOperatorCache = &AgentOsOperator{}
|
||||
|
||||
func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
|
||||
var resultLog []string
|
||||
var err error
|
||||
var realCommand [][]string
|
||||
|
||||
if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 {
|
||||
// 管道命令
|
||||
resultLog, err = PipeLineCommandExecutor(em.PipeLineCommand)
|
||||
realCommand = em.PipeLineCommand
|
||||
} else if em.MultiLineCommand != nil && len(em.MultiLineCommand) != 0 {
|
||||
// 多行命令
|
||||
resultLog, err = MultiLineCommandExecutor(em.MultiLineCommand)
|
||||
realCommand = em.MultiLineCommand
|
||||
if strings.HasPrefix(em.Type, "BASE") {
|
||||
// base function
|
||||
resultLog = AgentOsOperatorCache.Exec(em.BaseFuncContent[0], em.BaseFuncContent[1:]...)
|
||||
err = nil
|
||||
|
||||
} else {
|
||||
// 单行命令
|
||||
resultLog, err = SingleLineCommandExecutor(em.SingleLineCommand)
|
||||
realCommand = [][]string{em.SingleLineCommand}
|
||||
// shell command
|
||||
|
||||
if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 {
|
||||
// 管道命令
|
||||
resultLog, err = PipeLineCommandExecutor(em.PipeLineCommand)
|
||||
realCommand = em.PipeLineCommand
|
||||
} else if em.MultiLineCommand != nil && len(em.MultiLineCommand) != 0 {
|
||||
// 多行命令
|
||||
resultLog, err = MultiLineCommandExecutor(em.MultiLineCommand)
|
||||
realCommand = em.MultiLineCommand
|
||||
} else {
|
||||
// 单行命令
|
||||
resultLog, err = SingleLineCommandExecutor(em.SingleLineCommand)
|
||||
realCommand = [][]string{em.SingleLineCommand}
|
||||
}
|
||||
}
|
||||
|
||||
// 归一化错误和日志
|
||||
|
||||
Reference in New Issue
Block a user