[ Agent ] [ Executor ] - 增加Pipeline部分的代码

This commit is contained in:
zeaslity
2023-10-18 09:26:58 +08:00
parent 0e8f633166
commit be01eb28a9
8 changed files with 192 additions and 94 deletions

View File

@@ -1,34 +1,59 @@
package main
import (
"agent-go/g"
"agent-go/executor"
logger2 "agent-go/logger"
"agent-go/register"
"flag"
"fmt"
)
var log = logger2.Log
func main() {
// 解析命令行参数
var version string
var agentServerInfoConf string
flag.StringVar(&version, "version", "", "config file version")
flag.StringVar(&agentServerInfoConf, "agentServerInfoConf", "", "agent server info conf file")
flag.Parse()
// 读取对应版本的配置文件
filename := fmt.Sprintf("octopus-agent-%s.yaml", version)
println("config file name is => " + filename)
println("agent server info file is => " + agentServerInfoConf)
var agentOP = &executor.AgentOsOperator{
InstallCommandPrefix: []string{
"apt-get", "install", "-y",
},
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
CanAccessInternet: true,
IsOsTypeUbuntu: true,
IsAgentInnerWall: false,
AgentArch: "amd64",
AgentOSReleaseCode: "focal",
AgentServerInfo: &register.AgentServerInfo{
ServerName: "",
ServerIPPbV4: "158.247.241.43",
ServerIPInV4: "10.0.4.6",
ServerIPPbV6: "",
ServerIPInV6: "",
Location: "",
Provider: "",
ManagePort: "",
CPUCore: "",
CPUBrand: "",
OSInfo: "",
OSKernelInfo: "",
TCPControl: "",
Virtualization: "",
IoSpeed: "",
MemoryTotal: "",
DiskTotal: "",
DiskUsage: "",
Comment: "",
MachineID: "",
AgentVersion: "",
TopicName: "",
},
OssOfflinePrefix: "https://oss-s1.107421.xyz/",
}
// 初始化Nacos的连接配置
g.G.AgentConfig = register.ParseConfiguration(filename)
//executor.BasicPrettyPrint(agentOP.Exec("shutdownFirewall"))
//executor.BasicPrettyPrint(agentOP.Exec("modifyHostname", "seoul-amd64-01"))
//executor.BasicPrettyPrint(agentOP.Exec("disableSwap"))
executor.BasicPrettyPrint(agentOP.Exec("removeDocker"))
executor.BasicPrettyPrint(agentOP.Exec("installDocker", "20"))
executor.BasicPrettyPrint(agentOP.Exec("removeDockerCompose"))
executor.BasicPrettyPrint(agentOP.Exec("installDockerCompose"))
//executor.BasicPrettyPrint(agentOP.Exec("installZSH"))
// 执行初始化之策工作
businessForeverChan := INIT(agentServerInfoConf)
// 永远等待 runtime的队列消息
<-businessForeverChan
}