2024-02-05 15:29:45 +00:00
|
|
|
package libraries
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/databricks/databricks-sdk-go/service/compute"
|
|
|
|
)
|
|
|
|
|
|
|
|
// IsWorkspacePath returns true if the specified path indicates that
|
|
|
|
// it should be interpreted as a Databricks Workspace path.
|
|
|
|
//
|
|
|
|
// The following paths are considered workspace paths:
|
|
|
|
//
|
|
|
|
// - /Workspace/Users/jane@doe.com/myfile
|
|
|
|
// - /Users/jane@doe.com/myfile
|
|
|
|
// - /Shared/project/myfile
|
|
|
|
//
|
|
|
|
// The following paths are not considered workspace paths:
|
|
|
|
//
|
|
|
|
// - myfile.txt
|
|
|
|
// - ./myfile.txt
|
|
|
|
// - ../myfile.txt
|
|
|
|
// - /foo/bar/myfile.txt
|
|
|
|
func IsWorkspacePath(path string) bool {
|
|
|
|
return strings.HasPrefix(path, "/Workspace/") ||
|
|
|
|
strings.HasPrefix(path, "/Users/") ||
|
|
|
|
strings.HasPrefix(path, "/Shared/")
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsWorkspaceLibrary returns true if the specified library refers to a workspace path.
|
|
|
|
func IsWorkspaceLibrary(library *compute.Library) bool {
|
2024-08-26 10:03:56 +00:00
|
|
|
path, err := libraryPath(library)
|
|
|
|
if err != nil {
|
2024-02-05 15:29:45 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return IsWorkspacePath(path)
|
|
|
|
}
|
2024-10-24 12:36:17 +00:00
|
|
|
|
|
|
|
// IsVolumesPath returns true if the specified path indicates that
|
2024-10-29 12:06:38 +00:00
|
|
|
// it should be interpreted as a Databricks Volumes path.
|
2024-10-24 12:36:17 +00:00
|
|
|
func IsVolumesPath(path string) bool {
|
|
|
|
return strings.HasPrefix(path, "/Volumes/")
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsWorkspaceSharedPath(path string) bool {
|
|
|
|
return strings.HasPrefix(path, "/Workspace/Shared/")
|
|
|
|
}
|