From 57ade2652ad23ccd072e10d97f5a41fa17ada2e5 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Thu, 5 Sep 2019 18:45:39 -0700 Subject: [PATCH] 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 --- pkg/system/path.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/system/path.go b/pkg/system/path.go index a3d957afab..64e892289a 100644 --- a/pkg/system/path.go +++ b/pkg/system/path.go @@ -5,8 +5,6 @@ import ( "path/filepath" "runtime" "strings" - - "github.com/containerd/continuity/pathdriver" ) 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, // is the system drive. // On Linux: this is a no-op. @@ -42,7 +46,7 @@ func DefaultPathEnv(os string) string { // a --> a // /a --> \a // d:\ --> Fail -func CheckSystemDriveAndRemoveDriveLetter(path string, driver pathdriver.PathDriver) (string, error) { +func CheckSystemDriveAndRemoveDriveLetter(path string, driver PathVerifier) (string, error) { if runtime.GOOS != "windows" || LCOWSupported() { return path, nil }