mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
fix: Unexpected error during initial resource listing (#2579)
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
6aec54a82f
commit
ecfb0fe2b3
|
|
@ -259,6 +259,14 @@ func (s fileStorage) getRootEntries(key string) ([]os.DirEntry, bool, error) {
|
|||
default:
|
||||
return nil, false, errors.Errorf("key is invalid: %s", key)
|
||||
}
|
||||
if _, err := os.Stat(key); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, allNamespace, errors.Wrapf(err, "failed to stat path %q", key)
|
||||
}
|
||||
if err := os.MkdirAll(key, os.ModePerm); err != nil {
|
||||
return nil, allNamespace, errors.Wrapf(err, "failed to create dir %q", key)
|
||||
}
|
||||
}
|
||||
rootEntries, err := os.ReadDir(key)
|
||||
|
||||
return rootEntries, allNamespace, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue