Open noahehall opened 1 year ago
Hi @noahehall and thanks for raising this. I agree and think this would be really useful, and therefore will add it to our backlog.
Hi @jrasell , do you have a list of nomad cli command that we want to add -json
flag? I can help out on this if you don't mind
Hi @dttung2905, that sounds great. I have used grep -L "\-json" --exclude="*_test.go" --exclude="*_delete.go" command/*.go
to get a better view of the files that could be suitable for adding the -json
and t
flags. All those listed, however, would not be suitable.
Those that seem like good initial candidates would be:
Please let me know if you have any questions or thoughts.
I closed some issues that were related to this one. The commands mentioned in them were:
nomad acl token create
nomad node status
nomad alloc status
Just wanted to post an update of some internal progress that has been made internally over the past few weeks. The following PR's have been raised to add -json
and -t
flags to the CLI where missing:
Thanks to @Juanadelacuesta for this work!
@Juanadelacuesta excellent work!
I'm interested in contributing to Nomad, are there any other commands that could use the -json
and -t
flags?
I saw that acl token create
is one that could use it but it seems like acl token list
already accomplishes this with the flags already included.
Hi @BBBmau 👋
That's awesome that you're interested in contributing to Nomad! I think any info
, status
, list
command should have a -json
and -t
flag.
For create
and apply
commands, as the example you mentioned, it would be helpful to have these flags when the output has the generated resource, and so you can pipe its output to something else. For example, it would allow you to do something like this:
$ nomad acl token create | jq -r '.SecretID' > secret_token.txt
(for consistency, all create
and apply
should probably have these flags, but that's likely a bigger scope, specially since some apply
commands already have a -json
flag to change input parsing, but I digress 😅 )
https://github.com/hashicorp/nomad/pull/16055 already added these flags to acl token create
but I updated the issue body with a more exhaustive list of commands still missing them. Feel free to pick anyone of them to work next and let us know if you need any help 🙂
Proposal
-json
output for inspection cmds (e.g.nomad server members
) would be awesomenomad node status -verbose -json
can be piped to jq and drilled down to retrieve info,-json
optionUse-cases
List of commands missing flags
nomad acl token update
(refer to https://github.com/hashicorp/nomad/pull/16055 for an example implementation)nomad acl token self
(refer to https://github.com/hashicorp/nomad/pull/16055 for an example implementation)nomad acl token info
(refer to https://github.com/hashicorp/nomad/pull/16055 for an example implementation)nomad acl policy info
nomad job status
(would likely makenomad job inspect
redundant)nomad job scaling-events
nomad operator autopilot get-config
nomad operator gossip keyring list
nomad operator raft list-peers
nomad operator snapshot inspect
The following commands require a Nomad license, and it may not be possible to work on them without one.
nomad license get
nomad sentinel list
nomad sentinel read
The following commands are unusual in the sense they are not backed by a Go struct, so a JSON output would need to be created manually.
nomad alloc fs
(file stat and directory output)nomad operator raft info