[ Cmii ] [ Octopus ] - image sync refresh

This commit is contained in:
zeaslity
2024-03-19 10:11:00 +08:00
parent df44d6eef9
commit 798aea36fc
3 changed files with 13 additions and 8 deletions

View File

@@ -237,7 +237,7 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
cmiiEnv := demo cmiiEnv := demo
appName := "cmii-uav-platform" appName := "cmii-uav-platform"
newTag := "5.4.0-25263-0311" newTag := "5.4.0-031901"
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag) tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
assert.Equal(t, tag, true, "update image tag failed !") assert.Equal(t, tag, true, "update image tag failed !")

View File

@@ -44,7 +44,7 @@ func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResul
// get all image name by Name or Version // get all image name by Name or Version
// pull images // pull images
// compress // compress
if sync.ProjectVersion == "" { if sync.ProjectVersion != "" {
// get version // get version
if sync.DirectHarborHost == "" { if sync.DirectHarborHost == "" {
errorPullImageList, errorGzipImageList, allCmiiImageNameList = FetchVersionImages(sync.ProjectVersion, true) errorPullImageList, errorGzipImageList, allCmiiImageNameList = FetchVersionImages(sync.ProjectVersion, true)
@@ -62,8 +62,9 @@ func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResul
} }
} }
realCmiiImageList = append(realCmiiImageList, remove(allCmiiImageNameList, errorPullImageList)...) // todo function error
realCmiiImageList = append(realCmiiImageList, remove(allCmiiImageNameList, errorGzipImageList)...) realCmiiImageList = remove(allCmiiImageNameList, errorPullImageList)
realCmiiImageList = remove(allCmiiImageNameList, errorGzipImageList)
// direct push if can // direct push if can
if sync.DirectHarborHost != "" { if sync.DirectHarborHost != "" {

View File

@@ -196,11 +196,14 @@ func TagFromListAndPushToCHarbor(referenceImageList []string, targetHarborHost s
targetProject = "rancher" targetProject = "rancher"
} }
if strings.Contains(imageName, "/") { if strings.HasPrefix(imageName, CmiiHarborPrefix) {
// //
imageName = strings.Split(imageName, "/")[1] imageName = strings.TrimPrefix(imageName, CmiiHarborPrefix)
} else { } else {
// todo
if strings.Contains(imageName, "/") {
imageName = strings.Split(imageName, "/")[1]
}
} }
targetImageName := targetHarborHost + ":8033/" + targetProject + "/" + imageName targetImageName := targetHarborHost + ":8033/" + targetProject + "/" + imageName
@@ -209,7 +212,8 @@ func TagFromListAndPushToCHarbor(referenceImageList []string, targetHarborHost s
pushResult := PushToOctopusKindHarbor(targetImageName) pushResult := PushToOctopusKindHarbor(targetImageName)
if pushResult == nil { if pushResult == nil {
errorPushImageNameList = append(errorPushImageNameList, cmiiImageFullName) errorPushImageNameList = append(errorPushImageNameList, cmiiImageFullName)
continue log.InfoF("[ImageTagFromListAndPushToCHarbor] - push of %s error error !", targetImageName)
break
} }
scanner := bufio.NewScanner(pushResult) scanner := bufio.NewScanner(pushResult)
for scanner.Scan() { for scanner.Scan() {