From 51998ba54743be16f6ea28ab85a1f0718f4e0907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lapeyre?= Date: Tue, 29 Sep 2020 01:12:29 +0200 Subject: [PATCH] Ignore the Nomad token for the diff --- nomad/resource_job_v2.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nomad/resource_job_v2.go b/nomad/resource_job_v2.go index 45661ad7..f8881168 100644 --- a/nomad/resource_job_v2.go +++ b/nomad/resource_job_v2.go @@ -87,9 +87,20 @@ func resourceJobV2Register(register func(job *api.Job) error, d *schema.Resource } func hasChanges(diff *api.JobDiff) bool { - if len(diff.Fields)+len(diff.Objects) > 0 { + // Ignore the Nomad token if it is the only change + if len(diff.Objects) > 0 { return true } + if len(diff.Fields) > 1 { + return true + } + if len(diff.Fields) == 1 { + field := diff.Fields[0] + if field.Name != "NomadTokenID" || field.Type != "Deleted" { + return true + } + } + for _, tg := range diff.TaskGroups { if len(tg.Fields)+len(tg.Objects) > 0 { return true