Skip to content

Commit 84b323e

Browse files
HCK-10565: validate connection (#29)
<!--do not remove this marker, its needed to replace info when ticket title is updated --> <!--jira-description-action-hidden-marker-start--> <table> <td> <a href="https://hackolade.atlassian.net/browse/HCK-10565" title="HCK-10565" target="_blank"><img alt="Sub-task" src="https://hackolade.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium" />HCK-10565</a> Add disclaimer if instance metadata won't be fetched </td></table> <br /> <!--jira-description-action-hidden-marker-end--> ## Technical details * implemented `validateConnection` method, to check whether the cluster instance meta can be fetched ## Related PR's: * hackolade/studio#3033
1 parent fcc4d96 commit 84b323e

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
"enableREQueryAndSortCriteria": true,
5353
"relationships": {
5454
"entityNameSeparator": "."
55-
},
56-
"checkAwsCredentials": true
55+
}
5756
}
5857
},
5958
"description": "Hackolade plugin for Amazon DocumentDB",

reverse_engineering/api.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,60 @@ module.exports = {
3939
}
4040
},
4141

42-
async getDbCollectionsNames(connectionInfo, logger, cb, app) {
43-
const sshService = app.require('@hackolade/ssh-service');
44-
42+
async validateConnection(connectionInfo, logger, cb) {
4543
const log = createLogger({
46-
title: 'Retrieving databases and collections information',
44+
title: 'Validate connection',
4745
hiddenKeys: connectionInfo.hiddenKeys,
4846
logger,
4947
});
5048

5149
try {
5250
logger.clear();
53-
5451
log.info(getSystemInfo(connectionInfo.appVersion));
5552
log.info(connectionInfo, 'connectionInfo');
5653

54+
const docDbClientInstance = await getDocDbClientInstance({
55+
connectionInfo: {
56+
...connectionInfo,
57+
...parseHost(connectionInfo.host, log),
58+
},
59+
logger: log,
60+
});
61+
62+
log.info('Getting cluster information');
63+
64+
try {
65+
const cluster = await docDbClientInstance.getCluster();
66+
if (!cluster) {
67+
return cb(null, "Cluster doesn't exist in the chosen region.");
68+
}
69+
} catch (err) {
70+
return cb(null, err);
71+
}
72+
73+
log.info('Cluster information retrieved successfully');
74+
75+
cb();
76+
} catch (error) {
77+
log.error(error);
78+
79+
return cb({
80+
message: error.message,
81+
stack: error.stack,
82+
});
83+
}
84+
},
85+
86+
async getDbCollectionsNames(connectionInfo, logger, cb, app) {
87+
const sshService = app.require('@hackolade/ssh-service');
88+
89+
const log = createLogger({
90+
title: 'Retrieving databases and collections information',
91+
hiddenKeys: connectionInfo.hiddenKeys,
92+
logger,
93+
});
94+
95+
try {
5796
await getDocDbClientInstance({
5897
connectionInfo: {
5998
...connectionInfo,

0 commit comments

Comments
 (0)