mirror of
https://github.com/cderche/greenlock-storage-s3
synced 2025-02-22 06:08:04 +00:00
Refactor lib/certificates/set.js
This commit is contained in:
parent
f79677846c
commit
caf56d2e4e
@ -3,10 +3,8 @@ const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
|
|||||||
const pathHelper = require("../pathHelper");
|
const pathHelper = require("../pathHelper");
|
||||||
const fileNames = require("../fileNames");
|
const fileNames = require("../fileNames");
|
||||||
|
|
||||||
module.exports.set = (opts, options) => {
|
setObjects = (opts, options) => {
|
||||||
console.log("certificates.set for ", opts.subject);
|
return [
|
||||||
|
|
||||||
let objects = [
|
|
||||||
{
|
{
|
||||||
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.cert)
|
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.cert)
|
||||||
, Body: opts.pems.cert
|
, Body: opts.pems.cert
|
||||||
@ -23,9 +21,11 @@ module.exports.set = (opts, options) => {
|
|||||||
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.bundle)
|
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.bundle)
|
||||||
, Body: [opts.pems.privkey, opts.pems.cert, opts.pems.chain].join("\n") // for HAProxy
|
, Body: [opts.pems.privkey, opts.pems.cert, opts.pems.chain].join("\n") // for HAProxy
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
};
|
||||||
|
|
||||||
var promises = [];
|
setPromises = (objects, options) => {
|
||||||
|
let promises = [];
|
||||||
|
|
||||||
for (let i = 0; i < objects.length; i++) {
|
for (let i = 0; i < objects.length; i++) {
|
||||||
const obj = objects[i];
|
const obj = objects[i];
|
||||||
@ -38,6 +38,15 @@ module.exports.set = (opts, options) => {
|
|||||||
promises.push(promise);
|
promises.push(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return promises;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.set = (opts, options) => {
|
||||||
|
console.log("certificates.set for ", opts.subject);
|
||||||
|
|
||||||
|
const objects = setObjects(opts, options);
|
||||||
|
const promises = setPromises(objects, options);
|
||||||
|
|
||||||
return Promise.all(promises).then((values) => {
|
return Promise.all(promises).then((values) => {
|
||||||
return null;
|
return null;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user