fix create/delete when there exists broken stacks

This commit is contained in:
Anders Gustafsson
2023-04-12 15:44:51 +02:00
parent 87bbc14dad
commit feb8342bc1
5 changed files with 109 additions and 225 deletions
@@ -3,6 +3,7 @@ const chalk = require('chalk');
const { AutoComplete, Input, Confirm } = require('enquirer');
import { Octokit } from '@octokit/core';
import { exit } from 'process';
import { getTestStacksInfo } from '../../../../common/testservers';
import {
defaultMenuSettings,
getCurrentBranch,
@@ -99,47 +100,8 @@ 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
};
}
return Promise.resolve(null);
})
);
const curratedStacks: Stack[] = teststacks.filter(Boolean);
const options = curratedStacks.map(item => {
const testStacks = await getTestStacksInfo(toolbox);
const options = testStacks.map(item => {
return item.name;
});