From ef9f250b00a8a8070d6c64b593f6bb2eba4d6902 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 20 Apr 2023 09:11:57 -0700 Subject: [PATCH] cli: fix panic on job plan when -diff=false PR #14492 introduced a new check to return 0 when the `nomad job plan` command returns a diff of type `None`. But the `-diff` CLI flag was also being used to control whether the plan request should return the diff of not instead of just controlling if the diff was printed. This means that when `-diff=false` is set the response does not include any diff information, and so the new check panics. This commit fixes the problem by always requesting a diff and using the `-diff` only for controlling output, as it's currently documented. --- command/job_plan.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/command/job_plan.go b/command/job_plan.go index d3d45fbd057..54e70b744e1 100644 --- a/command/job_plan.go +++ b/command/job_plan.go @@ -237,9 +237,9 @@ func (c *JobPlanCommand) Run(args []string) int { } // Setup the options - opts := &api.PlanOptions{} - if diff { - opts.Diff = true + opts := &api.PlanOptions{ + // Always request the diff so we can tell if there are changes. + Diff: true, } if policyOverride { opts.PolicyOverride = true