diff --git a/lib/backends/kv-backend.js b/lib/backends/kv-backend.js index 7c18237b..baedc107 100644 --- a/lib/backends/kv-backend.js +++ b/lib/backends/kv-backend.js @@ -22,8 +22,8 @@ class KVBackend extends AbstractBackend { * object, this is the property name of the value to use. * @returns {Promise} Promise object representing secret property values. */ - _fetchSecretPropertyValues ({ secretProperties }) { - return Promise.all(secretProperties.map(async secretProperty => { + _fetchSecretPropertyValues ({ externalData }) { + return Promise.all(externalData.map(async secretProperty => { this._logger.info(`fetching secret property ${secretProperty.name}`) const value = await this._get({ secretKey: secretProperty.key }) @@ -48,10 +48,12 @@ class KVBackend extends AbstractBackend { */ async getSecretManifestData ({ secretDescriptor }) { const data = {} + // Use secretDescriptor.properties to be backwards compatible. + const externalData = secretDescriptor.data || secretDescriptor.properties const secretPropertyValues = await this._fetchSecretPropertyValues({ - secretProperties: secretDescriptor.properties + externalData }) - secretDescriptor.properties.forEach((secretProperty, index) => { + externalData.forEach((secretProperty, index) => { data[secretProperty.name] = (Buffer.from(secretPropertyValues[index], 'utf8')).toString('base64') }) return data diff --git a/lib/backends/kv-backend.test.js b/lib/backends/kv-backend.test.js index 6ec56bf0..1bcddc38 100644 --- a/lib/backends/kv-backend.test.js +++ b/lib/backends/kv-backend.test.js @@ -28,7 +28,7 @@ describe('SecretsManagerBackend', () => { it('handles secrets values that are objects', async () => { kvBackend._get.onFirstCall().resolves({ foo: 'bar' }) const secretPropertyValues = await kvBackend._fetchSecretPropertyValues({ - secretProperties: [{ + externalData: [{ key: 'mocked-key', name: 'mocked-name', property: 'foo' @@ -42,7 +42,7 @@ describe('SecretsManagerBackend', () => { kvBackend._get.onSecondCall().resolves('fakePropertyValue2') const secretPropertyValues = await kvBackend._fetchSecretPropertyValues({ - secretProperties: [{ + externalData: [{ key: 'fakePropertyKey1', name: 'fakePropertyName1' }, { @@ -103,7 +103,7 @@ describe('SecretsManagerBackend', () => { }) expect(kvBackend._fetchSecretPropertyValues.calledWith({ - secretProperties: [{ + externalData: [{ key: 'fakePropertyKey1', name: 'fakePropertyName1' }, {