mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +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() {
|
||||
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 {
|
||||
|
@ -447,7 +447,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
||||
if oftc.IsDir() {
|
||||
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)
|
||||
}
|
||||
if oftc.IsBlock() {
|
||||
@ -465,7 +465,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
||||
if oftc.IsDir() {
|
||||
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)
|
||||
}
|
||||
if oftc.IsSocket() {
|
||||
@ -483,7 +483,7 @@ func TestOSFileTypeChecker(t *testing.T) {
|
||||
if oftc.IsDir() {
|
||||
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)
|
||||
}
|
||||
if oftc.IsSocket() {
|
||||
|
Loading…
Reference in New Issue
Block a user