Move getLocationsSync into apps.js
This commit is contained in:
@@ -574,7 +574,7 @@ async function writeAppNginxConfig(app, fqdn, type, certificatePath) {
|
||||
async function writeAppConfigs(app) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
|
||||
const locations = appLocationsSync(app);
|
||||
const locations = apps.getLocationsSync(app);
|
||||
|
||||
for (const location of locations) {
|
||||
const certificatePath = await getCertificatePath(location.fqdn, location.domain);
|
||||
@@ -602,22 +602,11 @@ async function setUserCertificate(app, fqdn, certificate) {
|
||||
await writeAppConfigs(app);
|
||||
}
|
||||
|
||||
function appLocationsSync(app) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
|
||||
const locations = [{ domain: app.domain, fqdn: app.fqdn, certificate: app.certificate, type: apps.LOCATION_TYPE_PRIMARY }]
|
||||
.concat(app.secondaryDomains.map(sd => { return { domain: sd.domain, certificate: sd.certificate, fqdn: sd.fqdn, type: apps.LOCATION_TYPE_SECONDARY }; }))
|
||||
.concat(app.redirectDomains.map(rd => { return { domain: rd.domain, certificate: rd.certificate, fqdn: rd.fqdn, type: apps.LOCATION_TYPE_REDIRECT }; }))
|
||||
.concat(app.aliasDomains.map(ad => { return { domain: ad.domain, certificate: ad.certificate, fqdn: ad.fqdn, type: apps.LOCATION_TYPE_ALIAS }; }));
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
async function configureApp(app, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const locations = await appLocationsSync(app);
|
||||
const locations = await apps.getLocationsSync(app);
|
||||
const domainObjectMap = await domains.getDomainObjectMap();
|
||||
|
||||
for (const location of locations) {
|
||||
@@ -658,7 +647,7 @@ async function renewCerts(auditSource, progressCallback) {
|
||||
|
||||
for (const app of allApps) {
|
||||
if (app.runState === apps.RSTATE_STOPPED) continue; // do not renew certs of stopped apps
|
||||
locations = locations.concat(appLocationsSync(app));
|
||||
locations = locations.concat(apps.apps.getLocationsSync(app));
|
||||
}
|
||||
|
||||
let percent = 1, renewedCertificateNames = [];
|
||||
@@ -706,7 +695,7 @@ async function cleanupCerts(auditSource, progressCallback) {
|
||||
|
||||
for (const app of await apps.list()) {
|
||||
if (app.runState === apps.RSTATE_STOPPED) continue; // not in use
|
||||
locations = locations.concat(appLocationsSync(app));
|
||||
locations = locations.concat(apps.apps.getLocationsSync(app));
|
||||
}
|
||||
|
||||
const certsInUse = [ 'default.cert' ];
|
||||
|
||||
Reference in New Issue
Block a user