From 5b2de42ed366df72bab51022f79b3595eb297158 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Sun, 20 Jun 2021 17:09:31 +0200 Subject: [PATCH 1/2] register new destroy command --- package.json | 4 ++++ src/extension.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/package.json b/package.json index 9b4dd0148f..0ad81404fa 100644 --- a/package.json +++ b/package.json @@ -192,6 +192,10 @@ { "command": "terraform.plan", "title": "Terraform: plan" + }, + { + "command": "terraform.destroy", + "title": "Terraform: destroy" } ] }, diff --git a/src/extension.ts b/src/extension.ts index 7d0e491149..270c97e451 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -104,6 +104,9 @@ export async function activate(context: vscode.ExtensionContext): Promise { vscode.commands.registerCommand('terraform.validate', async () => { await terraformCommand('validate'); }), + vscode.commands.registerCommand('terraform.destroy', async () => { + await terraformCommand('destroy', false); + }), vscode.workspace.onDidChangeConfiguration( async (event: vscode.ConfigurationChangeEvent) => { if (event.affectsConfiguration('terraform') || event.affectsConfiguration('terraform-ls')) { From e2b1dcd45778ee7e3e1de269c0fa3c0cc1c0f2af Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Sun, 20 Jun 2021 17:26:49 +0200 Subject: [PATCH 2/2] show a warning message before running destroy --- src/extension.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 270c97e451..6d610d7608 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -105,7 +105,11 @@ export async function activate(context: vscode.ExtensionContext): Promise { await terraformCommand('validate'); }), vscode.commands.registerCommand('terraform.destroy', async () => { - await terraformCommand('destroy', false); + const result = await vscode.window.showWarningMessage('Do you really want to destroy all resources?', { modal: true}, 'Yes'); + + if (result) { + await terraformCommand('destroy', false); + } }), vscode.workspace.onDidChangeConfiguration( async (event: vscode.ConfigurationChangeEvent) => {