-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: add -json flag to support job commands #12591
Conversation
764cdcc
to
3a8de51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed the test failure on my original review. It looks like the plan command is failing with a redefined flag:
panic: job plan flag redefined: hcl1 [recovered]
panic: job plan flag redefined: hcl1
goroutine 19967 [running]:
testing.tRunner.func1.2({0x22f6e60, 0xc003aae680})
/usr/local/go/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:1212 +0x218
panic({0x22f6e60, 0xc003aae680})
/usr/local/go/src/runtime/panic.go:1038 +0x215
flag.(*FlagSet).Var(0xc0042ff920, {0x2ea2d28, 0xc0048eb3b0}, {0x2907e23, 0x4}, {0x0, 0x0})
/usr/local/go/src/flag/flag.go:879 +0x2f4
flag.(*FlagSet).BoolVar(...)
/usr/local/go/src/flag/flag.go:632
github.com/hashicorp/nomad/command.(*JobPlanCommand).Run(0xc0048eb300, {0xc004f6f410, 0x3, 0x3})
/home/circleci/go/src/github.com/hashicorp/nomad/command/job_plan.go:142 +0x237
github.com/hashicorp/nomad/command.TestPlanCommand_Fails(0xc00429b6c0)
/home/circleci/go/src/github.com/hashicorp/nomad/command/job_plan_test.go:33 +0x198
testing.tRunner(0xc00429b6c0, 0x2a227d8)
/usr/local/go/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1306 +0x35a
``
3a8de51
to
d03714a
Compare
d03714a
to
f00aea8
Compare
f00aea8
to
5d1d2b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ nomad job inspect example | jq '.Job.TaskGroups[0].Count = 2' | nomad job run -json -
🎉
Just needs a quick fix in the CHANGELOG file.
While the CLI has always supported running JSON jobs, its support has been via HCLv2's JSON parsing. I have no idea what format it expects the job to be in, but it's absolutely not in the same format as the API expects. So I ignored that and added a new -json flag to explicitly support *API* style JSON jobspecs. The jobspecs can even have the wrapping {"Job": {...}} envelope or not!
We haven't been able to validate inside driver config stanzas ever since the move to task driver plugins. 😭
5d1d2b2
to
413bd49
Compare
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #6758
Fixes #1749
While the CLI has always supported running JSON jobs, its support has
been via HCLv2's JSON parsing. I have no idea what format it expects the
job to be in, but it's absolutely not in the same format as the API
expects.
So I ignored that and added a new -json flag to explicitly support API
style JSON jobspecs.