From 856d8e07370f8fd69546eb50043556e2cd35448e Mon Sep 17 00:00:00 2001 From: Silas Boyd-Wickizer Date: Wed, 20 Feb 2019 09:35:39 -0800 Subject: [PATCH] fix(updating): use PUT not PATCH when updating an existing Secret (#20) PATCH is going to result in a merge, potentially resulting in a union of the previous Secret's fields and the updated Secret's fields. --- lib/poller.js | 2 +- lib/poller.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/poller.js b/lib/poller.js index 1422c165..bbedb077 100644 --- a/lib/poller.js +++ b/lib/poller.js @@ -98,7 +98,7 @@ class Poller { } this._logger.info(`updating secret ${secretName}`); - return kubeNamespace.secrets(secretName).patch({ body: secretManifest }); + return kubeNamespace.secrets(secretName).put({ body: secretManifest }); } /** diff --git a/lib/poller.test.js b/lib/poller.test.js index a1128da3..7cb12cd2 100644 --- a/lib/poller.test.js +++ b/lib/poller.test.js @@ -186,13 +186,13 @@ describe('Poller', () => { it('updates secret', async () => { kubeNamespaceMock.get = sinon.stub().resolves({ fakeSecretName: 'fakeSecretString' }); - kubeNamespaceMock.patch = sinon.stub().resolves(); + kubeNamespaceMock.put = sinon.stub().resolves(); await poller._upsertKubernetesSecret(upsertSecretParams); expect(kubeNamespaceMock.secrets.calledWith('fakeSecretName')).to.be.true; expect(kubeNamespaceMock.get.called).to.be.true; - expect(kubeNamespaceMock.patch.calledWith({ + expect(kubeNamespaceMock.put.calledWith({ body: { apiVersion: 'v1', kind: 'Secret',