Prevent nil panic on exec restore hooks (#5675)

* Prevent nil panic on exec restore hooks

Signed-off-by: Dylan Murray <dymurray@redhat.com>
This commit is contained in:
Dylan Murray
2022-12-13 00:45:52 -05:00
committed by GitHub
parent ffc9845fb9
commit 55873c1c37
2 changed files with 7 additions and 4 deletions

View File

@@ -0,0 +1 @@
Prevent nil panic on exec restore hooks

View File

@@ -342,10 +342,12 @@ func (c *restoreController) validateAndComplete(restore *api.Restore, pluginMana
}
for _, resource := range restoreHooks {
for _, h := range resource.RestoreHooks {
for _, container := range h.Init.InitContainers {
err = hook.ValidateContainer(container.Raw)
if err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, err.Error())
if h.Init != nil {
for _, container := range h.Init.InitContainers {
err = hook.ValidateContainer(container.Raw)
if err != nil {
restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, err.Error())
}
}
}
}