Skip to content

Commit 52bdc86

Browse files
committed
Add password option to Redis oneclick-app
1 parent c6c5112 commit 52bdc86

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

app-frontend/src/oneclick-apps/redis.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
var getErrorMessageIfExists = apiManager.getErrorMessageIfExists;
1111

12+
var REDIS_PASSWORD = 'REDIS_PASSWORD';
1213
var CONTAINER_NAME = 'CONTAINER_NAME';
1314

1415
var step1next = {};
@@ -19,6 +20,11 @@
1920
id: CONTAINER_NAME,
2021
type: 'text'
2122
});
23+
step1next.data.push({
24+
label: 'OPTIONAL: Redis password',
25+
id: REDIS_PASSWORD,
26+
type: 'text'
27+
});
2228

2329
step1next.process = function (data, step1Callback) {
2430

@@ -29,6 +35,9 @@
2935
function endWithSuccess() {
3036

3137
var nodejsCode = 'const client = redis.createClient(6379, "srv-captain--' + data[CONTAINER_NAME] + ')';
38+
if (data[REDIS_PASSWORD]) {
39+
nodejsCode = 'const client = redis.createClient(6379, "srv-captain--' + data[CONTAINER_NAME] + ', {password: "'+data[REDIS_PASSWORD]+'"})';
40+
}
3241

3342
step1Callback({
3443
message: {
@@ -89,7 +98,7 @@
8998

9099
var appDefinition = {
91100
instanceCount: 1,
92-
envVars: [],
101+
envVars: envVars,
93102
notExposeAsWebApp: true,
94103
volumes: volumes
95104
};
@@ -113,6 +122,11 @@
113122
]
114123
}
115124

125+
if (data[REDIS_PASSWORD]) {
126+
captainDefinitionContent.dockerfileLines.push('ENV REDIS_PASSWORD ' + data[REDIS_PASSWORD])
127+
captainDefinitionContent.dockerfileLines.push('CMD exec redis-server --requirepass \"$REDIS_PASSWORD\"')
128+
}
129+
116130
apiManager.uploadCaptainDefinitionContent(appName,
117131
JSON.stringify(captainDefinitionContent), function (data) {
118132
if (getErrorMessageIfExists(data)) {

0 commit comments

Comments
 (0)