mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
fix bug on checking hostpath type file
This commit is contained in:
parent
3f5e09b6e2
commit
084fe6de93
@ -370,7 +370,11 @@ func (ftc *fileTypeChecker) IsFile() bool {
|
|||||||
if !ftc.Exists() {
|
if !ftc.Exists() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !ftc.IsDir()
|
pathType, err := ftc.hu.GetFileType(ftc.path)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return string(pathType) == string(v1.HostPathFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ftc *fileTypeChecker) MakeFile() error {
|
func (ftc *fileTypeChecker) MakeFile() error {
|
||||||
|
@ -447,7 +447,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
|||||||
if oftc.IsDir() {
|
if oftc.IsDir() {
|
||||||
t.Errorf("[%d: %q] expected socket file, got unexpected folder: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected socket file, got unexpected folder: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if !oftc.IsFile() {
|
if oftc.IsFile() {
|
||||||
t.Errorf("[%d: %q] expected socket file, got unexpected file: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected socket file, got unexpected file: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if oftc.IsBlock() {
|
if oftc.IsBlock() {
|
||||||
@ -465,7 +465,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
|||||||
if oftc.IsDir() {
|
if oftc.IsDir() {
|
||||||
t.Errorf("[%d: %q] expected character device, got unexpected folder: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected character device, got unexpected folder: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if !oftc.IsFile() {
|
if oftc.IsFile() {
|
||||||
t.Errorf("[%d: %q] expected character device, got unexpected file: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected character device, got unexpected file: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if oftc.IsSocket() {
|
if oftc.IsSocket() {
|
||||||
@ -483,7 +483,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
|||||||
if oftc.IsDir() {
|
if oftc.IsDir() {
|
||||||
t.Errorf("[%d: %q] expected block device, got unexpected folder: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected block device, got unexpected folder: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if !oftc.IsFile() {
|
if oftc.IsFile() {
|
||||||
t.Errorf("[%d: %q] expected block device, got unexpected file: %s", i, tc.name, path)
|
t.Errorf("[%d: %q] expected block device, got unexpected file: %s", i, tc.name, path)
|
||||||
}
|
}
|
||||||
if oftc.IsSocket() {
|
if oftc.IsSocket() {
|
||||||
|
Loading…
Reference in New Issue
Block a user