File tree Expand file tree Collapse file tree 6 files changed +2170
-6
lines changed Expand file tree Collapse file tree 6 files changed +2170
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @metlo/cli" ,
3
- "version" : " 0.0.2 " ,
3
+ "version" : " 0.0.3 " ,
4
4
"license" : " MIT" ,
5
5
"main" : " dist/index.js" ,
6
6
"types" : " dist/index.d.ts" ,
11
11
"build" : " tsc" ,
12
12
"watch" : " tsc -w" ,
13
13
"dev" : " nodemon -r tsconfig-paths/register src/index.ts init" ,
14
+ "cli-gcp" : " nodemon -r tsconfig-paths/register src/index.ts traffic-mirror gcp" ,
15
+ "cli-aws" : " nodemon -r tsconfig-paths/register src/index.ts traffic-mirror aws" ,
16
+ "cli-gcp-prod" : " node dist/index.js traffic-mirror gcp" ,
14
17
"format" : " prettier --write './src/**/*.{ts,tsx}'"
15
18
},
16
19
"devDependencies" : {
23
26
"dependencies" : {
24
27
"@aws-sdk/client-ec2" : " ^3.198.0" ,
25
28
"@aws-sdk/client-sts" : " ^3.198.0" ,
29
+ "@google-cloud/compute" : " ^3.5.1" ,
26
30
"@metlo/testing" : " ^0.0.3" ,
31
+ "@types/chalk" : " ^2.2.0" ,
27
32
"@types/valid-url" : " ^1.0.3" ,
33
+ "async-retry" : " ^1.3.3" ,
28
34
"axios" : " ^0.27.2" ,
29
35
"chalk" : " ^4.1.2" ,
30
36
"commander" : " ^9.4.0" ,
31
37
"dotenv" : " ^16.0.2" ,
32
38
"enquirer" : " ^2.3.6" ,
33
39
"nodemon" : " ^2.0.19" ,
40
+ "ora" : " ^5.4.1" ,
34
41
"ts-node" : " ^10.9.1" ,
35
42
"tsconfig-paths" : " ^4.1.0" ,
36
43
"tslib" : " ^2.4.0" ,
37
44
"valid-url" : " ^1.0.9"
38
45
}
39
- }
46
+ }
Original file line number Diff line number Diff line change
1
+ import { GCP_CONN } from "./gcp_apis"
2
+ import AsyncRetry from "async-retry"
3
+
4
+ export async function wait_for_global_operation ( operation_id , conn : GCP_CONN ) {
5
+ return await AsyncRetry (
6
+ async ( f , at ) => {
7
+ let resp = await conn . get_global_operation_status ( operation_id )
8
+ if ( resp [ 0 ] . status === "DONE" ) {
9
+ return resp
10
+ } else {
11
+ throw Error ( "Couldn't fetch global operation" )
12
+ }
13
+ } ,
14
+ { retries : 5 } ,
15
+ )
16
+ }
17
+
18
+ export async function wait_for_regional_operation (
19
+ operation_id ,
20
+ conn : GCP_CONN ,
21
+ ) {
22
+ return await AsyncRetry (
23
+ async ( f , at ) => {
24
+ let resp = await conn . get_regional_operation_status ( operation_id )
25
+
26
+ if ( resp [ 0 ] . status === "DONE" ) {
27
+ return resp
28
+ } else {
29
+ throw Error ( "Couldn't fetch regional operation" )
30
+ }
31
+ } ,
32
+ { retries : 5 } ,
33
+ )
34
+ }
35
+
36
+ export async function wait_for_zonal_operation ( operation_id , conn : GCP_CONN ) {
37
+ return await AsyncRetry (
38
+ async ( f , at ) => {
39
+ let resp = await conn . get_zonal_operation_status ( operation_id )
40
+ if ( resp [ 0 ] . status === "DONE" ) {
41
+ return resp
42
+ } else {
43
+ throw Error ( "Couldn't fetch regional operation" )
44
+ }
45
+ } ,
46
+ { retries : 5 } ,
47
+ )
48
+ }
49
+
50
+ export const GCP_REGIONS_SUPPORTED = [
51
+ "us-west4-c" ,
52
+ "us-west4-b" ,
53
+ "us-west4-a" ,
54
+ "us-west3-c" ,
55
+ "us-west3-b" ,
56
+ "us-west3-a" ,
57
+ "us-west2-c" ,
58
+ "us-west2-b" ,
59
+ "us-west2-a" ,
60
+ "us-west1-c" ,
61
+ "us-west1-b" ,
62
+ "us-west1-a" ,
63
+ "us-south1-c" ,
64
+ "us-south1-b" ,
65
+ "us-south1-a" ,
66
+ "us-east5-c" ,
67
+ "us-east5-b" ,
68
+ "us-east5-a" ,
69
+ "us-east4-c" ,
70
+ "us-east4-b" ,
71
+ "us-east4-a" ,
72
+ "us-east1-d" ,
73
+ "us-east1-c" ,
74
+ "us-east1-b" ,
75
+ "us-central1-f" ,
76
+ "us-central1-c" ,
77
+ "us-central1-b" ,
78
+ "us-central1-a" ,
79
+ ]
You can’t perform that action at this time.
0 commit comments