Skip to content

Commit 426a7e1

Browse files
committed
extract driver version to constant
1 parent 77f910e commit 426a7e1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/cubejs-databricks-jdbc-driver/src/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33

4-
import { downloadJDBCDriver } from './installer';
4+
import { downloadJDBCDriver, OSS_DRIVER_VERSION } from './installer';
55

66
async function fileExistsOr(
77
fsPath: string,
@@ -15,16 +15,16 @@ async function fileExistsOr(
1515

1616
export async function resolveJDBCDriver(): Promise<string> {
1717
return fileExistsOr(
18-
path.join(process.cwd(), 'databricks-jdbc-1.0.2-oss.jar'),
18+
path.join(process.cwd(), `databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`),
1919
async () => fileExistsOr(
20-
path.join(__dirname, '..', 'download', 'databricks-jdbc-1.0.2-oss.jar'),
20+
path.join(__dirname, '..', 'download', `databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`),
2121
async () => {
2222
const pathOrNull = await downloadJDBCDriver();
2323
if (pathOrNull) {
2424
return pathOrNull;
2525
}
2626
throw new Error(
27-
'Please download and place databricks-jdbc-1.0.2-oss.jar inside your ' +
27+
`Please download and place databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar inside your ` +
2828
'project directory'
2929
);
3030
}

packages/cubejs-databricks-jdbc-driver/src/installer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import path from 'path';
22
import { downloadAndExtractFile, getEnv } from '@cubejs-backend/shared';
33

4+
export const OSS_DRIVER_VERSION = '1.0.2';
5+
46
function acceptedByEnv() {
57
const acceptStatus = getEnv('databrickAcceptPolicy');
68
if (acceptStatus) {
@@ -26,21 +28,21 @@ export async function downloadJDBCDriver(): Promise<string | null> {
2628
const driverAccepted = acceptedByEnv();
2729

2830
if (driverAccepted) {
29-
console.log('Downloading databricks-jdbc-1.0.2-oss.jar');
31+
console.log(`Downloading databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`);
3032

3133
await downloadAndExtractFile(
32-
'https://repo1.maven.org/maven2/com/databricks/databricks-jdbc/1.0.2-oss/databricks-jdbc-1.0.2-oss.jar',
34+
`https://repo1.maven.org/maven2/com/databricks/databricks-jdbc/${OSS_DRIVER_VERSION}-oss/databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`,
3335
{
3436
showProgress: true,
3537
cwd: path.resolve(path.join(__dirname, '..', 'download')),
3638
noExtract: true,
37-
dstFileName: 'databricks-jdbc-1.0.2-oss.jar',
39+
dstFileName: `databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`,
3840
}
3941
);
4042

41-
console.log('Release notes: https://mvnrepository.com/artifact/com.databricks/databricks-jdbc/1.0.2-oss');
43+
console.log(`Release notes: https://mvnrepository.com/artifact/com.databricks/databricks-jdbc/${OSS_DRIVER_VERSION}-oss`);
4244

43-
return path.resolve(path.join(__dirname, '..', 'download', 'databricks-jdbc-1.0.2-oss.jar'));
45+
return path.resolve(path.join(__dirname, '..', 'download', `databricks-jdbc-${OSS_DRIVER_VERSION}-oss.jar`));
4446
}
4547

4648
return null;

0 commit comments

Comments
 (0)