Skip to content

Commit cf6bcba

Browse files
committed
simplification of env vars and defaults for crons
1 parent 28dd638 commit cf6bcba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RUN npm install --production
66

77
COPY action.js /
88

9-
CMD echo "$S3_OBJ_PRUNE_CRON_MINUTE $S3_OBJ_PRUNE_CRON_HOUR * * * node /action.js" > /var/spool/cron/crontabs/root && crond -d 8 -f
9+
CMD echo "${CRON_MINUTE:-$(shuf -i 0-59 -n1)} ${CRON_HOUR:-*} * * * node /action.js" > /var/spool/cron/crontabs/root && crond -d 8 -f

action.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ function deleteKeys(s3, keySet) {
4545
const S3 = require('aws-sdk/clients/s3');
4646

4747
const s3 = new S3({
48-
region: process.env.S3_OBJ_PRUNE_AWS_REGION === 's3'
48+
region: process.env.AWS_REGION === 's3'
4949
? 'us-east-1'
50-
: process.env.S3_OBJ_PRUNE_AWS_REGION
50+
: process.env.AWS_REGION
5151
,
5252
credentials: {
53-
accessKeyId: process.env.S3_OBJ_PRUNE_AWS_ACCESS_KEY_ID,
54-
secretAccessKey: process.env.S3_OBJ_PRUNE_AWS_SECRET_ACCESS_KEY,
53+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
54+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
5555
},
5656
params: {
57-
Bucket: process.env.S3_OBJ_PRUNE_AWS_BUCKET,
57+
Bucket: process.env.AWS_BUCKET,
5858
},
5959
});
6060

61-
const prefix = process.env.S3_OBJ_PRUNE_AWS_OBJECT_PREFIX;
62-
const maxKeys = Number.parseInt(process.env.S3_OBJ_PRUNE_MAX_OBJECTS, 10);
61+
const prefix = process.env.PRUNE_PREFIX;
62+
const maxKeys = Number.parseInt(process.env.MAX_OBJECTS, 10);
6363

6464
function objectKeyToTimestamp(key) {
6565
return (new Date(key.replace(prefix, '').replace('.dump', ''))).valueOf();

0 commit comments

Comments
 (0)