Skip to content

Commit

Permalink
Update internal/services/appservice/helpers/linux_web_app_schema.go
Browse files Browse the repository at this point in the history
Hi @katbyte, I'm not sure that I got your point, since line 977 `len(autoHeal.Triggers) == 0`, line 979 `autoHeal.Triggers[0]` would trigger an index out of range panic right? Do you mean `if len(autoHeal.Triggers) == 1 {` for line 977?

I personal prefer return early style to reduce nested blocks' depth and avoid [arrow code](https://blog.codinghorror.com/flattening-arrow-code/), but this is HashiCorp's project so I would be happy to follow your guidance.

Co-authored-by: kt <[email protected]>
  • Loading branch information
lonegunmanb and katbyte authored Apr 17, 2023
1 parent ef69562 commit 2b3cccb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/services/appservice/helpers/linux_web_app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,9 @@ func expandAutoHealSettingsLinux(autoHealSettings []AutoHealSettingLinux) *web.A
}

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

triggers := autoHeal.Triggers[0]
if len(triggers.Requests) == 1 {
triggers := autoHeal.Triggers[0]
if len(triggers.Requests) == 1 {
result.Triggers.Requests = &web.RequestsBasedTrigger{
Count: pointer.To(int32(triggers.Requests[0].Count)),
TimeInterval: pointer.To(triggers.Requests[0].Interval),
Expand Down

0 comments on commit 2b3cccb

Please sign in to comment.