[agent-operator] - add tag from gzip folder
This commit is contained in:
@@ -148,3 +148,27 @@ func GzipFileNameToImageFullName(gzipFileName string) (imageFullName string) {
|
||||
|
||||
return gzipFileName
|
||||
}
|
||||
|
||||
func GzipFileNameToImageNameAndTag(gzipFileName string) (imageName, imageTag string) {
|
||||
if !strings.HasSuffix(gzipFileName, ".tar.gz") {
|
||||
log.ErrorF(" %s is not end with .tar.gz", gzipFileName)
|
||||
return "", ""
|
||||
}
|
||||
gzipFileName = strings.TrimSuffix(gzipFileName, ".tar.gz")
|
||||
|
||||
if strings.HasPrefix(gzipFileName, "docker=library") {
|
||||
// docker=library=busybox=latest.tar.gz
|
||||
return strings.Split(gzipFileName, "=")[2], strings.Split(gzipFileName, "=")[3]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(gzipFileName, "docker") {
|
||||
// docker=kubernetes=kubernetes-dashboard=v2.4.0.tar.gz
|
||||
return strings.Split(gzipFileName, "=")[1] + "/" + strings.Split(gzipFileName, "=")[2], strings.Split(gzipFileName, "=")[3]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(gzipFileName, "cmlc=cmii=") {
|
||||
return strings.Split(gzipFileName, "=")[2], strings.Split(gzipFileName, "=")[3]
|
||||
}
|
||||
|
||||
return "", ""
|
||||
}
|
||||
|
||||
@@ -150,11 +150,20 @@ func FileExistAndNotNull(filename string) bool {
|
||||
return size > 0
|
||||
}
|
||||
|
||||
// ListAllFileInFolder 列出一个目录中的所有文件,返回文件名,忽略folder,不带全路径
|
||||
func ListAllFileInFolder(folderName string) ([]string, error) {
|
||||
return listAllFileInFolderWithFullPath(folderName, false)
|
||||
}
|
||||
|
||||
func listAllFileInFolderWithFullPath(folderName string, fullPath bool) ([]string, error) {
|
||||
files := make([]string, 0)
|
||||
err := filepath.Walk(folderName, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() {
|
||||
files = append(files, info.Name())
|
||||
if fullPath {
|
||||
files = append(files, path)
|
||||
} else {
|
||||
files = append(files, info.Name())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user