1
- import { ActionContext } from '../types' ;
1
+ import { ActionContext , ServerlessIac } from '../types' ;
2
2
import path from 'node:path' ;
3
3
import { ProviderEnum } from './providerEnum' ;
4
4
@@ -12,28 +12,32 @@ export const getIacLocation = (location?: string): string => {
12
12
path . resolve ( projectRoot , 'serverless-insight.yml' ) ;
13
13
} ;
14
14
15
- export const constructActionContext = ( config ?: {
15
+ export const constructActionContext = ( config : {
16
+ stage ?: string ;
17
+ stackName ?: string ;
16
18
region ?: string ;
17
19
provider ?: string ;
18
- account ?: string ;
19
20
accessKeyId ?: string ;
20
21
accessKeySecret ?: string ;
21
22
securityToken ?: string ;
22
23
location ?: string ;
23
24
parameters ?: { [ key : string ] : string } ;
24
- stage ?: string ;
25
- stackName ?: string ;
25
+ iacProvider ?: ServerlessIac [ 'provider' ] ;
26
26
} ) : ActionContext => {
27
27
return {
28
- stage : config ?. stage ?? 'default' ,
29
- stackName : config ?. stackName ?? '' ,
28
+ stage : config . stage ?? 'default' ,
29
+ stackName : config . stackName ?? '' ,
30
+ provider : ( config . provider ?? config . iacProvider ?. name ?? ProviderEnum . ALIYUN ) as ProviderEnum ,
30
31
region :
31
- config ?. region ?? process . env . ROS_REGION_ID ?? process . env . ALIYUN_REGION ?? 'cn-hangzhou' ,
32
- accessKeyId : config ?. accessKeyId ?? ( process . env . ALIYUN_ACCESS_KEY_ID as string ) ,
33
- accessKeySecret : config ?. accessKeySecret ?? ( process . env . ALIYUN_ACCESS_KEY_SECRET as string ) ,
34
- securityToken : config ?. securityToken ?? process . env . ALIYUN_SECURITY_TOKEN ,
35
- iacLocation : getIacLocation ( config ?. location ) ,
36
- parameters : Object . entries ( config ?. parameters ?? { } ) . map ( ( [ key , value ] ) => ( { key, value } ) ) ,
37
- provider : config ?. provider as ProviderEnum ,
32
+ config . region ??
33
+ config . iacProvider ?. region ??
34
+ process . env . ROS_REGION_ID ??
35
+ process . env . ALIYUN_REGION ??
36
+ 'cn-hangzhou' ,
37
+ accessKeyId : config . accessKeyId ?? ( process . env . ALIYUN_ACCESS_KEY_ID as string ) ,
38
+ accessKeySecret : config . accessKeySecret ?? ( process . env . ALIYUN_ACCESS_KEY_SECRET as string ) ,
39
+ securityToken : config . securityToken ?? process . env . ALIYUN_SECURITY_TOKEN ,
40
+ iacLocation : getIacLocation ( config . location ) ,
41
+ parameters : Object . entries ( config . parameters ?? { } ) . map ( ( [ key , value ] ) => ( { key, value } ) ) ,
38
42
} ;
39
43
} ;
0 commit comments