mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Narrow dependencies of pkg/system
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>
This commit is contained in:
parent
3b23f90339
commit
57ade2652a
1 changed files with 7 additions and 3 deletions
|
@ -5,8 +5,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containerd/continuity/pathdriver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
@ -27,6 +25,12 @@ func DefaultPathEnv(os string) string {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PathVerifier defines the subset of a PathDriver that CheckSystemDriveAndRemoveDriveLetter
|
||||||
|
// actually uses in order to avoid system depending on containerd/continuity.
|
||||||
|
type PathVerifier interface {
|
||||||
|
IsAbs(string) bool
|
||||||
|
}
|
||||||
|
|
||||||
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
|
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
|
||||||
// is the system drive.
|
// is the system drive.
|
||||||
// On Linux: this is a no-op.
|
// On Linux: this is a no-op.
|
||||||
|
@ -42,7 +46,7 @@ func DefaultPathEnv(os string) string {
|
||||||
// a --> a
|
// a --> a
|
||||||
// /a --> \a
|
// /a --> \a
|
||||||
// d:\ --> Fail
|
// d:\ --> Fail
|
||||||
func CheckSystemDriveAndRemoveDriveLetter(path string, driver pathdriver.PathDriver) (string, error) {
|
func CheckSystemDriveAndRemoveDriveLetter(path string, driver PathVerifier) (string, error) {
|
||||||
if runtime.GOOS != "windows" || LCOWSupported() {
|
if runtime.GOOS != "windows" || LCOWSupported() {
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue