Skip to content

Commit 3246a76

Browse files
committed
[Enhancement] Adds TLS redis configuration support for encryption-at-rest enabled redis instances
1 parent 6b68ba2 commit 3246a76

File tree

5 files changed

+68
-10
lines changed

5 files changed

+68
-10
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/libpeerconnection.log
1616
npm-debug.log
1717
testem.log
18+
/.vscode

Diff for: README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ The Redis client to be used to upload files to the Redis store. By default this
158158

159159
A message that will be displayed after the file has been successfully uploaded to Redis. By default this message will only display if the revision for `revisionData.revisionKey` of the deployment context has been activated.
160160

161-
*Default:*
162-
163161
```javascript
164162
if (context.revisionData.revisionKey && !context.revisionData.activatedRevisionKey) {
165163
return "Deployed but did not activate revision " + context.revisionData.revisionKey + ". "
@@ -168,6 +166,12 @@ if (context.revisionData.revisionKey && !context.revisionData.activatedRevisionK
168166
}
169167
```
170168

169+
### tls
170+
171+
An optional tls configuration object for connecting to redis instances with encryption-in-transit enabled. Please see [https://github.com/luin/ioredis#tls-options](https://github.com/luin/ioredis#tls-options) for available options
172+
173+
*Default:* `null`
174+
171175
### maxRecentUploads
172176

173177
The maximum number of recent revisions to keep in Redis.

Diff for: index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = {
5555
url: pluginHelper.readConfig('url'),
5656
host: pluginHelper.readConfig('host'),
5757
port: pluginHelper.readConfig('port'),
58+
tls: pluginHelper.readConfig('tls'),
5859
password: pluginHelper.readConfig('password'),
5960
database: pluginHelper.readConfig('database'),
6061
maxRecentUploads: pluginHelper.readConfig('maxRecentUploads'),
@@ -82,7 +83,7 @@ module.exports = {
8283
}
8384
}
8485

85-
['filePattern', 'distDir', 'keyPrefix', 'activationSuffix', 'activeContentSuffix', 'revisionKey', 'didDeployMessage', 'redisDeployClient', 'maxRecentUploads', 'revisionData'].forEach(this.applyDefaultConfigProperty.bind(this));
86+
['filePattern', 'distDir', 'keyPrefix', 'activationSuffix', 'activeContentSuffix', 'revisionKey', 'didDeployMessage', 'redisDeployClient', 'maxRecentUploads', 'revisionData','tls'].forEach(this.applyDefaultConfigProperty.bind(this));
8687

8788
this.log('config ok', { verbose: true });
8889
},

Diff for: lib/redis.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ module.exports = CoreObject.extend({
2323
if (options.database) {
2424
redisOptions.db = options.database;
2525
}
26+
27+
if (options.tls) {
28+
redisOptions.tls = options.tls
29+
}
2630
}
2731

2832
if (!RedisLib) {

Diff for: tests/unit/index-test.js

+55-7
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,54 @@ describe("redis plugin", function() {
253253
});
254254
});
255255

256+
describe("resolving tls from the pipeline", function() {
257+
it("uses the config data if it already exists", function() {
258+
var plugin = subject.createDeployPlugin({
259+
name: "redis"
260+
});
261+
262+
var config = {
263+
host: "somehost",
264+
port: 1234,
265+
tls: {
266+
secure: false
267+
}
268+
};
269+
var context = {
270+
ui: mockUi,
271+
project: stubProject,
272+
config: {
273+
redis: config
274+
}
275+
};
276+
277+
plugin.beforeHook(context);
278+
plugin.configure(context);
279+
assert.deepEqual(plugin.readConfig("tls"), { secure: false });
280+
});
281+
282+
it("resolves to undefined if not specified in config", function() {
283+
var plugin = subject.createDeployPlugin({
284+
name: "redis"
285+
});
286+
287+
var config = {
288+
host: "somehost"
289+
};
290+
var context = {
291+
ui: mockUi,
292+
project: stubProject,
293+
config: {
294+
redis: config
295+
}
296+
};
297+
298+
plugin.beforeHook(context);
299+
plugin.configure(context);
300+
assert.equal(plugin.readConfig("tls"), undefined);
301+
});
302+
})
303+
256304
describe("resolving revisionKey from the pipeline", function() {
257305
it("uses the config data if it already exists", function() {
258306
var plugin = subject.createDeployPlugin({
@@ -359,7 +407,7 @@ describe("redis plugin", function() {
359407

360408
return previous;
361409
}, []);
362-
assert.equal(messages.length, 12);
410+
assert.equal(messages.length, 13);
363411
});
364412
it("adds default config to the config object", function() {
365413
plugin.configure(context);
@@ -389,7 +437,7 @@ describe("redis plugin", function() {
389437
};
390438
plugin.beforeHook(context);
391439
});
392-
it("warns about missing optional filePattern, distDir, activationSuffix, revisionKey, didDeployMessage, maxNumberOfRecentUploads, and connection info", function() {
440+
it("warns about missing optional filePattern, distDir, activationSuffix, revisionKey, didDeployMessage, maxNumberOfRecentUploads, and connection info, tls", function() {
393441
plugin.configure(context);
394442
var messages = mockUi.messages.reduce(function(previous, current) {
395443
if (/- Missing config:\s.*, using default:\s/.test(current)) {
@@ -398,7 +446,7 @@ describe("redis plugin", function() {
398446

399447
return previous;
400448
}, []);
401-
assert.equal(messages.length, 11);
449+
assert.equal(messages.length, 12);
402450
});
403451
it("does not add default config to the config object", function() {
404452
plugin.configure(context);
@@ -429,7 +477,7 @@ describe("redis plugin", function() {
429477
};
430478
plugin.beforeHook(context);
431479
});
432-
it("warns about missing optional filePattern, distDir, keyPrefix, revisionKey, didDeployMessage, maxNumberOfRecentUploads, and connection info", function() {
480+
it("warns about missing optional filePattern, distDir, keyPrefix, revisionKey, didDeployMessage, maxNumberOfRecentUploads, tls, and connection info", function() {
433481
plugin.configure(context);
434482
var messages = mockUi.messages.reduce(function(previous, current) {
435483
if (/- Missing config:\s.*, using default:\s/.test(current)) {
@@ -438,7 +486,7 @@ describe("redis plugin", function() {
438486

439487
return previous;
440488
}, []);
441-
assert.equal(messages.length, 11);
489+
assert.equal(messages.length, 12);
442490
});
443491
it("does not add default config to the config object", function() {
444492
plugin.configure(context);
@@ -469,7 +517,7 @@ describe("redis plugin", function() {
469517
};
470518
plugin.beforeHook(context);
471519
});
472-
it("warns about missing optional filePattern, distDir, keyPrefix, activationSuffix, revisionKey, maxNumberOfRecentUploads, and didDeployMessage only", function() {
520+
it("warns about missing optional filePattern, distDir, keyPrefix, activationSuffix, revisionKey, maxNumberOfRecentUploads, tls, and didDeployMessage only", function() {
473521
plugin.configure(context);
474522
var messages = mockUi.messages.reduce(function(previous, current) {
475523
if (/- Missing config:\s.*, using default:\s/.test(current)) {
@@ -478,7 +526,7 @@ describe("redis plugin", function() {
478526

479527
return previous;
480528
}, []);
481-
assert.equal(messages.length, 10);
529+
assert.equal(messages.length, 11);
482530
});
483531

484532
it("does not add default config to the config object", function() {

0 commit comments

Comments
 (0)