[ Service ] [ Executor ] 初步重构Executor部分的代码
This commit is contained in:
@@ -5,8 +5,14 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type OctopusFunc interface {
|
||||
Exec(baseFuncName string, funcArgs ...string) []string
|
||||
|
||||
Deploy(appFuncName string, funcArgs ...string) (bool, []string)
|
||||
}
|
||||
|
||||
type AppFunc interface {
|
||||
Deploy(appFuncName string, funcArgs ...string) []string
|
||||
Deploy(appFuncName string, funcArgs ...string) (bool, []string)
|
||||
}
|
||||
|
||||
var AppExecuteErrorLogPrefix = []string{"App指令执行错误! => "}
|
||||
|
||||
@@ -13,7 +13,7 @@ type ExecutionMessage struct {
|
||||
NeedResultReplay bool `json:"needResultReplay"`
|
||||
DurationTask bool `json:"durationTask,default:false"`
|
||||
Type string `json:"type"`
|
||||
BaseFuncContent []string `json:"baseFuncContent"`
|
||||
FuncContent []string `json:"funcContent"`
|
||||
SingleLineCommand []string `json:"singleLineCommand"`
|
||||
MultiLineCommand [][]string `json:"multiLineCommand"`
|
||||
PipeLineCommand [][]string `json:"pipeLineCommand"`
|
||||
@@ -32,9 +32,18 @@ func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
|
||||
if strings.HasPrefix(em.Type, "BASE") {
|
||||
// base function
|
||||
resultLog = AgentOsOperatorCache.Exec(em.BaseFuncContent[0], em.BaseFuncContent[1:]...)
|
||||
resultLog = AgentOsOperatorCache.Exec(em.FuncContent[0], em.FuncContent[1:]...)
|
||||
err = nil
|
||||
|
||||
} else if strings.HasPrefix(em.Type, "APP") {
|
||||
// app function
|
||||
ok, resultLog := AgentOsOperatorCache.Deploy(em.FuncContent[0], em.FuncContent[1:]...)
|
||||
if ok {
|
||||
return resultLog, nil
|
||||
} else {
|
||||
return resultLog, nil
|
||||
}
|
||||
|
||||
} else {
|
||||
// shell command
|
||||
|
||||
|
||||
Reference in New Issue
Block a user