[Cmii][ImageSync] -Image Function accomplish -1
This commit is contained in:
@@ -51,6 +51,12 @@ func (op *AgentOsOperator) downloadDockerImage(funcArgs []string) (bool, []strin
|
||||
}
|
||||
imageFullName := funcArgs[0]
|
||||
log.InfoF("[downloadDockerImage]- start to pull docker image %s", imageFullName)
|
||||
|
||||
// login
|
||||
if strings.HasPrefix(imageFullName, image.CmiiHarborPrefix) {
|
||||
HardCodeCommandExecutor("docker login -u rad02_drone -p Drone@1234 harbor.cdcyy.com.cn")
|
||||
}
|
||||
|
||||
if !PureResultSingleExecute([]string{
|
||||
"docker",
|
||||
"pull",
|
||||
@@ -61,7 +67,7 @@ func (op *AgentOsOperator) downloadDockerImage(funcArgs []string) (bool, []strin
|
||||
}
|
||||
}
|
||||
|
||||
if !JudgeDockerImageExists(funcArgs[0]) {
|
||||
if !BasicDockerImageExistByFullName(funcArgs[0]) {
|
||||
return false, []string{
|
||||
"image not exits ! unknown error happened!",
|
||||
}
|
||||
@@ -89,7 +95,7 @@ func (op *AgentOsOperator) compressImageToGzip(funcArgs []string) (bool, []strin
|
||||
}
|
||||
|
||||
imageFullName := funcArgs[0]
|
||||
if JudgeDockerImageExists(imageFullName) {
|
||||
if !BasicDockerImageExistByFullName(imageFullName) {
|
||||
return false, []string{
|
||||
"image not exits !",
|
||||
}
|
||||
@@ -129,18 +135,35 @@ func (op *AgentOsOperator) uploadGzipFileToOss(funcArgs []string) (bool, []strin
|
||||
gzipFolderPrefix := funcArgs[1]
|
||||
gzipImageFromFullName := funcArgs[2]
|
||||
|
||||
ok, resultLog := AllCommandExecutor([]string{
|
||||
ok, resultLog := HardCodeCommandExecutor("mc --insecure alias set demo https://oss.ig-demo.uavcmlc.com cmii B#923fC7mk")
|
||||
//ok, resultLog = HardCodeCommandExecutor("mc alias list")
|
||||
|
||||
PureResultSingleExecute([]string{
|
||||
"mc",
|
||||
"rm",
|
||||
"demo/cmlc-installation/tmp/" + gzipImageFromFullName,
|
||||
})
|
||||
|
||||
ok, resultLog = AllCommandExecutor([]string{
|
||||
"mc",
|
||||
"cp",
|
||||
gzipFolderPrefix + gzipImageFromFullName,
|
||||
"demo/cmlc-installation/tmp/",
|
||||
"demo/cmlc-installation/tmp/" + gzipImageFromFullName,
|
||||
})
|
||||
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
|
||||
return true, nil
|
||||
find, _ := BasicFindContentInCommandOutput("mc ls demo/cmlc-installation/tmp/", gzipImageFromFullName)
|
||||
if !find {
|
||||
return false, []string{
|
||||
"demo oss can't find gzip file !",
|
||||
}
|
||||
}
|
||||
|
||||
return true, []string{
|
||||
gzipImageFromFullName,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,13 +173,33 @@ func (op *AgentOsOperator) downloadGzipImageFile(funcArgs []string) (bool, []str
|
||||
gzipImageFromFullName := funcArgs[2]
|
||||
proxyUrl := funcArgs[4]
|
||||
|
||||
if proxyUrl == "" {
|
||||
BasicDownloadFile(ossUrlPrefix+gzipImageFromFullName, LocalGzipImageFolderPrefix+gzipImageFromFullName)
|
||||
} else {
|
||||
BasicDownloadFileWithProxy(ossUrlPrefix+gzipImageFromFullName, proxyUrl, LocalGzipImageFolderPrefix+gzipImageFromFullName)
|
||||
// create folder
|
||||
BasicCreateFolder(LocalGzipImageFolderPrefix)
|
||||
|
||||
// remove file
|
||||
desFile := LocalGzipImageFolderPrefix + gzipImageFromFullName
|
||||
|
||||
if !BasicRemoveFileOrFolder(desFile) {
|
||||
return false, []string{
|
||||
"file already exits ! can't remove it!",
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
var download bool
|
||||
var downloadLog []string
|
||||
if proxyUrl == "" {
|
||||
download, downloadLog = BasicDownloadFile(ossUrlPrefix+gzipImageFromFullName, desFile)
|
||||
} else {
|
||||
download, downloadLog = BasicDownloadFileWithProxy(ossUrlPrefix+gzipImageFromFullName, proxyUrl, desFile)
|
||||
}
|
||||
|
||||
if !download {
|
||||
return false, downloadLog
|
||||
}
|
||||
|
||||
return true, []string{
|
||||
desFile,
|
||||
}
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) loadDockerImageFromGzip(funcArgs []string) (bool, []string) {
|
||||
@@ -175,6 +218,13 @@ func (op *AgentOsOperator) loadDockerImageFromGzip(funcArgs []string) (bool, []s
|
||||
return false, i
|
||||
}
|
||||
|
||||
if !BasicDockerImageExistByFullName(funcArgs[0]) {
|
||||
return false, []string{
|
||||
"docker load from gzip file error ! image not exits!",
|
||||
funcArgs[0],
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
func (op *AgentOsOperator) pushImageToTargetHarbor(funcArgs []string) (bool, []string) {
|
||||
@@ -198,8 +248,11 @@ func (op *AgentOsOperator) pushImageToTargetHarbor(funcArgs []string) (bool, []s
|
||||
"docker tag error!",
|
||||
}
|
||||
}
|
||||
|
||||
HardCodeCommandExecutor("docker login -u admin -p V2ryStr@ngPss " + targetHarborHost)
|
||||
if strings.HasPrefix(targetImageFullName, image.CmiiHarborPrefix) {
|
||||
HardCodeCommandExecutor("docker login -u rad02_drone -p Drone@1234 harbor.cdcyy.com.cn")
|
||||
} else {
|
||||
HardCodeCommandExecutor("docker login -u admin -p V2ryStr@ngPss " + targetHarborHost)
|
||||
}
|
||||
|
||||
ok, resultLog := AllCommandExecutor([]string{
|
||||
"docker",
|
||||
@@ -240,10 +293,6 @@ func (op *AgentOsOperator) updateImageTag(funcArgs []string) (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func JudgeDockerImageExists(imageFullName string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//func BuildGzipImageFromFullName(imageFullName string) string {
|
||||
//
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user