nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: godaddy/kubernetes-external-secrets
Pull request #40 (2019-04-09 17:00:27)

feat(data): support `.data` in the `secretDescriptor`
This mirrors `Secret` objects.


Patch:
diff --git a/lib/backends/kv-backend.js b/lib/backends/kv-backend.js
index 7c18237..baedc10 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


Test patch:
diff --git a/lib/backends/kv-backend.test.js b/lib/backends/kv-backend.test.js
index 6ec56bf..1bcddc3 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'
         }, {
Repository: godaddy/kubernetes-external-secrets
Pull request #243 (2019-12-04 12:08:06)

Fix typo


Patch:
diff --git a/README.md b/README.md
index b89f869..19028a7 100644
--- a/README.md
+++ b/README.md
@@ -312,7 +312,7 @@ kubectl create secret generic vault-ca --from-file=./ca.pem
 ```
 
 ```yml
-# vaules.yaml
+# values.yaml
 env:
   VAULT_ADDR: https://vault.domain.tld
   NODE_EXTRA_CA_CERTS: "/usr/local/share/ca-certificates/ca.pem"
diff --git a/lib/backends/kv-backend.js b/lib/backends/kv-backend.js
index 6c4aa13..7f8d79a 100644
--- a/lib/backends/kv-backend.js
+++ b/lib/backends/kv-backend.js
@@ -108,10 +108,16 @@ class KVBackend extends AbstractBackend {
       }), {})
 
     const encodedEntries = Object.entries(plainValues)
-      .map(([name, plainValue]) => [
-        name,
-        (Buffer.from(`${plainValue}`, 'utf8')).toString('base64')
-      ])
+      .map(([name, plainValue]) => {
+        let bufferValue = plainValue
+        if (!(plainValue instanceof Buffer)) {
+          bufferValue = Buffer.from(`${plainValue}`, 'utf8')
+        }
+        return [
+          name,
+          bufferValue.toString('base64')
+        ]
+      })
 
     return Object.fromEntries(encodedEntries)
   }


Test patch:
diff --git a/lib/backends/kv-backend.test.js b/lib/backends/kv-backend.test.js
index a0c5ee2..0ecc0d0 100644
--- a/lib/backends/kv-backend.test.js
+++ b/lib/backends/kv-backend.test.js
@@ -382,5 +382,25 @@ describe('kv-backend', () => {
         specOptions: { }
       })
     })
+
+    it('do not skew binary data', async () => {
+      kvBackend._fetchDataValues
+        .resolves([{
+          textProperty: 'text',
+          binaryProperty: Buffer.from('test', 'utf-8'),
+          binaryProperty2: Buffer.from([0xEFBFBDEF, 2, 3])
+        }])
+
+      const manifestData = await kvBackend
+        .getSecretManifestData({
+          spec: { }
+        })
+
+      expect(manifestData).deep.equals({
+        textProperty: 'dGV4dA==', // base 64 value of text
+        binaryProperty: 'dGVzdA==', // base 64 value of test
+        binaryProperty2: '7wID' // base 64 value of binary data
+      })
+    })
   })
 })
Repository: godaddy/kubernetes-external-secrets
Pull request #244 (2019-12-05 16:07:41)

Do not skew binary data
In some cases when AWS Secret Manage secret has a type `Binary` the value can be corrupted during uploading to Kubernetes.
`.SecretBinary` returns Buffer and it should not be converted.
Should fix https://github.com/godaddy/kubernetes-external-secrets/issues/235

Could you please review this @Flydiverny  @silasbw ?


Patch:
diff --git a/lib/backends/kv-backend.js b/lib/backends/kv-backend.js
index 6c4aa13..7f8d79a 100644
--- a/lib/backends/kv-backend.js
+++ b/lib/backends/kv-backend.js
@@ -108,10 +108,16 @@ class KVBackend extends AbstractBackend {
       }), {})
 
     const encodedEntries = Object.entries(plainValues)
-      .map(([name, plainValue]) => [
-        name,
-        (Buffer.from(`${plainValue}`, 'utf8')).toString('base64')
-      ])
+      .map(([name, plainValue]) => {
+        let bufferValue = plainValue
+        if (!(plainValue instanceof Buffer)) {
+          bufferValue = Buffer.from(`${plainValue}`, 'utf8')
+        }
+        return [
+          name,
+          bufferValue.toString('base64')
+        ]
+      })
 
     return Object.fromEntries(encodedEntries)
   }


Test patch:
diff --git a/lib/backends/kv-backend.test.js b/lib/backends/kv-backend.test.js
index a0c5ee2..0ecc0d0 100644
--- a/lib/backends/kv-backend.test.js
+++ b/lib/backends/kv-backend.test.js
@@ -382,5 +382,25 @@ describe('kv-backend', () => {
         specOptions: { }
       })
     })
+
+    it('do not skew binary data', async () => {
+      kvBackend._fetchDataValues
+        .resolves([{
+          textProperty: 'text',
+          binaryProperty: Buffer.from('test', 'utf-8'),
+          binaryProperty2: Buffer.from([0xEFBFBDEF, 2, 3])
+        }])
+
+      const manifestData = await kvBackend
+        .getSecretManifestData({
+          spec: { }
+        })
+
+      expect(manifestData).deep.equals({
+        textProperty: 'dGV4dA==', // base 64 value of text
+        binaryProperty: 'dGVzdA==', // base 64 value of test
+        binaryProperty2: '7wID' // base 64 value of binary data
+      })
+    })
   })
 })