From da93e236a93f5a6d9365986175acfc6d04823785 Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Mon, 6 Apr 2020 12:25:50 -0400 Subject: [PATCH] guard against nil maps --- nomad/structs/diff.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/nomad/structs/diff.go b/nomad/structs/diff.go index 812a28e17ad..34533c0584c 100644 --- a/nomad/structs/diff.go +++ b/nomad/structs/diff.go @@ -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.