fixed status for newly created stacks

This commit is contained in:
Arwid Thornström
2022-01-25 11:40:16 +01:00
parent c00be4305e
commit 13af2cebba
@@ -22,6 +22,7 @@ module.exports = {
const stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`))); const stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`)));
const teststacks: Stack[] = await Promise.all(stacks.StackSummaries.map(async (item) => { 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)) { if (item.StackName.indexOf('photowall-test-') > -1 && ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_IN_PROGRESS', 'UPDATE_FAILED', 'CREATE_FAILED', 'CREATE_IN_PROGRESS'].includes(item.StackStatus)) {
try {
const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`))); const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`)));
const branch = pipeline.pipeline.stages.filter(stage => { const branch = pipeline.pipeline.stages.filter(stage => {
return stage.name === 'Source'; return stage.name === 'Source';
@@ -34,6 +35,16 @@ module.exports = {
branch: branch, branch: branch,
updated: lastUpdated, updated: lastUpdated,
} }
} catch (e) {
return {
name: item.StackName,
status: 'NO_STATUS',
drift_status: '',
branch: '',
updated: '',
}
}
} }
return Promise.resolve(null); return Promise.resolve(null);
})); }));
@@ -42,6 +53,8 @@ module.exports = {
const status = (status: string) => { const status = (status: string) => {
switch(status) { switch(status) {
case 'NO_STATUS':
return ` (❓) `;
case 'UPDATE_FAILED': case 'UPDATE_FAILED':
case 'CREATE_FAILED': case 'CREATE_FAILED':
return ` (💔) `; return ` (💔) `;