check for namespaces/ dir before reading it
Signed-off-by: Steve Kriss <steve@heptio.com>pull/38/head
parent
35b865dfcf
commit
49809b0a59
|
@ -210,6 +210,15 @@ func (kr *kubernetesRestorer) restoreFromDir(
|
||||||
|
|
||||||
// namespace-scoped
|
// namespace-scoped
|
||||||
namespacesPath := path.Join(dir, api.NamespaceScopedDir)
|
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)
|
nses, err := kr.fileSystem.ReadDir(namespacesPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
addArkError(&errors, err)
|
addArkError(&errors, err)
|
||||||
|
|
|
@ -91,6 +91,13 @@ func TestRestoreMethod(t *testing.T) {
|
||||||
restore: &api.Restore{Spec: api.RestoreSpec{}},
|
restore: &api.Restore{Spec: api.RestoreSpec{}},
|
||||||
expectedReadDirs: []string{"bak/cluster", "bak/namespaces"},
|
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",
|
name: "namespacesToRestore having * restores all namespaces",
|
||||||
fileSystem: newFakeFileSystem().WithDirectories("bak/cluster", "bak/namespaces/a", "bak/namespaces/b", "bak/namespaces/c"),
|
fileSystem: newFakeFileSystem().WithDirectories("bak/cluster", "bak/namespaces/a", "bak/namespaces/b", "bak/namespaces/c"),
|
||||||
|
|
Loading…
Reference in New Issue