diff --git a/packages/databricks-vscode/package.json b/packages/databricks-vscode/package.json index ae6491396..237c47b03 100644 --- a/packages/databricks-vscode/package.json +++ b/packages/databricks-vscode/package.json @@ -310,6 +310,18 @@ "enablement": "databricks.context.activated && databricks.context.bundle.isTargetSet && databricks.context.bundle.deploymentState == idle", "category": "Databricks", "icon": "$(trash)" + }, + { + "command": "databricks.bundle.forceDeploy", + "title": "Force deploy bundle", + "category": "Databricks", + "enablement": "databricks.context.activated && databricks.context.bundle.isTargetSet && databricks.context.bundle.deploymentState == idle" + }, + { + "command": "databricks.bundle.forceDestroy", + "title": "Force destroy bundle", + "category": "Databricks", + "enablement": "databricks.context.activated && databricks.context.bundle.isTargetSet && databricks.context.bundle.deploymentState == idle" } ], "viewsContainers": { @@ -429,6 +441,14 @@ "when": "view == dabsResourceExplorerView && databricks.context.bundle.deploymentState == idle", "group": "navigation@1" }, + { + "command": "databricks.bundle.forceDeploy", + "when": "view == dabsResourceExplorerView && databricks.context.bundle.deploymentState == idle" + }, + { + "command": "databricks.bundle.forceDestroy", + "when": "view == dabsResourceExplorerView && databricks.context.bundle.deploymentState == idle" + }, { "command": "databricks.bundle.variable.openFile", "when": "view == dabsVariableView && databricks.context.bundle.deploymentState == idle", diff --git a/packages/databricks-vscode/src/bundle/models/BundleRemoteStateModel.ts b/packages/databricks-vscode/src/bundle/models/BundleRemoteStateModel.ts index bbd97553b..13a8daf4a 100644 --- a/packages/databricks-vscode/src/bundle/models/BundleRemoteStateModel.ts +++ b/packages/databricks-vscode/src/bundle/models/BundleRemoteStateModel.ts @@ -59,7 +59,7 @@ export class BundleRemoteStateModel extends BaseModelWithStateCache { - await this.bundleRemoteStateModel.deploy(); + await this.bundleRemoteStateModel.deploy(force); } ); @@ -114,6 +114,11 @@ export class BundleCommands implements Disposable { await this.deploy(); } + @onError({log: true, popup: false}) + public async forceDeployCommand() { + await this.deploy(true); + } + @onError({popup: {prefix: "Error running resource."}}) async deployAndRun(treeNode: BundleResourceExplorerTreeNode) { if (!isRunnable(treeNode)) { @@ -147,8 +152,7 @@ export class BundleCommands implements Disposable { this.bundleRunStatusManager.cancel(treeNode.resourceKey); } - @onError({log: true, popup: false}) - async destroy() { + async destroy(force = false) { if ((await this.configModel.get("mode")) !== "development") { const confirm = await window.showErrorMessage( "Are you sure you want to destroy this bundle and all resources associated with it?", @@ -167,7 +171,7 @@ export class BundleCommands implements Disposable { await window.withProgress( {location: ProgressLocation.Notification, cancellable: false}, async () => { - await this.bundleRemoteStateModel.destroy(); + await this.bundleRemoteStateModel.destroy(force); } ); @@ -185,6 +189,16 @@ export class BundleCommands implements Disposable { } } + @onError({log: true, popup: false}) + public async destroyCommand() { + await this.destroy(); + } + + @onError({log: true, popup: false}) + public async forceDestroyCommand() { + await this.destroy(true); + } + dispose() { this.disposables.forEach((i) => i.dispose()); }