open-vault/command
Alexander Scheel 9a3f34a41e
Vault CLI: show detailed information with ListResponseWithInfo (#15417)
* CLI: Add ability to display ListResponseWithInfos

The Vault Server API includes a ListResponseWithInfo call, allowing LIST
responses to contain additional information about their keys. This is in
a key=value mapping format (both for each key, to get the additional
metadata, as well as within each metadata).

Expand the `vault list` CLI command with a `-detailed` flag (and env var
VAULT_DETAILED_LISTS) to print this additional metadata. This looks
roughly like the following:

    $ vault list -detailed pki/issuers
    Keys                                    issuer_name
    ----                                    -----------
    0cba84d7-bbbe-836a-4ff6-a11b31dc0fb7    n/a
    35dfb02d-0cdb-3d35-ee64-d0cd6568c6b0    n/a
    382fad1e-e99c-9c54-e147-bb1faa8033d3    n/a
    8bb4a793-2ad9-460c-9fa8-574c84a981f7    n/a
    8bd231d7-20e2-f21f-ae1a-7aa3319715e7    n/a
    9425d51f-cb81-426d-d6ad-5147d092094e    n/a
    ae679732-b497-ab0d-3220-806a2b9d81ed    n/a
    c5a44a1f-2ae4-2140-3acf-74b2609448cc    utf8
    d41d2419-efce-0e36-c96b-e91179a24dc1    something

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Allow detailed printing of LIST responses in JSON

When using the JSON formatter, only the absolute list of keys were
returned. Reuse the `-detailed` flag value for the `-format=json` list
response printer, allowing us to show the complete API response returned
by Vault.

This returns something like the following:

    {
      "request_id": "e9a25dcd-b67a-97d7-0f08-3670918ef3ff",
      "lease_id": "",
      "lease_duration": 0,
      "renewable": false,
      "data": {
        "key_info": {
          "0cba84d7-bbbe-836a-4ff6-a11b31dc0fb7": {
            "issuer_name": ""
          },
          "35dfb02d-0cdb-3d35-ee64-d0cd6568c6b0": {
            "issuer_name": ""
          },
          "382fad1e-e99c-9c54-e147-bb1faa8033d3": {
            "issuer_name": ""
          },
          "8bb4a793-2ad9-460c-9fa8-574c84a981f7": {
            "issuer_name": ""
          },
          "8bd231d7-20e2-f21f-ae1a-7aa3319715e7": {
            "issuer_name": ""
          },
          "9425d51f-cb81-426d-d6ad-5147d092094e": {
            "issuer_name": ""
          },
          "ae679732-b497-ab0d-3220-806a2b9d81ed": {
            "issuer_name": ""
          },
          "c5a44a1f-2ae4-2140-3acf-74b2609448cc": {
            "issuer_name": "utf8"
          },
          "d41d2419-efce-0e36-c96b-e91179a24dc1": {
            "issuer_name": "something"
          }
        },
        "keys": [
          "0cba84d7-bbbe-836a-4ff6-a11b31dc0fb7",
          "35dfb02d-0cdb-3d35-ee64-d0cd6568c6b0",
          "382fad1e-e99c-9c54-e147-bb1faa8033d3",
          "8bb4a793-2ad9-460c-9fa8-574c84a981f7",
          "8bd231d7-20e2-f21f-ae1a-7aa3319715e7",
          "9425d51f-cb81-426d-d6ad-5147d092094e",
          "ae679732-b497-ab0d-3220-806a2b9d81ed",
          "c5a44a1f-2ae4-2140-3acf-74b2609448cc",
          "d41d2419-efce-0e36-c96b-e91179a24dc1"
        ]
      },
      "warnings": null
    }

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add changelog

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Use field on UI rather than secret.Data

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Only include headers from visitable key_infos

Certain API endpoints return data from non-visitable key_infos, by
virtue of using a hand-rolled response. Limit our headers to those
from visitable key_infos. This means we won't return entire columns with
n/a entries, if no key matches the key_info key that includes that
header.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Use setupEnv sourced detailed info

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Fix changelog environment variable

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Fix broken tests using setupEnv

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
2022-05-18 13:00:50 -04:00
..
agent VAULT-5935 agent: redact renew-self if using auto auth (#15380) 2022-05-12 09:25:55 -07:00
config Convert to Go 1.17 go:build directive (#13579) 2022-01-05 12:02:03 -06:00
server Query and Precompute Non-Contiguous Segments in the Activity Log (#15352) 2022-05-17 12:17:32 -07:00
test-fixtures
token reformat using 'make fmt' (#13794) 2022-01-27 10:06:34 -08:00
agent.go Added optional -log-level flag to 'operator migrate' command (#15405) 2022-05-12 15:56:25 -04:00
agent_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
approle_concurrency_integ_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
audit.go
audit_disable.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
audit_disable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
audit_enable.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
audit_enable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
audit_list.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
audit_list_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
auth.go
auth_disable.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
auth_disable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
auth_enable.go Fix description of StringSliceVar options (#14439) 2022-03-14 14:11:49 -04:00
auth_enable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
auth_help.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
auth_help_test.go
auth_list.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
auth_list_test.go
auth_move.go remount cli changes (#14159) 2022-02-18 08:50:05 -08:00
auth_move_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
auth_test.go
auth_tune.go Fix description of StringSliceVar options (#14439) 2022-03-14 14:11:49 -04:00
auth_tune_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
base.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
base_flags.go Fix integer overflows with new parseutil (#15437) 2022-05-16 13:57:19 -04:00
base_flags_test.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
base_helpers.go Typo and clarity fixes (#14081) 2022-02-15 10:43:49 -08:00
base_helpers_test.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
base_predict.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
base_predict_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
base_test.go CLI: add new -header option to be able to add headers to all cli requests #8754 (#12508) 2021-10-27 11:04:04 -04:00
command_test.go Update deps for consul-template 0.29.0 (#15293) 2022-05-05 10:30:40 -07:00
commands.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
commands_nonwindows.go Convert to Go 1.17 go:build directive (#13579) 2022-01-05 12:02:03 -06:00
commands_windows.go Convert to Go 1.17 go:build directive (#13579) 2022-01-05 12:02:03 -06:00
config.go
config_test.go
debug.go Add DR Metric scraping capability to debug command (#15316) 2022-05-06 16:04:08 -04:00
debug_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
delete.go vault delete should allow the same output options as vault write,… (#11992) 2021-07-06 10:36:07 -04:00
delete_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
format.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
format_test.go Add build date (#14957) 2022-04-19 14:28:08 -04:00
kv.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_delete.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_destroy.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_enable_versioning.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
kv_get.go [VAULT-14990] Support retrieving kv secret paths with trailing spaces (#15188) 2022-05-10 14:07:45 -07:00
kv_helpers.go Global flag that outputs minimum policy HCL required for an operation (#14899) 2022-04-27 16:35:18 -07:00
kv_list.go Typo and clarity fixes (#14081) 2022-02-15 10:43:49 -08:00
kv_metadata.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_metadata_delete.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_metadata_get.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_metadata_patch.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_metadata_patch_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
kv_metadata_put.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_metadata_put_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
kv_patch.go Global flag that outputs minimum policy HCL required for an operation (#14899) 2022-04-27 16:35:18 -07:00
kv_put.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_rollback.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
kv_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
kv_undelete.go Mount flag syntax to mitigate confusion from KV-v2 path discrepancies (#14807) 2022-04-06 13:58:06 -07:00
lease.go
lease_lookup.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
lease_lookup_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
lease_renew.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
lease_renew_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
lease_revoke.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
lease_revoke_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
list.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
list_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
login.go VAULT-5885: Fix erroneous success message in case of two-phase MFA, and provide MFA information in table format (#15428) 2022-05-17 14:03:02 -04:00
login_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
main.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
monitor.go Migrate to sdk/internalshared libs in go-secure-stdlib (#12090) 2021-07-15 20:17:31 -04:00
monitor_test.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
namespace.go API Lock CLI OSS port (#12925) 2021-10-26 10:52:29 -06:00
namespace_api_lock.go API Lock CLI OSS port (#12925) 2021-10-26 10:52:29 -06:00
namespace_api_unlock.go API Lock CLI OSS port (#12925) 2021-10-26 10:52:29 -06:00
namespace_create.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
namespace_delete.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
namespace_list.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
namespace_lookup.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator.go
operator_diagnose.go Diagnose partial/missing telemetry configuration (#12802) 2021-10-20 16:47:59 -05:00
operator_diagnose_test.go Vault-6037 making filesystem permissions check opt-in (#15452) 2022-05-17 11:34:31 -07:00
operator_generate_root.go Add helper for encoding/decoding root tokens and OTP generation in SDK module (#10504) (#10505) 2021-12-01 08:05:49 -05:00
operator_generate_root_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
operator_init.go Rename master key to root key (#13324) 2021-12-06 17:12:20 -08:00
operator_init_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
operator_key_status.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_key_status_test.go
operator_members.go Add "operator members" command to list nodes in the cluster. (#13292) 2021-11-30 14:49:58 -05:00
operator_migrate.go Added optional -log-level flag to 'operator migrate' command (#15405) 2022-05-12 15:56:25 -04:00
operator_migrate_test.go Migrate to sdk/internalshared libs in go-secure-stdlib (#12090) 2021-07-15 20:17:31 -04:00
operator_raft.go
operator_raft_autopilot_get_config.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_autopilot_set_config.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_autopilot_state.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_join.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_listpeers.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_remove_peer.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_snapshot.go
operator_raft_snapshot_restore.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_raft_snapshot_save.go Fixing excessive unix file permissions (#14791) 2022-04-01 12:57:38 -04:00
operator_rekey.go Rename master key to root key (#13324) 2021-12-06 17:12:20 -08:00
operator_rekey_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
operator_seal.go Rename master key to root key (#13324) 2021-12-06 17:12:20 -08:00
operator_seal_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
operator_step_down.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
operator_step_down_test.go
operator_unseal.go Rename master key to root key (#13324) 2021-12-06 17:12:20 -08:00
operator_unseal_test.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
operator_usage.go Global flag that outputs minimum policy HCL required for an operation (#14899) 2022-04-27 16:35:18 -07:00
path_help.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
path_help_test.go
path_map_upgrade_api_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
pgp_test.go reformat using 'make fmt' (#13794) 2022-01-27 10:06:34 -08:00
plugin.go
plugin_deregister.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_deregister_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
plugin_info.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_info_test.go
plugin_list.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_list_test.go
plugin_register.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_register_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
plugin_reload.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_reload_status.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
plugin_reload_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
plugin_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
policy.go
policy_delete.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
policy_delete_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
policy_fmt.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
policy_fmt_test.go
policy_list.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
policy_list_test.go
policy_read.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
policy_read_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
policy_write.go Warn on upper case in policy name (#14670) 2022-03-24 13:29:11 -07:00
policy_write_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
print.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
print_token.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
read.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
read_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
rotate.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
rotate_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
secrets.go
secrets_disable.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
secrets_disable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
secrets_enable.go Fix description of StringSliceVar options (#14439) 2022-03-14 14:11:49 -04:00
secrets_enable_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
secrets_list.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
secrets_list_test.go
secrets_move.go remount cli changes (#14159) 2022-02-18 08:50:05 -08:00
secrets_move_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
secrets_tune.go Fix description of StringSliceVar options (#14439) 2022-03-14 14:11:49 -04:00
secrets_tune_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
server.go Added optional -log-level flag to 'operator migrate' command (#15405) 2022-05-12 15:56:25 -04:00
server_noprofile.go Convert to Go 1.17 go:build directive (#13579) 2022-01-05 12:02:03 -06:00
server_profile.go Convert to Go 1.17 go:build directive (#13579) 2022-01-05 12:02:03 -06:00
server_test.go Vault-6037 making filesystem permissions check opt-in (#15452) 2022-05-17 11:34:31 -07:00
server_util.go Add infrastructure for exposing FIPS status (#14127) 2022-02-17 13:03:57 -05:00
ssh.go command: deprecate errwrap.Wrapf() (#11744) 2021-06-02 09:22:31 -04:00
ssh_test.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
status.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
status_test.go
token.go
token_capabilities.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
token_capabilities_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
token_create.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
token_create_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
token_lookup.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
token_lookup_test.go
token_renew.go Update token renew docs (#12572) 2021-09-16 16:54:46 -07:00
token_renew_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
token_revoke.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
token_revoke_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
unwrap.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
unwrap_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00
util.go cleanup unused code and fix t.Fatal usage in goroutine in testing (#11694) 2021-09-30 07:33:14 -04:00
version.go Run a more strict formatter over the code (#11312) 2021-04-08 09:43:39 -07:00
version_history.go Add build date (#14957) 2022-04-19 14:28:08 -04:00
version_history_test.go Vault CLI: show detailed information with ListResponseWithInfo (#15417) 2022-05-18 13:00:50 -04:00
version_test.go
write.go add MFA validation support to vault login command (#14425) 2022-03-14 15:54:41 -04:00
write_test.go Revert the WithContext changes to vault tests (#14947) 2022-04-07 15:12:58 -04:00