新增xa空能院项目,新增大量的更新内容
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"wdd.io/agent-common/utils"
|
||||
)
|
||||
|
||||
@@ -49,7 +50,7 @@ func TestHarborOperator_BuildOperator(t *testing.T) {
|
||||
|
||||
func TestHarborOperator_RepoListAll(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
TestHarborOperator_BuildOperator_CMII(t)
|
||||
|
||||
//repoListAll := DefaultHarborOperator.RepoListAll("ran")
|
||||
repoListAll := DefaultHarborOperator.RepoListAll("cmii")
|
||||
@@ -69,20 +70,31 @@ func TestHarborOperator_RepoAllCmiiImage(t *testing.T) {
|
||||
|
||||
func TestHarborOperator_ArtifactListAll(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
TestHarborOperator_BuildOperator_CMII(t)
|
||||
|
||||
artifactListAll := DefaultHarborOperator.ArtifactListAll("cmii", "cmii-uav-user")
|
||||
|
||||
var tagNameList []string
|
||||
|
||||
for _, artifact := range artifactListAll {
|
||||
//if len(artifact.Tags) == 0 {
|
||||
// fmt.Println(artifact.Digest)
|
||||
//}
|
||||
for _, tag := range artifact.Tags {
|
||||
fmt.Println(tag.Name)
|
||||
tagNameList = append(tagNameList, tag.Name)
|
||||
}
|
||||
}
|
||||
//utils.BeautifulPrint(artifactListAll)
|
||||
|
||||
toDelete, keep := FindTagsToDelete(tagNameList)
|
||||
|
||||
fmt.Printf("总共有 %d 个标签, 其中 %d 个可以被删除, 需要保留 %d 个。\n\n", len(tagNameList), len(toDelete), len(keep))
|
||||
fmt.Println("建议删除的标签列表:")
|
||||
for _, tag := range toDelete {
|
||||
fmt.Println(tag)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestHarborOperator_CmiiHarborCleanUp(t *testing.T) {
|
||||
@@ -93,21 +105,43 @@ func TestHarborOperator_CmiiHarborCleanUp(t *testing.T) {
|
||||
|
||||
for _, repo := range repoListAll {
|
||||
repoName := strings.TrimPrefix(repo.Name, "cmii/")
|
||||
|
||||
// 获取所有的
|
||||
artifactListAll := DefaultHarborOperator.ArtifactListAll("cmii", repoName)
|
||||
|
||||
for _, artifact := range artifactListAll {
|
||||
//if len(artifact.Tags) == 0 {
|
||||
// fmt.Println(artifact.Digest)
|
||||
//}
|
||||
var tagNameList []string
|
||||
|
||||
for _, tag := range artifact.Tags {
|
||||
|
||||
// 添加到Tag列表中
|
||||
tagNameList = append(tagNameList, tag.Name)
|
||||
|
||||
if strings.Contains(tag.Name, "snapshot") || strings.Contains(tag.Name, "validation") || strings.Contains(tag.Name, "beta") || strings.Contains(tag.Name, "staging") || strings.Contains(tag.Name, "test") {
|
||||
fmt.Println(tag.Name)
|
||||
fmt.Println(artifact.Digest)
|
||||
|
||||
fmt.Println(fmt.Sprintf("prepare delete image is %s:%s", repoName, tag.Name))
|
||||
|
||||
//DefaultHarborOperator.ArtifactDeleteOne("cmii", repoName, artifact.Digest)
|
||||
|
||||
fmt.Println()
|
||||
DefaultHarborOperator.ArtifactDeleteOne("cmii", repoName, artifact.Digest)
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤所有可以删除的Tag
|
||||
//deletableTags := FilterTags(tagNameList)
|
||||
//
|
||||
//fmt.Printf("总共有 %d 个标签, 其中 %d 个可以被删除。\n\n", len(tagNameList), len(deletableTags))
|
||||
//fmt.Println("建议删除的标签列表:")
|
||||
//for _, tag := range deletableTags {
|
||||
// fmt.Println(fmt.Sprintf("开始删除镜像 => %s:%s", repoName, tag))
|
||||
// DefaultHarborOperator.ArtifactDeleteOne("cmii", repoName, tag)
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//utils.BeautifulPrint(artifactListAll)
|
||||
|
||||
Reference in New Issue
Block a user