[Agent][Deploy] - sz ga
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"wdd.io/agent-common/utils"
|
||||
)
|
||||
|
||||
@@ -15,6 +12,8 @@ var LocalKubeConfigFile = "/root/.kube/config"
|
||||
// C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64" -output "build/agent-operator_{{.OS}}_{{.Arch}}"
|
||||
// C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64 linux/arm64" -output "build/agent-operator_{{.OS}}_{{.Arch}}"
|
||||
|
||||
//
|
||||
|
||||
func BuildDefaultK8sOperator() {
|
||||
|
||||
// build from local LocalKubeConfigFile
|
||||
@@ -86,75 +85,84 @@ func main() {
|
||||
// C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64" -output "build/operator_{{.OS}}_{{.Arch}}"
|
||||
|
||||
//RealProjectRunner()
|
||||
|
||||
// 解析命令行参数
|
||||
var mode string
|
||||
flag.StringVar(&mode, "mode", "mode", "agent run mode")
|
||||
flag.Parse()
|
||||
|
||||
if mode == "image" {
|
||||
BuildDefaultK8sOperator()
|
||||
|
||||
BuildDefaultK8sOperator()
|
||||
// 堡垒机模式 的 镜像美容
|
||||
// 初始化堡垒机模式
|
||||
for {
|
||||
BackupAllDeploymentFromEnv(mode)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
fmt.Printf(DLTUHelp)
|
||||
fmt.Print("enter ==> ")
|
||||
|
||||
text, _ := reader.ReadString('\n')
|
||||
split := strings.Split(text, " ")
|
||||
var result []string
|
||||
for _, s := range split {
|
||||
text = strings.TrimSpace(s)
|
||||
if text == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, text)
|
||||
}
|
||||
|
||||
if len(result) != 6 {
|
||||
fmt.Println("input error!")
|
||||
fmt.Printf(DLTUHelp)
|
||||
return
|
||||
}
|
||||
|
||||
ossUrlPrefix := result[1]
|
||||
ossFileName := result[2]
|
||||
localGzipFolderOrGzipFile := result[3]
|
||||
harborHostFullName := result[4]
|
||||
namespace := result[5]
|
||||
|
||||
fmt.Println("ossUrlPrefix: ", ossUrlPrefix)
|
||||
fmt.Println("ossFileName: ", ossFileName)
|
||||
fmt.Println("localGzipFolderOrGzipFile: ", localGzipFolderOrGzipFile)
|
||||
fmt.Println("harborHostFullName: ", harborHostFullName)
|
||||
fmt.Println("namespace: ", namespace)
|
||||
fmt.Println()
|
||||
|
||||
downloadFromOss := true
|
||||
if ossFileName == "0" {
|
||||
downloadFromOss = false
|
||||
}
|
||||
|
||||
// DLTU
|
||||
targetImageFullNameList := DownloadLoadTagUpload(downloadFromOss, ossUrlPrefix, ossFileName, localGzipFolderOrGzipFile, harborHostFullName)
|
||||
|
||||
// 是否需要更新
|
||||
if namespace != "" {
|
||||
for _, targetImageFullName := range targetImageFullNameList {
|
||||
if !DefaultCmiiOperator.DeploymentUpdateTagByImageFullName(namespace, targetImageFullName) {
|
||||
fmt.Printf("[Update] update [%s] [%s] failed", namespace, targetImageFullName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
}
|
||||
// 解析命令行参数
|
||||
//var mode string
|
||||
//flag.StringVar(&mode, "mode", "mode", "agent run mode")
|
||||
//flag.Parse()
|
||||
//
|
||||
//if mode == "image" {
|
||||
//
|
||||
// BuildDefaultK8sOperator()
|
||||
// // 堡垒机模式 的 镜像美容
|
||||
// // 初始化堡垒机模式
|
||||
// for {
|
||||
//
|
||||
// reader := bufio.NewReader(os.Stdin)
|
||||
// for {
|
||||
// fmt.Printf(DLTUHelp)
|
||||
// fmt.Print("enter ==> ")
|
||||
//
|
||||
// text, _ := reader.ReadString('\n')
|
||||
// split := strings.Split(text, " ")
|
||||
// var result []string
|
||||
// for _, s := range split {
|
||||
// text = strings.TrimSpace(s)
|
||||
// if text == "" {
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// result = append(result, text)
|
||||
// }
|
||||
//
|
||||
// if len(result) != 6 {
|
||||
// fmt.Println("input error!")
|
||||
// fmt.Printf(DLTUHelp)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// ossUrlPrefix := result[1]
|
||||
// ossFileName := result[2]
|
||||
// localGzipFolderOrGzipFile := result[3]
|
||||
// harborHostFullName := result[4]
|
||||
// namespace := result[5]
|
||||
//
|
||||
// fmt.Println("ossUrlPrefix: ", ossUrlPrefix)
|
||||
// fmt.Println("ossFileName: ", ossFileName)
|
||||
// fmt.Println("localGzipFolderOrGzipFile: ", localGzipFolderOrGzipFile)
|
||||
// fmt.Println("harborHostFullName: ", harborHostFullName)
|
||||
// fmt.Println("namespace: ", namespace)
|
||||
// fmt.Println()
|
||||
//
|
||||
// downloadFromOss := true
|
||||
// if ossFileName == "0" {
|
||||
// downloadFromOss = false
|
||||
// }
|
||||
//
|
||||
// // DLTU
|
||||
// targetImageFullNameList := DownloadLoadTagUpload(downloadFromOss, ossUrlPrefix, ossFileName, localGzipFolderOrGzipFile, harborHostFullName)
|
||||
//
|
||||
// // 是否需要更新
|
||||
// if namespace != "" {
|
||||
// for _, targetImageFullName := range targetImageFullNameList {
|
||||
// if !DefaultCmiiOperator.DeploymentUpdateTagByImageFullName(namespace, targetImageFullName) {
|
||||
// fmt.Printf("[Update] update [%s] [%s] failed", namespace, targetImageFullName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fmt.Println()
|
||||
// }
|
||||
// }
|
||||
//} else if mode == "operator" {
|
||||
//
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user