1
0
Fork 0
mirror of https://github.com/Luzifer/vault2env.git synced 2024-12-20 20:21:20 +00:00

Support json.Number data format

returned on some keys in Vault 1.13

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-04-08 18:55:53 +02:00
parent fa29e46842
commit a9a8b55775
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

12
main.go
View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -149,7 +150,16 @@ func main() {
if newKey, ok := transformMap[key]; ok { if newKey, ok := transformMap[key]; ok {
key = newKey key = newKey
} }
envData[key] = v.(string)
switch vI := v.(type) {
case string:
envData[key] = vI
case json.Number:
envData[key] = string(vI)
default:
log.Errorf("Vault key %q.%q contained unexpected data type %T", vaultKey, k, v)
continue
}
} }
} }