Skip to content
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

Option for json output for CLI #5904

Open
rgarrigue opened this issue May 28, 2019 · 4 comments
Open

Option for json output for CLI #5904

rgarrigue opened this issue May 28, 2019 · 4 comments
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature type/umbrella-☂️ Makes issue the "source of truth" for multiple requests relating to the same topic

Comments

@rgarrigue
Copy link

Feature Description

A global -out [table|json] option to modify the commands output from the current "table" to json

consul info -out json
{ "agent": {
	"check_monitors": 0,
	"check_ttls": 0,
	"checks": 5,
	...

or

consul acl token list
[
  { 
    "AccessorID":   "49f6bd35-0cc6-8acc-ee71-2ccfe8c57161",
    "Description":  "client service token",
    "Local":        "false",
    "Create Time":  "2019-05-27 11:28:40.321670815 +0000 UTC",
    "Legacy":       "false",
    "Policies": {
      {
        "AccessorID": "c4a6823e-62b0-1740-ea4a-1eef83988669",
        "Description": "client-service-policy"
      }
    }    
  },
  ...
]

Use Case(s)

consul CLI is very convenient for a bit of bash scripting, when one doesn't wan't to curl everything. One annoying bit is the "human readable" output, which need to be parsed to be exploitable. The good ol' | grep | awk and so on. But it's unreliable on the long term. Adding a "machine readable" output like json would allow using jq for a more sustainable result

@mkeeler mkeeler added type/enhancement Proposed improvement or new feature theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner labels May 31, 2019
@jewertow
Copy link

jewertow commented Oct 7, 2019

I will take care of it.

@wenerme
Copy link

wenerme commented Dec 16, 2019

Vault has these options

Output Options:

  -field=<string>
      Print only the field with the given name. Specifying this option will
      take precedence over other formatting directives. The result will not
      have a trailing newline making it ideal for piping to other processes.

  -format=<string>
      Print the output in the given format. Valid formats are "table", "json",
      or "yaml". The default is table. This can also be specified via the
      VAULT_FORMAT environment variable.

Really hop consul can get these, e.g. consul acl token read -id $ACCESSOR_ID -format json

@ghost
Copy link

ghost commented Jun 16, 2020

Is there any progress on this feature?

@dnephin
Copy link
Contributor

dnephin commented Jun 16, 2020

#7198 added -format=json to a bunch of the acl commands. It is available in 1.8.0. The first RC for 1.8.0 was just released.

More work will need to be done to add the json format to all the other commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature type/umbrella-☂️ Makes issue the "source of truth" for multiple requests relating to the same topic
Projects
None yet
Development

No branches or pull requests

6 participants