Luzifer / vault2env

Small utility to transfer fields of a key in Vault into the environment
Apache License 2.0
9 stars 2 forks source link

Panic when using K/V Version 2 secret engine #4

Open gslin opened 3 years ago

gslin commented 3 years ago

Vault 1.6.1 and vault2env (latest master):

gslin@home [~/tmp/vault2env] [13:42/W4] (master) git reflog 
2d782ce (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: clone: from https://github.com/Luzifer/vault2env.git

Not sure if it's because data structure has been changed in Vault:

gslin@home [~/tmp/vault2env] [13:41/W4] (master) ./vault2env --key=kv/data/app1/ -- env
panic: interface conversion: interface {} is map[string]interface {}, not string

goroutine 1 [running]:
main.main()
        /home/gslin/tmp/vault2env/main.go:152 +0x1557

The corresponding data is:

gslin@home [~/tmp/vault2env] [13:42/W4] (master) vault read kv/data/app1     
Key         Value
---         -----
data        map[db_password:password db_username:username test:test]
metadata    map[created_time:2020-12-29T09:50:32.81045165Z deletion_time: destroyed:false version:2]
Luzifer commented 3 years ago

That looks like you are using the K/V Version 2 engine for kv/...… That might be an issue as the response differs from the K/V Version 1 engine…

I'll need to have a look at the response format and add Version 2 support…

gslin commented 3 years ago

Ouch... yes, I am using Version 2.