MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / parseZipFile

Function parseZipFile

lib/datastax/cloud/index.js:111–137  ·  view source on GitHub ↗

* @param {CloudOptions} cloudOptions * @returns {Promise }

(cloudOptions)

Source from the content-addressed store, hash-verified

109 * @returns {Promise<void>}
110 */
111async function parseZipFile(cloudOptions) {
112 if (cloudOptions.serviceUrl) {
113 // Service url already was provided
114 return;
115 }
116
117 if (!cloudOptions.secureConnectBundle) {
118 throw new TypeError('secureConnectBundle must be provided');
119 }
120
121 const data = await readFile(cloudOptions.secureConnectBundle);
122 const zip = new AdmZip(data);
123 const zipEntries = new Map(zip.getEntries().map(e => [e.entryName, e.getData()]));
124
125 if (!zipEntries.get('config.json')) {
126 throw new TypeError('Config file must be contained in secure bundle');
127 }
128
129 const config = JSON.parse(zipEntries.get('config.json').toString('utf8'));
130 if (!config['host'] || !config['port']) {
131 throw new TypeError('Config file must include host and port information');
132 }
133
134 cloudOptions.serviceUrl = `${config['host']}:${config['port']}/metadata`;
135 cloudOptions.setSslOptions(zipEntries);
136 cloudOptions.setAuthProvider(config.username, config.password);
137}
138
139/**
140 * Gets the information retrieved from the metadata service.

Callers 1

initFunction · 0.85

Calls 5

setSslOptionsMethod · 0.80
setAuthProviderMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected