[Agent][Deploy] - cqsh

This commit is contained in:
zeaslity
2024-07-04 10:58:01 +08:00
parent 4e7422c32b
commit 1fd1cc8b29
32 changed files with 23808 additions and 58 deletions

View File

@@ -105,27 +105,48 @@ func ImageFullNameToGzipFileName(imageFullName string) (gzipFileName string) {
}
// ImageNameToTargetImageFullName 将ImageName转换为目标TargetHosts的全名称ImageName的格式为 短名称或者长名称 均可
func ImageNameToTargetImageFullName(imageFullName, targetHostFullName string) string {
func ImageNameToTargetImageFullName(imageName, targetHarborHost string) string {
if strings.HasPrefix(imageFullName, CmiiHarborPrefix) {
imageFullName = strings.TrimPrefix(imageFullName, CmiiHarborPrefix)
} else if strings.HasPrefix(imageFullName, "docker.io") {
imageFullName = strings.TrimPrefix(imageFullName, "docker.io")
}
// rancher/123:v123
if strings.HasPrefix(imageFullName, "rancher") {
return targetHostFullName + "/" + imageFullName
}
// ossr/srs:v4.0.5
if strings.Contains(imageFullName, "/") {
imageFullName = strings.Split(imageFullName, "/")[1]
targetProject := "cmii"
if strings.HasPrefix(imageName, "rancher") {
// rancher/rancher:v2.5.7 rancher名称的形式
targetProject = "rancher"
}
// srs:v4.0.5
// cmii-uav-platform:5.4.0
s := targetHostFullName + "/cmii/" + imageFullName
log.InfoF("ImageFullName: [%s] to TargetImageFullName: [%s]", imageFullName, s)
return s
countOfSplit := strings.Count(imageName, "/")
split := strings.Split(imageName, "/")
targetImageName := imageName
switch countOfSplit {
case 0:
// nginx:latest
targetImageName = targetHarborHost + "/" + targetProject + "/" + imageName
break
default:
// 10.250.0.10:8033/cmii/cmii-uav-gateway:v1.0.0
targetImageName = targetHarborHost + "/" + targetProject + "/" + split[countOfSplit]
break
}
//if strings.HasPrefix(imageFullName, CmiiHarborPrefix) {
// imageFullName = strings.TrimPrefix(imageFullName, CmiiHarborPrefix)
//} else if strings.HasPrefix(imageFullName, "docker.io") {
// imageFullName = strings.TrimPrefix(imageFullName, "docker.io")
//}
//// rancher/123:v123
//if strings.HasPrefix(imageFullName, "rancher") {
// return targetHostFullName + "/" + imageFullName
//}
//// ossr/srs:v4.0.5
//if strings.Contains(imageFullName, "/") {
// imageFullName = strings.Split(imageFullName, "/")[1]
//}
//
//// srs:v4.0.5
//// cmii-uav-platform:5.4.0
//s := targetHostFullName + "/cmii/" + imageFullName
log.InfoF("ImageFullName: [%s] to TargetImageFullName: [%s]", imageName, targetImageName)
return targetImageName
}
func GzipFileNameToImageFullName(gzipFileName string) (imageFullName string) {