CheckSystemDriveAndRemoveDriveLetter depends on pathdriver.PathDriver
unnecessarily. This depends on the minimal interface that it actually
needs, to avoid callers from unnecessarily bringing in a
containerd/continuity dependency.
Signed-off-by: Jon Johnson <jonjohnson@google.com>
| ... | ... |
@@ -5,8 +5,6 @@ import ( |
| 5 | 5 |
"path/filepath" |
| 6 | 6 |
"runtime" |
| 7 | 7 |
"strings" |
| 8 |
- |
|
| 9 |
- "github.com/containerd/continuity/pathdriver" |
|
| 10 | 8 |
) |
| 11 | 9 |
|
| 12 | 10 |
const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| ... | ... |
@@ -27,6 +25,12 @@ func DefaultPathEnv(os string) string {
|
| 27 | 27 |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
+// PathVerifier defines the subset of a PathDriver that CheckSystemDriveAndRemoveDriveLetter |
|
| 31 |
+// actually uses in order to avoid system depending on containerd/continuity. |
|
| 32 |
+type PathVerifier interface {
|
|
| 33 |
+ IsAbs(string) bool |
|
| 34 |
+} |
|
| 35 |
+ |
|
| 30 | 36 |
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, |
| 31 | 37 |
// is the system drive. |
| 32 | 38 |
// On Linux: this is a no-op. |
| ... | ... |
@@ -42,7 +46,7 @@ func DefaultPathEnv(os string) string {
|
| 42 | 42 |
// a --> a |
| 43 | 43 |
// /a --> \a |
| 44 | 44 |
// d:\ --> Fail |
| 45 |
-func CheckSystemDriveAndRemoveDriveLetter(path string, driver pathdriver.PathDriver) (string, error) {
|
|
| 45 |
+func CheckSystemDriveAndRemoveDriveLetter(path string, driver PathVerifier) (string, error) {
|
|
| 46 | 46 |
if runtime.GOOS != "windows" || LCOWSupported() {
|
| 47 | 47 |
return path, nil |
| 48 | 48 |
} |