[Agent] [Executor] 完成PipelineCommand part
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var RemoveForcePrefix = []string{"rm", "-rf"}
|
||||
@@ -81,3 +83,37 @@ func BasicPrettyPrint(resultOk bool, resultLog []string) {
|
||||
fmt.Println(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BasicTransPipelineCommand(pipelineString string) (pipelineCommand [][]string) {
|
||||
|
||||
var pipelineCommandC [][]string
|
||||
split := strings.Split(pipelineString, "|")
|
||||
if len(split) == 0 {
|
||||
log.WarnF("输入的pipelineString有误! %s", pipelineString)
|
||||
return pipelineCommandC
|
||||
}
|
||||
|
||||
for _, s := range split {
|
||||
// 去除掉无效的空行
|
||||
singleCommand := strings.Split(s, " ")
|
||||
var realSingleCommand []string
|
||||
|
||||
for i := range singleCommand {
|
||||
if singleCommand[i] != "" {
|
||||
realSingleCommand = append(realSingleCommand, singleCommand[i])
|
||||
}
|
||||
}
|
||||
pipelineCommandC = append(pipelineCommandC, realSingleCommand)
|
||||
}
|
||||
|
||||
return pipelineCommandC
|
||||
}
|
||||
|
||||
func BasicConvertBufferToSlice(outputBuffer bytes.Buffer) (resultLog []string) {
|
||||
|
||||
s := outputBuffer.String()
|
||||
split := strings.Split(s, "\n")
|
||||
|
||||
return split
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user