From 13af2cebba42d4fc50ec85fc2c64056c39dd02c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arwid=20Thornstro=CC=88m?= Date: Tue, 25 Jan 2022 11:40:16 +0100 Subject: [PATCH] fixed status for newly created stacks --- .../deployment/testservers/status/status.ts | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/commands/deployment/testservers/status/status.ts b/src/commands/deployment/testservers/status/status.ts index 0899305..1c9a7b5 100644 --- a/src/commands/deployment/testservers/status/status.ts +++ b/src/commands/deployment/testservers/status/status.ts @@ -22,18 +22,29 @@ module.exports = { const stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`))); const teststacks: Stack[] = await Promise.all(stacks.StackSummaries.map(async (item) => { if (item.StackName.indexOf('photowall-test-') > -1 && ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_IN_PROGRESS', 'UPDATE_FAILED', 'CREATE_FAILED', 'CREATE_IN_PROGRESS'].includes(item.StackStatus)) { - const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`))); - const branch = pipeline.pipeline.stages.filter(stage => { - return stage.name === 'Source'; - })[0].actions[0].configuration.Branch; - const lastUpdated = pipeline.metadata.updated; - return { - name: item.StackName, - status: item.StackStatus, - drift_status: item.DriftInformation.StackDriftStatus, - branch: branch, - updated: lastUpdated, + try { + const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`))); + const branch = pipeline.pipeline.stages.filter(stage => { + return stage.name === 'Source'; + })[0].actions[0].configuration.Branch; + const lastUpdated = pipeline.metadata.updated; + return { + name: item.StackName, + status: item.StackStatus, + drift_status: item.DriftInformation.StackDriftStatus, + branch: branch, + updated: lastUpdated, + } + } catch (e) { + return { + name: item.StackName, + status: 'NO_STATUS', + drift_status: '', + branch: '', + updated: '', + } } + } return Promise.resolve(null); })); @@ -42,6 +53,8 @@ module.exports = { const status = (status: string) => { switch(status) { + case 'NO_STATUS': + return ` (❓) `; case 'UPDATE_FAILED': case 'CREATE_FAILED': return ` (💔) `;