Skip to content

Commit

Permalink
guard against nil maps
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Apr 6, 2020
1 parent a142302 commit da93e23
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions nomad/structs/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ func (tg *TaskGroup) Diff(other *TaskGroup, contextual bool) (*TaskGroupDiff, er
}

// ShutdownDelay diff
if tg.ShutdownDelay == nil {
oldPrimitiveFlat["ShutdownDelay"] = ""
} else {
oldPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *tg.ShutdownDelay)
}
if other.ShutdownDelay == nil {
newPrimitiveFlat["ShutdownDelay"] = ""
} else {
newPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *other.ShutdownDelay)
if oldPrimitiveFlat != nil && newPrimitiveFlat != nil {
if tg.ShutdownDelay == nil {
oldPrimitiveFlat["ShutdownDelay"] = ""
} else {
oldPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *tg.ShutdownDelay)
}
if other.ShutdownDelay == nil {
newPrimitiveFlat["ShutdownDelay"] = ""
} else {
newPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *other.ShutdownDelay)
}
}

// Diff the primitive fields.
Expand Down

0 comments on commit da93e23

Please sign in to comment.