Skip to content

Commit

Permalink
Prevent nil panic on exec restore hooks (vmware-tanzu#5675)
Browse files Browse the repository at this point in the history
* Prevent nil panic on exec restore hooks

Signed-off-by: Dylan Murray <dymurray@redhat.com>
  • Loading branch information
dymurray committed Dec 13, 2022
1 parent ffc9845 commit 55873c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5675-dymurray
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent nil panic on exec restore hooks
10 changes: 6 additions & 4 deletions pkg/controller/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
}
Expand Down

0 comments on commit 55873c1

Please sign in to comment.