mirror of https://github.com/k3s-io/k3s
fix comments
parent
520b8d49fc
commit
f06c01fc83
|
@ -726,7 +726,7 @@ func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) {
|
|||
// MakeAbsolutePath convert path to absolute path according to GOOS
|
||||
func MakeAbsolutePath(goos, path string) string {
|
||||
if goos != "windows" {
|
||||
return "/" + filepath.Clean(path)
|
||||
return filepath.Clean("/" + path)
|
||||
}
|
||||
// These are all for windows
|
||||
// If there is a colon, give up.
|
||||
|
|
|
@ -19,6 +19,7 @@ package util
|
|||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
|
@ -988,7 +989,13 @@ func TestMakeAbsolutePath(t *testing.T) {
|
|||
goos: "linux",
|
||||
path: "non-absolute/path",
|
||||
expectedPath: "/non-absolute/path",
|
||||
name: "basic linux",
|
||||
name: "linux non-absolute path",
|
||||
},
|
||||
{
|
||||
goos: "linux",
|
||||
path: "/absolute/path",
|
||||
expectedPath: "/absolute/path",
|
||||
name: "linux absolute path",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
|
@ -1016,9 +1023,11 @@ func TestMakeAbsolutePath(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
path := MakeAbsolutePath(test.goos, test.path)
|
||||
if path != test.expectedPath {
|
||||
t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path)
|
||||
if runtime.GOOS == test.goos {
|
||||
path := MakeAbsolutePath(test.goos, test.path)
|
||||
if path != test.expectedPath {
|
||||
t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue