Skip to content

Commit

Permalink
allow to read integer
Browse files Browse the repository at this point in the history
  • Loading branch information
mc-slava committed May 27, 2020
1 parent fe8f381 commit d1da6fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vault/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"os"
"strconv"

"github.com/hashicorp/vault/api"
)
Expand Down Expand Up @@ -81,10 +80,12 @@ func (v *Vault) Read(path string) map[string]interface{} {
for k, v := range s.Data {
switch t := v.(type) {
case json.Number:
if i, err := strconv.Atoi(string(t)); err != nil {
out[k] = int(i)
if n, err := v.(json.Number).Int64(); err == nil {
out[k] = n
} else if f, err := v.(json.Number).Float64(); err == nil {
out[k] = f
} else {
fmt.Printf("error reading value at %s, key=%s, type=%T\n", path, k, v)
out[k] = v
}
case string:
out[k] = base64.StdEncoding.EncodeToString([]byte(t))
Expand Down

0 comments on commit d1da6fb

Please sign in to comment.