From 65ec00da1d0b61986d19965166983dc4f1b93619 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 25 Sep 2024 09:12:52 -0400 Subject: [PATCH] cli: fix -t flag on job status command (#24054) In #18925 we added a `-json` flag to the `job status` command, but the argument handling had a bug where it would always set the `-json` flag if either the `-t` or `-json` flags were set, resulting in a misleading error. Instead, pass the `-json` flag value into the formatter. Fixes: https://github.com/hashicorp/nomad/issues/24050 --- .changelog/24054.txt | 3 +++ command/job_status.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .changelog/24054.txt diff --git a/.changelog/24054.txt b/.changelog/24054.txt new file mode 100644 index 000000000..448f43df7 --- /dev/null +++ b/.changelog/24054.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fixed a bug in job status command where -t would act as though -json was also set +``` diff --git a/command/job_status.go b/command/job_status.go index 4de0d6e19..0f444646c 100644 --- a/command/job_status.go +++ b/command/job_status.go @@ -173,7 +173,7 @@ func (c *JobStatusCommand) Run(args []string) int { return 1 } - out, err := Format(true, c.tmpl, jsonJobs) + out, err := Format(c.json, c.tmpl, jsonJobs) if err != nil { c.Ui.Error(err.Error()) return 1 @@ -220,7 +220,7 @@ func (c *JobStatusCommand) Run(args []string) int { return 1 } - out, err := Format(true, c.tmpl, jsonJobs) + out, err := Format(c.json, c.tmpl, jsonJobs) if err != nil { c.Ui.Error(err.Error()) return 1