Skip to content

Commit ea7b079

Browse files
Update CLI to v0.214.1 (#1099)
## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? -->
1 parent c28620a commit ea7b079

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

packages/databricks-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@
765765
"useYarn": false
766766
},
767767
"cli": {
768-
"version": "0.212.3"
768+
"version": "0.214.1"
769769
},
770770
"scripts": {
771771
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && yarn run generate-telemetry",

packages/databricks-vscode/src/cli/CliWrapper.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import {promisify} from "node:util";
1010
import {execFile as execFileCb} from "node:child_process";
1111
import {withFile} from "tmp-promise";
1212
import {writeFile, readFile} from "node:fs/promises";
13-
import {when, spy, reset} from "ts-mockito";
13+
import {when, spy, reset, instance, mock} from "ts-mockito";
1414
import {CliWrapper} from "./CliWrapper";
1515
import path from "node:path";
1616
import os from "node:os";
1717
import crypto from "node:crypto";
1818
import {Context} from "@databricks/databricks-sdk/dist/context";
1919
import {logging} from "@databricks/databricks-sdk";
20+
import {LoggerManager} from "../logger";
2021

2122
const execFile = promisify(execFileCb);
2223
const cliPath = path.join(__dirname, "../../bin/databricks");
@@ -35,6 +36,7 @@ function createCliWrapper(logFilePath?: string) {
3536
return path.join(__dirname, "../..", relativePath);
3637
},
3738
} as any,
39+
instance(mock(LoggerManager)),
3840
logFilePath
3941
);
4042
}
@@ -126,14 +128,12 @@ describe(__filename, () => {
126128
assert.equal(profiles.length, 2);
127129
assert.equal(profiles[0].name, "DEFAULT");
128130
assert.equal(profiles[0].host, "https://cloud.databricks.com/");
129-
assert.equal(profiles[0].authType, "pat");
130131

131132
assert.equal(profiles[1].name, "STAGING");
132133
assert.equal(
133134
profiles[1].host,
134135
"https://staging.cloud.databricks.com/"
135136
);
136-
assert.equal(profiles[1].authType, "pat");
137137
});
138138
});
139139

@@ -164,7 +164,6 @@ nothing = true
164164

165165
assert.equal(profiles[0].name, "correct");
166166
assert.equal(profiles[0].host, "https://cloud.databricks.com/");
167-
assert.equal(profiles[0].authType, "pat");
168167

169168
assert.equal(profiles[1].name, "no-token");
170169
assert.equal(profiles[1].host, "https://cloud.databricks.com/");

packages/databricks-vscode/src/cli/CliWrapper.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {SyncDestinationMapper} from "../sync/SyncDestination";
99
import {workspaceConfigs} from "../vscode-objs/WorkspaceConfigs";
1010
import {promisify} from "node:util";
1111
import {logging} from "@databricks/databricks-sdk";
12-
import {Loggers} from "../logger";
12+
import {LoggerManager, Loggers} from "../logger";
1313
import {Context, context} from "@databricks/databricks-sdk/dist/context";
1414
import {Cloud} from "../utils/constants";
1515
import {EnvVarGenerators, FileUtils, UrlUtils} from "../utils";
@@ -89,6 +89,7 @@ export class CliWrapper {
8989
private clusterId?: string;
9090
constructor(
9191
private extensionContext: ExtensionContext,
92+
private loggerManager: LoggerManager,
9293
private logFilePath?: string
9394
) {}
9495

@@ -191,7 +192,13 @@ export class CliWrapper {
191192
}
192193
}
193194
ctx?.logger?.error(msg, e);
194-
this.showConfigFileWarning(msg);
195+
window
196+
.showWarningMessage(msg, "Open Databricks Config File")
197+
.then(async (choice) => {
198+
if (choice === "Open Databricks Config File") {
199+
await FileUtils.openDatabricksConfigFile();
200+
}
201+
});
195202
return [];
196203
}
197204

@@ -201,7 +208,7 @@ export class CliWrapper {
201208
profiles = profiles.filter((p: any) => !p.account_id);
202209

203210
const result = [];
204-
211+
let hasError = false;
205212
for (const profile of profiles) {
206213
try {
207214
result.push({
@@ -220,22 +227,27 @@ export class CliWrapper {
220227
msg = `Error parsing profile ${profile.name}`;
221228
}
222229
ctx?.logger?.error(msg, e);
223-
this.showConfigFileWarning(msg);
230+
hasError = true;
224231
}
225232
}
226-
return result;
227-
}
228233

229-
private async showConfigFileWarning(msg: string) {
230-
const openAction = "Open Databricks Config File";
231-
const choice = await window.showWarningMessage(
232-
msg,
233-
openAction,
234-
"Ignore"
235-
);
236-
if (choice === openAction) {
237-
await FileUtils.openDatabricksConfigFile();
234+
if (hasError) {
235+
window
236+
.showWarningMessage(
237+
"There were errors in parsing some profiles",
238+
"Open Databricks Config File",
239+
"Show Error Logs"
240+
)
241+
.then(async (choice) => {
242+
if (choice === "Open Databricks Config File") {
243+
await FileUtils.openDatabricksConfigFile();
244+
}
245+
if (choice === "Show Error Logs") {
246+
this.loggerManager.showOutputChannel("Databricks Logs");
247+
}
248+
});
238249
}
250+
return result;
239251
}
240252

241253
public async getBundleSchema(): Promise<string> {

packages/databricks-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function activate(
9999
e
100100
);
101101
}
102-
const cli = new CliWrapper(context, cliLogFilePath);
102+
const cli = new CliWrapper(context, loggerManager, cliLogFilePath);
103103
context.extensionPath;
104104

105105
if (

packages/databricks-vscode/src/file-managers/DatabricksEnvFileManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export class DatabricksEnvFileManager implements Disposable {
151151
logging.NamedLogger.getOrCreate(Loggers.Extension).debug(
152152
`${this.userEnvPath.fsPath} does not exist. Not loading user env vars and continuing.`
153153
);
154+
return;
154155
}
155156
return await EnvVarGenerators.getUserEnvVars(this.userEnvPath);
156157
}

0 commit comments

Comments
 (0)