Skip to content

Commit 2fe262d

Browse files
authored
Merge pull request #124 from ember-cli-deploy/redis-options
Allow specifying additional arguments to redis client
2 parents ac68204 + e3f24b5 commit 2fe262d

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ A Redis connection url to the Redis store
9494

9595
*Example:* 'redis://some-user:some-password@some-host.com:1234'
9696

97+
### redisOptions
98+
99+
Options to be passed to the redis client.
100+
101+
*Example:* { tls: { rejectUnauthorized: false } }
97102
### filePattern
98103

99104
A file matching this pattern will be uploaded to Redis.

index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ module.exports = {
4646
return context.commandOptions.revision || (context.revisionData && context.revisionData.revisionKey);
4747
},
4848
redisDeployClient(context, pluginHelper) {
49-
var redisLib = context._redisLib;
50-
var options = {
49+
let redisLib = context._redisLib;
50+
let libOptions = {
5151
url: pluginHelper.readConfig('url'),
5252
host: pluginHelper.readConfig('host'),
5353
port: pluginHelper.readConfig('port'),
5454
password: pluginHelper.readConfig('password'),
5555
database: pluginHelper.readConfig('database'),
56+
redisOptions: pluginHelper.readConfig('redisOptions'),
5657
maxRecentUploads: pluginHelper.readConfig('maxRecentUploads'),
5758
allowOverwrite: pluginHelper.readConfig('allowOverwrite'),
5859
activationSuffix: pluginHelper.readConfig('activationSuffix')
5960
};
6061

61-
return new Redis(options, redisLib);
62+
return new Redis(libOptions, redisLib);
6263
},
6364

6465
revisionData(context) {

lib/redis.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@ module.exports = CoreObject.extend({
55

66
init(options, lib) {
77
this._super();
8-
var redisOptions = {};
9-
var RedisLib = lib;
10-
8+
let libOptions = {};
9+
let RedisLib = lib;
1110
if (options.url) {
12-
redisOptions = this._stripUsernameFromConfigUrl(options.url);
11+
libOptions = { url: this._stripUsernameFromConfigUrl(options.url) };
1312
} else {
14-
redisOptions = {
13+
libOptions = {
1514
host: options.host,
1615
port: options.port
1716
};
1817

1918
if (options.password) {
20-
redisOptions.password = options.password;
19+
libOptions.password = options.password;
2120
}
2221

2322
if (options.database) {
24-
redisOptions.db = options.database;
23+
libOptions.db = options.database;
2524
}
2625
}
26+
if (options.redisOptions) {
27+
libOptions = Object.assign(libOptions, options.redisOptions);
28+
}
2729

2830
if (!RedisLib) {
2931
RedisLib = require('ioredis');
3032
}
3133

32-
this._client = new RedisLib(redisOptions);
34+
this._client = new RedisLib(libOptions);
3335

3436
this._maxRecentUploads = options.maxRecentUploads || 10;
3537
this._allowOverwrite = options.allowOverwrite || false;

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@
6060
"infile": "CHANGELOG.md"
6161
}
6262
}
63+
},
64+
"volta": {
65+
"node": "14.18.1",
66+
"yarn": "1.22.17"
6367
}
6468
}

tests/unit/index-test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ describe("redis plugin", function() {
8484
redis: {
8585
host: "somehost",
8686
port: 1234,
87-
database: 4
87+
database: 4,
88+
redisOptions: { tls: { rejectUnauthorized: false }}
8889
}
8990
},
9091
_redisLib: redisLibStub
@@ -97,7 +98,8 @@ describe("redis plugin", function() {
9798
redisLibStub.calledWith({
9899
host: "somehost",
99100
port: 1234,
100-
db: 4
101+
db: 4,
102+
tls: { rejectUnauthorized: false }
101103
})
102104
);
103105
});
@@ -125,7 +127,7 @@ describe("redis plugin", function() {
125127
plugin.readConfig("redisDeployClient");
126128

127129
assert.isTrue(
128-
redisLibStub.calledWith("redis://:password@host.amazonaws.com:6379/4")
130+
redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" })
129131
);
130132
});
131133

@@ -151,7 +153,7 @@ describe("redis plugin", function() {
151153
plugin.readConfig("redisDeployClient");
152154

153155
assert.isTrue(
154-
redisLibStub.calledWith("redis://:password@host.amazonaws.com:6379/4")
156+
redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" })
155157
);
156158
});
157159

0 commit comments

Comments
 (0)