mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 04:55:22 +00:00
check for namespaces/ dir before reading it
Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
@@ -210,6 +210,15 @@ func (kr *kubernetesRestorer) restoreFromDir(
|
||||
|
||||
// namespace-scoped
|
||||
namespacesPath := path.Join(dir, api.NamespaceScopedDir)
|
||||
exists, err = kr.fileSystem.DirExists(namespacesPath)
|
||||
if err != nil {
|
||||
addArkError(&errors, err)
|
||||
return warnings, errors
|
||||
}
|
||||
if !exists {
|
||||
return warnings, errors
|
||||
}
|
||||
|
||||
nses, err := kr.fileSystem.ReadDir(namespacesPath)
|
||||
if err != nil {
|
||||
addArkError(&errors, err)
|
||||
|
||||
@@ -91,6 +91,13 @@ func TestRestoreMethod(t *testing.T) {
|
||||
restore: &api.Restore{Spec: api.RestoreSpec{}},
|
||||
expectedReadDirs: []string{"bak/cluster", "bak/namespaces"},
|
||||
},
|
||||
{
|
||||
name: "namespaces dir is not read & does not error if it does not exist",
|
||||
fileSystem: newFakeFileSystem().WithDirectories("bak/cluster"),
|
||||
baseDir: "bak",
|
||||
restore: &api.Restore{Spec: api.RestoreSpec{}},
|
||||
expectedReadDirs: []string{"bak/cluster"},
|
||||
},
|
||||
{
|
||||
name: "namespacesToRestore having * restores all namespaces",
|
||||
fileSystem: newFakeFileSystem().WithDirectories("bak/cluster", "bak/namespaces/a", "bak/namespaces/b", "bak/namespaces/c"),
|
||||
|
||||
Reference in New Issue
Block a user