Skip to content

Commit

Permalink
Merge pull request #49 from lalamove/fix/vault-kv-version2
Browse files Browse the repository at this point in the history
Fix/vault kv version2
  • Loading branch information
francoispqt authored May 22, 2019
2 parents d8d9ac1 + 113e94f commit 5732359
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions loader/klvault/vaultloader.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package klvault

import (
"encoding/json"
"errors"
"fmt"
"net/url"
Expand Down Expand Up @@ -184,8 +185,8 @@ func (vl *Loader) Load(cs konfig.Values) error {
// confirming version exists on metadata and it is an int
if m, ok := s.Data["metadata"].(map[string]interface{}); ok {
kvData, dataOK := s.Data["data"].(map[string]interface{})
_, versionOK := m["version"].(int)
if versionOK && dataOK {
_, versionJSONNumberOK := m["version"].(json.Number)
if versionJSONNumberOK && dataOK {
sData = kvData
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions loader/klvault/vaultloader_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package klvault

import (
"encoding/json"
"errors"
"sync"
"testing"
Expand Down Expand Up @@ -75,7 +76,7 @@ func TestVaultLoader(t *testing.T) {
"created_time": "2018-03-22T02:24:06.945319214Z",
"deletion_time": "",
"destroyed": false,
"version": 1,
"version": json.Number("1"),
},
},
LeaseDuration: int(1 * time.Hour / time.Second),
Expand All @@ -92,7 +93,7 @@ func TestVaultLoader(t *testing.T) {
"created_time": "2018-03-22T02:24:06.945319214Z",
"deletion_time": "",
"destroyed": false,
"version": 1,
"version": json.Number("1"),
},
},
LeaseDuration: int(1 * time.Hour / time.Second),
Expand Down

0 comments on commit 5732359

Please sign in to comment.