Skip to content

Commit

Permalink
cli: fix panic on job plan when -diff=false
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lgfa29 committed Apr 20, 2023
1 parent e169847 commit ef9f250
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions command/job_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef9f250

Please sign in to comment.