[ 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
appName := "cmii-uav-platform"
newTag := "5.4.0-25263-0311"
newTag := "5.4.0-031901"
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
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
// pull images
// compress
if sync.ProjectVersion == "" {
if sync.ProjectVersion != "" {
// get version
if sync.DirectHarborHost == "" {
errorPullImageList, errorGzipImageList, allCmiiImageNameList = FetchVersionImages(sync.ProjectVersion, true)
@@ -62,8 +62,9 @@ func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResul
}
}
realCmiiImageList = append(realCmiiImageList, remove(allCmiiImageNameList, errorPullImageList)...)
realCmiiImageList = append(realCmiiImageList, remove(allCmiiImageNameList, errorGzipImageList)...)
// todo function error
realCmiiImageList = remove(allCmiiImageNameList, errorPullImageList)
realCmiiImageList = remove(allCmiiImageNameList, errorGzipImageList)
// direct push if can
if sync.DirectHarborHost != "" {

View File

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