import { OrgFormationError } from '../org-formation-error' ; import { ICfnTask } from './cfn-task-provider' ; import { GenericTaskRunner , ITaskRunnerDelegates } from '~core/generic-task-runner' ; export class CfnTaskRunner { public static async RunTasks ( tasks , stackName , logVerbose , maxConcurrentTasks , failedTasksTolerance ) { if ( maxConcurrentTasks === undefined ) { throw new OrgFormationError ( 'maxConcurrentTasks must not be undefined' ) ; } if ( failedTasksTolerance === undefined ) { throw new OrgFormationError ( 'failedTasksTolerance must not be undefined' ) ; } const delegate = { getName : task => `Stack ${ task . stackName } in account ${ task . accountId } (${ task . region })` , getVerb : task => `${ task . action === 'Delete' ? 'delete' : 'update' }` , maxConcurrentTasks , failedTasksTolerance , logVerbose , } ; await GenericTaskRunner . RunTasks < ICfnTask > ( tasks , delegate ) ; } public static async ValidateTemplates ( tasks , logVerbose , maxConcurrentTasks , failedTasksTolerance ) { const delegate = { getName : task => `Stack ${ task . stackName } in account ${ task . accountId } (${ task . region })` , getVerb : ( ) => 'validate' , maxConcurrentTasks , failedTasksTolerance , logVerbose , } ; await GenericTaskRunner . RunTasks < ICfnTask > ( tasks , delegate ) ; } }