diff --git a/packages/dashmate/src/commands/ssl/cleanup.js b/packages/dashmate/src/commands/ssl/cleanup.js index b7f108aa08..eaef76cf49 100644 --- a/packages/dashmate/src/commands/ssl/cleanup.js +++ b/packages/dashmate/src/commands/ssl/cleanup.js @@ -34,7 +34,7 @@ Cancel all drafted or pending validation certificates on ZeroSSL [ { title: 'Cleanup ZeroSSL certificate', - task: async () => cleanupZeroSSLCertificatesTask(config), + task: () => cleanupZeroSSLCertificatesTask(config), }, ], { diff --git a/packages/dashmate/src/commands/ssl/obtain.js b/packages/dashmate/src/commands/ssl/obtain.js index cc39f1a47a..4dbfcd3561 100644 --- a/packages/dashmate/src/commands/ssl/obtain.js +++ b/packages/dashmate/src/commands/ssl/obtain.js @@ -45,7 +45,7 @@ Certificate will be renewed if it is about to expire (see 'expiration-days' flag [ { title: 'Obtain ZeroSSL certificate', - task: async () => obtainZeroSSLCertificateTask(config), + task: () => obtainZeroSSLCertificateTask(config), }, ], { diff --git a/packages/dashmate/src/helper/scheduleRenewZeroSslCertificateFactory.js b/packages/dashmate/src/helper/scheduleRenewZeroSslCertificateFactory.js index c403c2bef3..8d741511dd 100644 --- a/packages/dashmate/src/helper/scheduleRenewZeroSslCertificateFactory.js +++ b/packages/dashmate/src/helper/scheduleRenewZeroSslCertificateFactory.js @@ -51,7 +51,7 @@ export default function scheduleRenewZeroSslCertificateFactory( } const job = new CronJob(expiresAt, async () => { - const tasks = await obtainZeroSSLCertificateTask(config); + const tasks = obtainZeroSSLCertificateTask(config); await tasks.run({ expirationDays: Certificate.EXPIRATION_LIMIT_DAYS, diff --git a/packages/dashmate/src/listr/tasks/ssl/zerossl/cleanupZeroSSLCertificatesTaskFactory.js b/packages/dashmate/src/listr/tasks/ssl/zerossl/cleanupZeroSSLCertificatesTaskFactory.js index c0d4979cde..f38d62562d 100644 --- a/packages/dashmate/src/listr/tasks/ssl/zerossl/cleanupZeroSSLCertificatesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/ssl/zerossl/cleanupZeroSSLCertificatesTaskFactory.js @@ -13,18 +13,18 @@ export default function cleanupZeroSSLCertificatesTaskFactory( cancelCertificate, ) { /** - * @typedef {obtainZeroSSLCertificateTask} + * @typedef {cleanupZeroSSLCertificatesTask} * @param {Config} config - * @return {Promise} + * @return {Listr} */ - async function cleanupZeroSSLCertificatesTask(config) { + function cleanupZeroSSLCertificatesTask(config) { + const apiKey = config.get('platform.gateway.ssl.providerConfigs.zerossl.apiKey', true); + return new Listr([ { title: 'Collect drafted and pending validation certificates', // Skips the check if force flag is set task: async (ctx, task) => { - ctx.apiKey = config.get('platform.gateway.ssl.providerConfigs.zerossl.apiKey', true); - ctx.certificates = []; let certificatesPerRequest = []; @@ -33,7 +33,7 @@ export default function cleanupZeroSSLCertificatesTaskFactory( // Fetch all certificates in draft or pending validation status // with pagination do { - certificatesPerRequest = await listCertificates(ctx.apiKey, ['draft', 'pending_validation'], page); + certificatesPerRequest = await listCertificates(apiKey, ['draft', 'pending_validation'], page); ctx.certificates = ctx.certificates.concat(certificatesPerRequest); @@ -57,7 +57,7 @@ export default function cleanupZeroSSLCertificatesTaskFactory( return new Observable(async (observer) => { for (const certificate of ctx.certificates) { try { - await cancelCertificate(ctx.apiKey, certificate.id); + await cancelCertificate(apiKey, certificate.id); ctx.canceled += 1; } catch (e) { diff --git a/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js b/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js index ca679233d0..95eb4b5e13 100644 --- a/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/ssl/zerossl/obtainZeroSSLCertificateTaskFactory.js @@ -36,9 +36,9 @@ export default function obtainZeroSSLCertificateTaskFactory( /** * @typedef {obtainZeroSSLCertificateTask} * @param {Config} config - * @return {Promise} + * @return {Listr} */ - async function obtainZeroSSLCertificateTask(config) { + function obtainZeroSSLCertificateTask(config) { return new Listr([ { title: 'Check if certificate already exists and not expiring soon',