Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
feat(core): adds support for nested key lookups (eg key: a.b.c to g…
Browse files Browse the repository at this point in the history
…et nested value in json secret) (#592)

* adds lodash get function for nested keys lookup

* removed semicolon

* added hasIn for nested property check, use get to return nested property value
  • Loading branch information
jonathonbattista authored Feb 5, 2021
1 parent 74d4459 commit 190e6db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/backends/kv-backend.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const AbstractBackend = require('./abstract-backend')
const { get, hasIn } = require('lodash')

/** Key Value backend class. */
class KVBackend extends AbstractBackend {
Expand Down Expand Up @@ -61,11 +62,11 @@ class KVBackend extends AbstractBackend {
return
}

if (!(property in parsedValue)) {
if (!(hasIn(parsedValue, property))) {
throw new Error(`Could not find property ${property} in ${key}`)
}

value = parsedValue[property]
value = get(parsedValue, property)
}

if (isBinary) {
Expand Down

0 comments on commit 190e6db

Please sign in to comment.