[Agent][Deploy] - cqejpt

This commit is contained in:
zeaslity
2024-08-27 14:17:39 +08:00
parent ebed0bfc07
commit ae11512f0a
4 changed files with 117 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ var CmiiBackendAppMap = map[string]string{
"cmii-uav-grid-engine": "5.4.0",
"cmii-uav-grid-manage": "5.4.0",
"cmii-uav-sense-adapter": "5.4.0",
"cmii-uav-sync": "5.4.0",
}
var CmiiFrontendAppMap = map[string]string{

View File

@@ -59,12 +59,18 @@ type UploadEntity struct {
ShouldUploadToDemoMinio bool // 上传镜像 DCU中的U
}
type DirectPushResultEntity struct {
ErrorPushedImageList []string
}
type ImageSyncResult struct {
ProcedureSuccessImageList []string // 经过特定步骤之后成功的镜像
DownloadResult *DownloadResultEntity
CompressResult *CompressResultEntity
UploadResult *UploadResultEntity
DirectPushResult *DirectPushResultEntity
}
type DownloadResultEntity struct {
@@ -103,6 +109,9 @@ func (syncCondition *ImageSyncEntity) PullFromEntityAndSyncConditionally() (imag
ErrorUploadImageList: nil,
AllDownloadUrl: nil,
},
DirectPushResult: &DirectPushResultEntity{
ErrorPushedImageList: nil,
},
}
if (syncCondition.DownloadCondition.CmiiNameTagList == nil && syncCondition.DownloadCondition.FullNameImageList == nil) || (len(syncCondition.DownloadCondition.CmiiNameTagList) == 0 && len(syncCondition.DownloadCondition.FullNameImageList) == 0) {
@@ -137,7 +146,7 @@ func (syncCondition *ImageSyncEntity) PullFromEntityAndSyncConditionally() (imag
log.ErrorF("DirectHarborHost is null ! can't push to target harbor !")
}
// push to
//errorPushImageNameList = image.TagFromListAndPushToCHarbor(allCmiiImageNameList, syncCondition.DirectHarborHost)
imageSyncResult.DirectPushResult.ErrorPushedImageList = image.TagFromListAndPushToCHarbor(imageSyncResult.ProcedureSuccessImageList, syncCondition.DirectHarborHost)
}
// build result

View File

@@ -81,6 +81,104 @@ func TestPullFromEntityAndSyncConditionally(t *testing.T) {
// ...其他验证逻辑...
}
func TestPullFromEntityAndSyncConditionally_ChongQingErJiPingTai(t *testing.T) {
// 创建一个模拟的sync对象用于测试函数的行为。这里需要根据你的实际需求来设置mock数据和预期结果。
sync := ImageSyncEntity{
DownloadCondition: &DownloadEntity{
ShouldDownloadImage: true,
ProjectName: "cqejpt",
ProjectVersion: "",
CmiiNameTagList: []string{
//"cmii-uav-mqtthandler:5.4.0-bjdyt-052102",
},
FullNameImageList: []string{
"docker.107421.xyz/rancher/backup-restore-operator:v1.0.3",
"docker.107421.xyz/rancher/calico-cni:v3.17.2",
"docker.107421.xyz/rancher/calico-ctl:v3.17.2",
"docker.107421.xyz/rancher/calico-kube-controllers:v3.17.2",
"docker.107421.xyz/rancher/calico-node:v3.17.2",
"docker.107421.xyz/rancher/calico-pod2daemon-flexvol:v3.17.2",
"docker.107421.xyz/rancher/cis-operator:v1.0.3",
"docker.107421.xyz/rancher/cluster-proportional-autoscaler:1.7.1",
"docker.107421.xyz/rancher/coredns-coredns:1.8.0",
"docker.107421.xyz/rancher/coreos-etcd:v3.4.14-rancher1",
"docker.107421.xyz/rancher/coreos-kube-state-metrics:v1.9.7",
"docker.107421.xyz/rancher/coreos-prometheus-config-reloader:v0.39.0",
"docker.107421.xyz/rancher/coreos-prometheus-operator:v0.39.0",
"docker.107421.xyz/rancher/externalip-webhook:v0.1.6",
"docker.107421.xyz/rancher/flannel-cni:v0.3.0-rancher6",
"docker.107421.xyz/rancher/coreos-flannel:v0.13.0-rancher1",
"docker.107421.xyz/rancher/fleet-agent:v0.3.4",
"docker.107421.xyz/rancher/fleet:v0.3.4",
"docker.107421.xyz/rancher/fluentd:v0.1.24",
"docker.107421.xyz/rancher/grafana-grafana:7.1.5",
"docker.107421.xyz/rancher/hyperkube:v1.20.4-rancher1",
"docker.107421.xyz/rancher/jimmidyson-configmap-reload:v0.3.0",
"docker.107421.xyz/rancher/k8s-dns-dnsmasq-nanny:1.15.2",
"docker.107421.xyz/rancher/k8s-dns-kube-dns:1.15.2",
"docker.107421.xyz/rancher/k8s-dns-node-cache:1.15.13",
"docker.107421.xyz/rancher/k8s-dns-sidecar:1.15.2",
"docker.107421.xyz/rancher/klipper-lb:v0.1.2",
"docker.107421.xyz/rancher/kube-api-auth:v0.1.4",
"docker.107421.xyz/rancher/kubectl:v1.20.4",
"docker.107421.xyz/rancher/kubernetes-external-dns:v0.7.3",
"docker.107421.xyz/rancher/cluster-proportional-autoscaler:1.8.1",
"docker.107421.xyz/rancher/library-busybox:1.31.1",
"docker.107421.xyz/rancher/library-busybox:1.32.1",
"docker.107421.xyz/rancher/library-nginx:1.19.2-alpine",
"docker.107421.xyz/rancher/library-traefik:1.7.19",
"docker.107421.xyz/rancher/local-path-provisioner:v0.0.11",
"docker.107421.xyz/rancher/local-path-provisioner:v0.0.14",
"docker.107421.xyz/rancher/local-path-provisioner:v0.0.19",
"docker.107421.xyz/rancher/log-aggregator:v0.1.7",
"docker.107421.xyz/rancher/istio-kubectl:1.5.10",
"docker.107421.xyz/rancher/metrics-server:v0.4.1",
"docker.107421.xyz/rancher/configmap-reload:v0.3.0-rancher4",
"docker.107421.xyz/rancher/nginx-ingress-controller-defaultbackend:1.5-rancher1",
"docker.107421.xyz/rancher/nginx-ingress-controller:nginx-0.43.0-rancher1",
"docker.107421.xyz/rancher/opa-gatekeeper:v3.1.0-beta.7",
"docker.107421.xyz/rancher/openzipkin-zipkin:2.14.2",
"docker.107421.xyz/rancher/pause:3.2",
"docker.107421.xyz/rancher/plugins-docker:18.09",
"docker.107421.xyz/rancher/prom-alertmanager:v0.21.0",
"docker.107421.xyz/rancher/prom-node-exporter:v1.0.1",
"docker.107421.xyz/rancher/prom-prometheus:v2.18.2",
"docker.107421.xyz/rancher/prometheus-auth:v0.2.1",
"docker.107421.xyz/rancher/rancher-agent:v2.5.7",
"docker.107421.xyz/rancher/rancher-webhook:v0.1.0-beta9",
"docker.107421.xyz/rancher/rancher:v2.5.7",
"docker.107421.xyz/rancher/rke-tools:v0.1.72",
"docker.107421.xyz/rancher/security-scan:v0.1.14",
"docker.107421.xyz/rancher/security-scan:v0.2.2",
"docker.107421.xyz/rancher/shell:v0.1.6",
"docker.107421.xyz/rancher/sonobuoy-sonobuoy:v0.16.3",
"docker.107421.xyz/rancher/system-upgrade-controller:v0.6.2",
},
DownloadAuthUserName: "",
DownloadAuthPassword: "",
},
CompressCondition: &CompressEntity{
ShouldCompressImageToGzip: false,
ShouldGzipSplit: true,
GzipLocalFolder: "",
},
UploadCondition: &UploadEntity{
ShouldUploadToDemoMinio: false,
},
DirectHarborHost: "chongqingshcis-a189ec98.ecis.chongqing-1.cmecloud.cn",
ShouldDirectPushToHarbor: true,
}
// 调用函数并获取结果。这里需要根据你的实际需求来验证返回的结果是否符合预期。
result := sync.PullFromEntityAndSyncConditionally()
utils.BeautifulPrint(result)
// 添加断言以检查函数的输出,例如:
// ...其他验证逻辑...
}
func TestDownloadLoadTagUpload(t *testing.T) {
localGzipFileList := []string{

View File

@@ -192,9 +192,10 @@ func UploadToOctopusKindHarbor(targetImageName string) (pushResult io.ReadCloser
}
pushResult, err := apiClient.ImagePush(context.TODO(), targetImageName, types.ImagePushOptions{
All: false,
RegistryAuth: "eyAidXNlcm5hbWUiOiAiYWRtaW4iLCAicGFzc3dvcmQiOiAiVjJyeVN0ckBuZ1BzcyIsICJlbWFpbCI6ICJpY2VAcXEuY29tIiB9Cg==",
//RegistryAuth: "eyAidXNlcm5hbWUiOiAiZGljdHp4IiwgInBhc3N3b3JkIjogIjlAcDNoekdWU0JscyVIWXUiLCAiZW1haWwiOiAiaWNlQHFxLmNvbSIgfQ==",
All: false,
//RegistryAuth: "eyAidXNlcm5hbWUiOiAiYWRtaW4iLCAicGFzc3dvcmQiOiAiVjJyeVN0ckBuZ1BzcyIsICJlbWFpbCI6ICJpY2VAcXEuY29tIiB9Cg==",
// 重庆移动二级平台
RegistryAuth: "eyAidXNlcm5hbWUiOiAiemd5ZHR4anRjcXl4Z3MxODg4MzI1NzMxMSIsICJwYXNzd29yZCI6ICJEaWN0QDIwMjQiLCAiZW1haWwiOiAiaWNlQHFxLmNvbSIgfQ==",
PrivilegeFunc: nil,
Platform: "amd64",
})
@@ -247,7 +248,10 @@ func TagFromListAndPushToCHarbor(referenceImageList []string, targetHarborHost s
}
scanner := bufio.NewScanner(pushResult)
for scanner.Scan() {
//fmt.Println(scanner.Text())
text := scanner.Text()
if strings.Contains(text, "digest: sha256:") {
fmt.Println(scanner.Text())
}
}
log.InfoF("[ImageTagFromListAndPushToCHarbor] - push of %s success!", targetImageName)
fmt.Println()