add config whether to check terraform exists in the path
This commit is contained in:
Родитель
696b76a278
Коммит
ce6d0136ff
|
@ -51,6 +51,11 @@
|
|||
],
|
||||
"description": "Specifies terminal used to run Terraform commands. Valid settings are `cloudshell` or `integrated`."
|
||||
},
|
||||
"azureTerraform.checkTerraformCmd": {
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Specifies whether or not check terraform installed in the PATH."
|
||||
},
|
||||
"azureTerraform.files": {
|
||||
"type": "string",
|
||||
"default": "**/*.{rb,sh,tf,tfvars,txt,yml}",
|
||||
|
|
|
@ -32,3 +32,11 @@ export function getLocationForTest(): string {
|
|||
export function getImageNameForTest(): string {
|
||||
return vscode.workspace.getConfiguration().get("azureTerraform.test.imageName");
|
||||
}
|
||||
|
||||
export function getCheckTerraformCmd(): boolean {
|
||||
return vscode.workspace.getConfiguration().get("azureTerraform.checkTerraformCmd");
|
||||
}
|
||||
|
||||
export function setCheckTerraformCmd(checked: boolean): void {
|
||||
vscode.workspace.getConfiguration().update("azureTerraform.checkTerraformCmd", checked);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,20 @@
|
|||
"use strict";
|
||||
|
||||
import { executeCommand } from "./cpUtils";
|
||||
import { openUrlHint } from "./uiUtils";
|
||||
import * as settingUtils from "./settingUtils";
|
||||
import { openUrlHintOrNotShowAgain } from "./uiUtils";
|
||||
|
||||
export async function checkTerraformInstalled(): Promise<void> {
|
||||
if (!settingUtils.getCheckTerraformCmd()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await executeCommand("terraform", ["-v"], { shell: true });
|
||||
} catch (error) {
|
||||
openUrlHint("Terraform is not installed, please make sure Terraform is in the PATH environment variable.", "https://aka.ms/azTerraform-requirement");
|
||||
openUrlHintOrNotShowAgain("Terraform is not installed, please make sure Terraform is in the PATH environment variable.",
|
||||
"https://aka.ms/azTerraform-requirement",
|
||||
() => {
|
||||
settingUtils.setCheckTerraformCmd(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,15 @@ import * as opn from "opn";
|
|||
import * as vscode from "vscode";
|
||||
import { terraformChannel } from "../terraformChannel";
|
||||
|
||||
export async function openUrlHintOrNotShowAgain(message: string, url: string, notShowCallback: () => void): Promise<void> {
|
||||
const response = await vscode.window.showInformationMessage(message, DialogOption.learnMore, DialogOption.notShownAgain);
|
||||
if (response === DialogOption.learnMore && url) {
|
||||
opn(url);
|
||||
} else if (response === DialogOption.notShownAgain) {
|
||||
notShowCallback();
|
||||
}
|
||||
}
|
||||
|
||||
export async function openUrlHint(message: string, url: string): Promise<void> {
|
||||
const response = await vscode.window.showInformationMessage(message, DialogOption.learnMore, DialogOption.cancel);
|
||||
if (response === DialogOption.learnMore && url) {
|
||||
|
@ -58,6 +67,7 @@ export namespace DialogOption {
|
|||
export const cancel: vscode.MessageItem = { title: "Cancel", isCloseAffordance: true };
|
||||
export const open: vscode.MessageItem = { title: "Open" };
|
||||
export const learnMore: vscode.MessageItem = { title: "Learn More" };
|
||||
export const notShownAgain: vscode.MessageItem = { title: "Don't show again" };
|
||||
}
|
||||
|
||||
export enum DialogType {
|
||||
|
|
Загрузка…
Ссылка в новой задаче