Fix status for failed stacks

This commit is contained in:
Anders Gustafsson
2023-04-12 10:29:51 +02:00
parent ce650d3516
commit 87bbc14dad
@@ -9,6 +9,7 @@ type Stack = {
drift_status: string; drift_status: string;
branch: string; branch: string;
updated: string; updated: string;
created: string;
}; };
module.exports = { module.exports = {
@@ -32,7 +33,8 @@ module.exports = {
'UPDATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS',
'UPDATE_FAILED', 'UPDATE_FAILED',
'CREATE_FAILED', 'CREATE_FAILED',
'CREATE_IN_PROGRESS' 'CREATE_IN_PROGRESS',
'ROLLBACK_COMPLETE',
].includes(item.StackStatus) ].includes(item.StackStatus)
) { ) {
try { try {
@@ -55,15 +57,17 @@ module.exports = {
status: item.StackStatus, status: item.StackStatus,
drift_status: item.DriftInformation.StackDriftStatus, drift_status: item.DriftInformation.StackDriftStatus,
branch: branch, branch: branch,
updated: lastUpdated updated: lastUpdated,
created: item.CreationTime,
}; };
} catch (e) { } catch (e) {
return { return {
name: item.StackName, name: item.StackName,
status: 'NO_STATUS', status: item.StackStatus,
drift_status: '', drift_status: '',
branch: '', branch: '',
updated: '' updated: '',
created: item.CreationTime,
}; };
} }
} }
@@ -75,17 +79,18 @@ module.exports = {
const status = (status: string) => { const status = (status: string) => {
switch (status) { switch (status) {
case 'NO_STATUS':
return `(${chalk.red.bold('?')})`;
case 'UPDATE_FAILED': case 'UPDATE_FAILED':
case 'CREATE_FAILED': case 'CREATE_FAILED':
return `(${chalk.red.bold('FAILED')})`; case 'ROLLBACK_COMPLETE':
return `(${chalk.red('FAILED')})`;
case 'UPDATE_IN_PROGRESS': case 'UPDATE_IN_PROGRESS':
case 'CREATE_IN_PROGRESS': case 'CREATE_IN_PROGRESS':
return `(${chalk.yellow.bold('IN PROGRESS')})`; return `(${chalk.yellow('IN PROGRESS')})`;
case 'UPDATE_COMPLETE': case 'UPDATE_COMPLETE':
case 'CREATE_COMPLETE': case 'CREATE_COMPLETE':
return `(${chalk.greenBright('OK')})`; return `(${chalk.greenBright('OK')})`;
default:
return `(${chalk.red.bold('?')})`;
} }
}; };
@@ -148,7 +153,7 @@ module.exports = {
status(stack.status), status(stack.status),
stack.name, stack.name,
ellipsis(stack.branch, 24), ellipsis(stack.branch, 24),
timeSince(t.getTime()), !isNaN(t.getTime()) ? timeSince(t.getTime()) : timeSince((new Date(stack.created)).getTime()),
stackUrl(stack.name) stackUrl(stack.name)
]); ]);
} }