File tree 2 files changed +60
-7
lines changed
2 files changed +60
-7
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,38 @@ export class InspectClusterTool extends AtlasToolBase {
31
31
throw new Error ( "Cluster not found" ) ;
32
32
}
33
33
34
+ const regionConfigs = ( cluster . replicationSpecs || [ ] )
35
+ . map (
36
+ ( replicationSpec ) =>
37
+ ( replicationSpec . regionConfigs || [ ] ) as {
38
+ providerName : string ;
39
+ electableSpecs ?: {
40
+ instanceSize : string ;
41
+ } ;
42
+ readOnlySpecs ?: {
43
+ instanceSize : string ;
44
+ } ;
45
+ } [ ]
46
+ )
47
+ . flat ( )
48
+ . map ( ( regionConfig ) => {
49
+ return {
50
+ providerName : regionConfig . providerName ,
51
+ instanceSize : regionConfig . electableSpecs ?. instanceSize || regionConfig . readOnlySpecs ?. instanceSize ,
52
+ } ;
53
+ } ) ;
54
+
55
+ const instanceSize = ( regionConfigs . length <= 0 ? undefined : regionConfigs [ 0 ] . instanceSize ) || "UNKNOWN" ;
56
+
57
+ const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED" ;
58
+
34
59
return {
35
60
content : [
36
61
{
37
62
type : "text" ,
38
- text : `Cluster Name | State | MongoDB Version | Connection String
39
- ----------------|----------------|----------------|----------------|----------------
40
- ${ cluster . name } | ${ cluster . stateName } | ${ cluster . mongoDBVersion || "N/A" } | ${ cluster . connectionStrings ?. standard || "N/A" } `,
63
+ text : `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
64
+ ----------------|----------------|----------------|----------------|----------------|----------------
65
+ ${ cluster . name } | ${ clusterInstanceType } | ${ clusterInstanceType == "DEDICATED" ? instanceSize : "N/A" } | ${ cluster . stateName } | ${ cluster . mongoDBVersion || "N/A" } | ${ cluster . connectionStrings ?. standardSrv || cluster . connectionStrings ?. standard || "N/A" } `,
41
66
} ,
42
67
] ,
43
68
} ;
Original file line number Diff line number Diff line change @@ -79,9 +79,37 @@ ${rows}`,
79
79
}
80
80
const rows = clusters . results
81
81
. map ( ( cluster ) => {
82
- const connectionString = cluster . connectionStrings ?. standard || "N/A" ;
82
+ const connectionString =
83
+ cluster . connectionStrings ?. standardSrv || cluster . connectionStrings ?. standard || "N/A" ;
83
84
const mongoDBVersion = cluster . mongoDBVersion || "N/A" ;
84
- return `${ cluster . name } | ${ cluster . stateName } | ${ mongoDBVersion } | ${ connectionString } ` ;
85
+ const regionConfigs = ( cluster . replicationSpecs || [ ] )
86
+ . map (
87
+ ( replicationSpec ) =>
88
+ ( replicationSpec . regionConfigs || [ ] ) as {
89
+ providerName : string ;
90
+ electableSpecs ?: {
91
+ instanceSize : string ;
92
+ } ;
93
+ readOnlySpecs ?: {
94
+ instanceSize : string ;
95
+ } ;
96
+ } [ ]
97
+ )
98
+ . flat ( )
99
+ . map ( ( regionConfig ) => {
100
+ return {
101
+ providerName : regionConfig . providerName ,
102
+ instanceSize :
103
+ regionConfig . electableSpecs ?. instanceSize || regionConfig . readOnlySpecs ?. instanceSize ,
104
+ } ;
105
+ } ) ;
106
+
107
+ const instanceSize =
108
+ ( regionConfigs . length <= 0 ? undefined : regionConfigs [ 0 ] . instanceSize ) || "UNKNOWN" ;
109
+
110
+ const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED" ;
111
+
112
+ return `${ cluster . name } | ${ clusterInstanceType } | ${ clusterInstanceType == "DEDICATED" ? instanceSize : "N/A" } | ${ cluster . stateName } | ${ mongoDBVersion } | ${ connectionString } ` ;
85
113
} )
86
114
. join ( "\n" ) ;
87
115
return {
@@ -92,8 +120,8 @@ ${rows}`,
92
120
} ,
93
121
{
94
122
type : "text" ,
95
- text : `Cluster Name | State | MongoDB Version | Connection String
96
- ----------------|----------------|----------------|----------------|----------------
123
+ text : `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
124
+ ----------------|----------------|----------------|----------------|----------------|----------------
97
125
${ rows } `,
98
126
} ,
99
127
] ,
You can’t perform that action at this time.
0 commit comments