[ Service ] [ Executor ] 初步重构Executor部分的代码

This commit is contained in:
zeaslity
2023-08-10 17:09:51 +08:00
parent e5af31bb38
commit fbd8348e15
43 changed files with 1020 additions and 1650 deletions

View File

@@ -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指令执行错误 => "}

View File

@@ -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