1
- import {
2
- Action ,
3
- ActionInputs ,
4
- ActionOutputs ,
5
- Diff ,
6
- DiffAction ,
7
- Environment ,
8
- Factory ,
9
- IModelAction ,
10
- ModelType ,
11
- } from '@quadnix/octo' ;
1
+ import { Action , ActionInputs , ActionOutputs , Diff , DiffAction , Factory , IModelAction , ModelType } from '@quadnix/octo' ;
12
2
import { EcsCluster } from '../../../resources/ecs/ecs-cluster.resource.js' ;
13
3
import { AwsRegion } from '../../region/aws.region.model.js' ;
4
+ import { AwsEnvironment } from '../aws.environment.model.js' ;
14
5
15
6
@Action ( ModelType . MODEL )
16
7
export class DeleteEnvironmentModelAction implements IModelAction {
17
8
readonly ACTION_NAME : string = 'DeleteEnvironmentModelAction' ;
18
9
19
10
collectInput ( diff : Diff ) : string [ ] {
20
- const environment = diff . model as Environment ;
11
+ const environment = diff . model as AwsEnvironment ;
21
12
const environmentName = environment . environmentName ;
22
13
const region = environment . getParents ( ) [ 'region' ] [ 0 ] . to as AwsRegion ;
23
14
const clusterName = [ region . regionId , environmentName ] . join ( '-' ) ;
@@ -27,12 +18,15 @@ export class DeleteEnvironmentModelAction implements IModelAction {
27
18
28
19
filter ( diff : Diff ) : boolean {
29
20
return (
30
- diff . action === DiffAction . DELETE && diff . model . MODEL_NAME === 'environment' && diff . field === 'environmentName'
21
+ diff . action === DiffAction . DELETE &&
22
+ diff . model instanceof AwsEnvironment &&
23
+ diff . model . MODEL_NAME === 'environment' &&
24
+ diff . field === 'environmentName'
31
25
) ;
32
26
}
33
27
34
28
async handle ( diff : Diff , actionInputs : ActionInputs ) : Promise < ActionOutputs > {
35
- const environment = diff . model as Environment ;
29
+ const environment = diff . model as AwsEnvironment ;
36
30
const environmentName = environment . environmentName ;
37
31
const region = environment . getParents ( ) [ 'region' ] [ 0 ] . to as AwsRegion ;
38
32
const clusterName = [ region . regionId , environmentName ] . join ( '-' ) ;
0 commit comments