Skip to content

Commit

Permalink
add length check to avoid panic
Browse files Browse the repository at this point in the history
add length check to match linux_web_app to avoid potential panic in windows_web_app

linux change done in hashicorp#21328
  • Loading branch information
calebak404 authored Oct 31, 2023
1 parent 9f832ba commit bcde86d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/services/appservice/helpers/auto_heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,17 @@ func expandAutoHealSettingsWindows(autoHealSettings []AutoHealSettingWindows) *w
}

autoHeal := autoHealSettings[0]

if len(autoHeal.actions) > 0 {
action := autoHeal.Actions[0]
result.Actions.ActionType = web.AutoHealActionType(action.ActionType)
result.Actions.MinProcessExecutionTime = pointer.To(action.MinimumProcessTime)
}

if len(autoHeal.Triggers) == 0 {
return result
}

triggers := autoHeal.Triggers[0]
if len(triggers.Requests) == 1 {
result.Triggers.Requests = &web.RequestsBasedTrigger{
Expand Down Expand Up @@ -462,10 +472,7 @@ func expandAutoHealSettingsWindows(autoHealSettings []AutoHealSettingWindows) *w
result.Triggers.StatusCodes = &statusCodeTriggers
result.Triggers.StatusCodesRange = &statusCodeRangeTriggers
}

action := autoHeal.Actions[0]
result.Actions.ActionType = web.AutoHealActionType(action.ActionType)
result.Actions.MinProcessExecutionTime = pointer.To(action.MinimumProcessTime)

if len(action.CustomAction) != 0 {
customAction := action.CustomAction[0]
result.Actions.CustomAction = &web.AutoHealCustomAction{
Expand Down

0 comments on commit bcde86d

Please sign in to comment.