Using vault-client-go to list KVs

Hi… probably a fairly simple question… just trying to list a kv-v2 path using the vault-client-go

l, err := client.List(ctx, "drew", vault.WithMountPath("kv-v2"))
if err != nil {
	log.Fatal(err)
}

error:
404: no handler for route "drew/". route entry not found.

proof there is a key there:

$ vault kv list kv-v2
Keys
----
beth/
bmc/
drew/
my-secret
my-secret/

$ vault secrets list
Path          Type         Accessor              Description
----          ----         --------              -----------
cubbyhole/    cubbyhole    cubbyhole_614d4f86    per-token private secret storage
identity/     identity     identity_ab5c6bc0     identity store
kv-v2/        kv           kv_57913fa7           n/a
secret/       kv           kv_f0a62aaa           key/value secret storage

Hi,

vault-cli-go is not the name of this library, it is vault-client-go. Fortunately I recognize the code anyway, but you’re really limiting potential answerers, if you give the wrong name of the thing you’re asking about.

You have called the generic List operation, rather than an operation specific to any particular type of mount. The generic operations do make use of WithMountPath, and ignore the fact that you have used it.

Additionally, the generic operations have no knowledge that they are interacting with a KVv2 specifically, so you’d need to specify the appropriate URL-path for the relevant KVv2 API.

So you would instead need to do:

l, err := client.List(ctx, "kv-v2/metadata/drew")

or, you could change List to Secrets.KvV2ListMetadata instead, to use the kv-v2 specific function.

thanks… yeah was late on the east coast when i posted.

Cunningham’s law in action, i suppose: Cunningham's Law - Meta