[Agent][Deploy] - 修改ImageSync模块 大量修改
This commit is contained in:
@@ -100,8 +100,11 @@ func ImageFullNameToGzipFileName(imageFullName string) (gzipFileName string) {
|
||||
if len(first) == 3 {
|
||||
// harbor.cdcyy.cn/cmii/cmii-uav-platform:5.4.0
|
||||
// docker.io/ossr/srs:v5.0.1
|
||||
// docker.107421.xyz/rancher/calico-cni:v3.17.2
|
||||
if strings.HasPrefix(split[0], CmiiHarborPrefix) {
|
||||
gzipFileName += "cmlc=cmii="
|
||||
} else if strings.Contains(split[0], "rancher") {
|
||||
gzipFileName += "docker=rancher="
|
||||
} else {
|
||||
gzipFileName += "docker=cmii="
|
||||
}
|
||||
@@ -111,6 +114,7 @@ func ImageFullNameToGzipFileName(imageFullName string) (gzipFileName string) {
|
||||
} else if len(first) == 4 {
|
||||
// harbor.cdcyy.cn/cmii/ossr/srs:v5.0.1
|
||||
// harbor.cdcyy.com.cn/cmii/cmlc-ai/cmlc-ai-operator:v5.2.0-t4-no-dino
|
||||
|
||||
if !strings.HasPrefix(split[0], CmiiHarborPrefix) {
|
||||
return imageFullName
|
||||
}
|
||||
|
||||
@@ -12,17 +12,18 @@ import (
|
||||
)
|
||||
|
||||
var imageFullNameList = []string{
|
||||
"bitnami/redis:6.2.6-debian-10-r0",
|
||||
"simonrupf/chronyd:0.4.3",
|
||||
"harbor.cdcyy.com.cn/cmii/cmii-rtsp-operator:v4.1.0",
|
||||
"harbor.cdcyy.com.cn/cmii/ossrs/srs:v4.0.136",
|
||||
"ossrs/srs:v4.0.136",
|
||||
"mongo:5.0",
|
||||
"bitnami/minio:2023.5.4",
|
||||
"busybox:latest",
|
||||
"busybox",
|
||||
"rancher/rancher:v2.7.0",
|
||||
"10.1.1.1:8033/cmii/ok:1.2",
|
||||
//"bitnami/redis:6.2.6-debian-10-r0",
|
||||
//"simonrupf/chronyd:0.4.3",
|
||||
//"harbor.cdcyy.com.cn/cmii/cmii-rtsp-operator:v4.1.0",
|
||||
//"harbor.cdcyy.com.cn/cmii/ossrs/srs:v4.0.136",
|
||||
//"ossrs/srs:v4.0.136",
|
||||
//"mongo:5.0",
|
||||
//"bitnami/minio:2023.5.4",
|
||||
//"busybox:latest",
|
||||
//"busybox",
|
||||
//"rancher/rancher:v2.7.0",
|
||||
//"10.1.1.1:8033/cmii/ok:1.2",
|
||||
"docker.107421.xyz/rancher/shell:v0.1.6",
|
||||
}
|
||||
|
||||
func TestImageFullNameToGzipFileName(t *testing.T) {
|
||||
|
||||
@@ -68,6 +68,33 @@ func AppendContentToFile(content string, targetFile string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func AppendOverwriteListContentToFile(contentList []string, targetFile string) bool {
|
||||
|
||||
err := os.Remove(targetFile)
|
||||
if err != nil {
|
||||
log.WarnF("[AppendOverwriteListContentToFile] - Error removing file: %s , error is %s", targetFile, err.Error())
|
||||
}
|
||||
|
||||
// 打开文件用于追加。如果文件不存在,将会创建一个新文件。
|
||||
file, err := os.OpenFile(targetFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.ErrorF("[AppendOverwriteListContentToFile] - Error opening file: %s , error is %s", targetFile, err.Error())
|
||||
return false
|
||||
}
|
||||
defer file.Close() // 确保文件最终被关闭
|
||||
|
||||
// 写入内容到文件
|
||||
for _, contentLine := range contentList {
|
||||
//bytes, _ := json.Marshal(contentLine)
|
||||
if _, err := file.WriteString(contentLine + "\n"); err != nil {
|
||||
log.ErrorF("[AppendOverwriteListContentToFile] - Error writing to file: %s , error is %s", targetFile, err.Error())
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// AppendContentWithSplitLineToFile 专门为k8s的yaml文件设计的,在每次写入内容之前,先写入一行分隔符
|
||||
func AppendContentWithSplitLineToFile(content string, targetFile string) bool {
|
||||
|
||||
@@ -174,6 +201,10 @@ func ListAllFileInFolder(folderName string) ([]string, error) {
|
||||
return listAllFileInFolderWithFullPath(folderName, false)
|
||||
}
|
||||
|
||||
func ListAllFileInFolderWithFullPath(folderName string) ([]string, error) {
|
||||
return listAllFileInFolderWithFullPath(folderName, true)
|
||||
}
|
||||
|
||||
func listAllFileInFolderWithFullPath(folderName string, fullPath bool) ([]string, error) {
|
||||
files := make([]string, 0)
|
||||
err := filepath.Walk(folderName, func(path string, info os.FileInfo, err error) error {
|
||||
|
||||
Reference in New Issue
Block a user