MCPcopy
hub / github.com/fluid-cloudnative/fluid / ParseBackupRestorePath

Function ParseBackupRestorePath

pkg/utils/databackup.go:70–93  ·  view source on GitHub ↗

ParseBackupRestorePath parse the BackupPath in spec of DataBackup or the RestorePath in spec of Dataset

(backupRestorePath string)

Source from the content-addressed store, hash-verified

68
69// ParseBackupRestorePath parse the BackupPath in spec of DataBackup or the RestorePath in spec of Dataset
70func ParseBackupRestorePath(backupRestorePath string) (pvcName string, path string, err error) {
71 if backupRestorePath == "" {
72 err = errors.New("DataBackupRestorePath is empty, cannot parse")
73 return
74 }
75 if strings.HasPrefix(backupRestorePath, common.VolumeScheme.String()) {
76 path = strings.TrimPrefix(backupRestorePath, common.VolumeScheme.String())
77 split := strings.Split(path, "/")
78 pvcName = split[0]
79 path = strings.TrimPrefix(path, pvcName)
80 } else if strings.HasPrefix(backupRestorePath, common.PathScheme.String()) {
81 path = strings.TrimPrefix(backupRestorePath, common.PathScheme.String())
82 } else {
83 err = errors.New("DataBackupRestorePath is not in supported formats, cannot parse")
84 return
85 }
86 if !strings.HasPrefix(path, "/") {
87 path = "/" + path
88 }
89 if !strings.HasSuffix(path, "/") {
90 path = path + "/"
91 }
92 return
93}
94
95// GetBackupUserDir generate the temp dir of backup user
96func GetBackupUserDir(namespace string, name string) string {

Callers 7

transformMastersMethod · 0.92
transformMastersMethod · 0.92

Calls 1

StringMethod · 0.45

Tested by 1