[agent-go] [Bastion] - install docker; docker-compose; install harbor

This commit is contained in:
zeaslity
2024-04-18 09:46:26 +08:00
parent dacdb6588e
commit abe83b68e9
10 changed files with 554 additions and 99 deletions

View File

@@ -32,8 +32,9 @@ var AllFunctionCache = &bastion_init.Trie{}
const (
InstallDocker = "docker"
InstallDockerCompose = "dockercompose"
InstallHarbor = "harbor"
InstallMinio = "minio"
InstallRabbitmq = "rabbitmq"
RemoveDocker = "removedocker"
Exit = "exit"
Help = "help"
)
@@ -102,15 +103,20 @@ func BastionModeInit() {
text = strings.TrimSpace(text)
inputCommand := uniformInputCommand(text)
fmt.Println("inputCommand: ", inputCommand)
fmt.Println()
// execute the function
switch inputCommand {
case InstallDocker:
agentOperator.InstallDockerBastion()
beautifulPrintExeResult(agentOperator.InstallDockerBastion())
case InstallDockerCompose:
agentOperator.InstallDockerComposeBastion()
case InstallMinio:
agentOperator.InstallMinioBastion()
case InstallHarbor:
a_executor.InstallHarborBastion()
case RemoveDocker:
beautifulPrintExeResult(agentOperator.RemoveDockerBastion())
case Exit:
os.Exit(0)
case Help:
@@ -122,6 +128,19 @@ func BastionModeInit() {
}
func beautifulPrintExeResult(resultOk bool, result []string) {
fmt.Println()
if resultOk {
fmt.Println("execute SUCCESS")
} else {
fmt.Println("execute FAIL")
}
for _, s := range result {
fmt.Println(s)
}
fmt.Println()
}
func buildBastionModeFunction() {
// build the tree search node
log.Info("build the tree search node")
@@ -130,7 +149,8 @@ func buildBastionModeFunction() {
tcc.Insert(InstallDocker)
tcc.Insert(InstallDockerCompose)
tcc.Insert(InstallMinio)
tcc.Insert(InstallRabbitmq)
tcc.Insert(InstallHarbor)
tcc.Insert(RemoveDocker)
tcc.Insert(Help)
tcc.Insert(Exit)