Commit 44f01404 authored by andyzhangx's avatar andyzhangx

fix comments

parent eb7c36ee
...@@ -754,7 +754,7 @@ func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) { ...@@ -754,7 +754,7 @@ func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) {
// MakeAbsolutePath convert path to absolute path according to GOOS // MakeAbsolutePath convert path to absolute path according to GOOS
func MakeAbsolutePath(goos, path string) string { func MakeAbsolutePath(goos, path string) string {
if goos != "windows" { if goos != "windows" {
return "/" + filepath.Clean(path) return filepath.Clean("/" + path)
} }
// These are all for windows // These are all for windows
// If there is a colon, give up. // If there is a colon, give up.
......
...@@ -19,6 +19,7 @@ package util ...@@ -19,6 +19,7 @@ package util
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"runtime"
"testing" "testing"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
...@@ -1101,7 +1102,13 @@ func TestMakeAbsolutePath(t *testing.T) { ...@@ -1101,7 +1102,13 @@ func TestMakeAbsolutePath(t *testing.T) {
goos: "linux", goos: "linux",
path: "non-absolute/path", path: "non-absolute/path",
expectedPath: "/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", goos: "windows",
...@@ -1129,9 +1136,11 @@ func TestMakeAbsolutePath(t *testing.T) { ...@@ -1129,9 +1136,11 @@ func TestMakeAbsolutePath(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
if runtime.GOOS == test.goos {
path := MakeAbsolutePath(test.goos, test.path) path := MakeAbsolutePath(test.goos, test.path)
if path != test.expectedPath { if path != test.expectedPath {
t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path) t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path)
} }
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment