[CMII] [Operator] accomplish - 1
This commit is contained in:
57
cmii_operator/CmiiOperator.go
Normal file
57
cmii_operator/CmiiOperator.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package cmii_operator
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
"wdd.io/agent-go/executor"
|
||||
"wdd.io/agent-go/utils"
|
||||
)
|
||||
|
||||
func FetchDemoImages(projectName, projectFolderPath string) bool {
|
||||
if !strings.HasSuffix(projectFolderPath, "/") {
|
||||
projectFolderPath += "/"
|
||||
}
|
||||
|
||||
// generate a project folder
|
||||
err := os.Mkdir(projectFolderPath, os.ModeDir)
|
||||
if err != nil {
|
||||
if !errors.Is(err, os.ErrExist) {
|
||||
log.ErrorF("[FetchDemoImages] - create folder of %s error %s", projectFolderPath, err.Error())
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// get demo image version map
|
||||
backendMap, frontendMap := BackupAllCmiiDeploymentToMap(demo)
|
||||
|
||||
utils.BeautifulPrint(backendMap)
|
||||
utils.BeautifulPrint(frontendMap)
|
||||
|
||||
// save map to file
|
||||
backendMapFile := projectFolderPath + projectName + "-backend-app.json"
|
||||
frontendMapFile := projectFolderPath + projectName + "-frontend-app.json"
|
||||
_ = os.Remove(backendMapFile)
|
||||
_ = os.Remove(frontendMapFile)
|
||||
|
||||
executor.BasicAppendContentToFile(
|
||||
utils.BeautifulPrintToString(backendMap),
|
||||
backendMapFile,
|
||||
)
|
||||
executor.BasicAppendContentToFile(
|
||||
utils.BeautifulPrintToString(frontendMap),
|
||||
frontendMapFile,
|
||||
)
|
||||
|
||||
// download image
|
||||
ImagePullFromCmiiHarborByMap(backendMap, true)
|
||||
ImagePullFromCmiiHarborByMap(frontendMap, true)
|
||||
|
||||
// compress image
|
||||
|
||||
// upload to harbor
|
||||
|
||||
// clean up images
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user