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 fileNames = require("../fileNames");
|
||||
|
||||
module.exports.set = (opts, options) => {
|
||||
console.log("certificates.set for ", opts.subject);
|
||||
|
||||
let objects = [
|
||||
setObjects = (opts, options) => {
|
||||
return [
|
||||
{
|
||||
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.cert)
|
||||
, Body: opts.pems.cert
|
||||
|
@ -23,9 +21,11 @@ module.exports.set = (opts, options) => {
|
|||
Key: pathHelper.certificatesPath(options, opts.subject, fileNames.bundle)
|
||||
, 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++) {
|
||||
const obj = objects[i];
|
||||
|
@ -38,6 +38,15 @@ module.exports.set = (opts, options) => {
|
|||
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 null;
|
||||
}).catch((err) => {
|
||||
|
|
Loading…
Reference in New Issue