push files first when running test (#116)

* push files first when running test

* refine the wording

* remove 'the' before 'CloudShell'
This commit is contained in:
Sheng Chen 2018-02-09 17:03:20 +08:00 коммит произвёл GitHub
Родитель f39107e3aa
Коммит 489e303c61
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -30,7 +30,7 @@ export class CloudShell extends BaseShell {
try {
await Promise.all(promises);
vscode.window.showInformationMessage("Synced all matched files in the current workspace to CloudShell");
await vscode.window.showInformationMessage("Synced all matched files in the current workspace to CloudShell");
} catch (error) {
terraformChannel.appendLine(error);
await promptForOpenOutputChannel("Failed to push files to the cloud. Please open the output channel for more details.", DialogType.error);
@ -41,6 +41,15 @@ export class CloudShell extends BaseShell {
public async runTerraformTests(testType: string, workingDirectory: string) {
if (await this.connectedToCloudShell()) {
const choice: vscode.MessageItem = await vscode.window.showInformationMessage(
"Would you like to push the terraform project files to CloudShell?",
DialogOption.OK,
DialogOption.CANCEL,
);
if (choice === DialogOption.OK) {
await vscode.commands.executeCommand("vscode-terraform-azure.push");
}
const workspaceName: string = path.basename(workingDirectory);
const cloudDrivePath: string = `${workspaceName}/.TFTesting`;
const localPath: string = path.join(workingDirectory, ".TFTesting");
@ -59,17 +68,16 @@ export class CloudShell extends BaseShell {
const shellscript = exportTestScript("lint", TFConfiguration, this.tfTerminal.ResourceGroup, this.tfTerminal.storageAccountName, this.tfTerminal.fileShareName, cloudDrivePath);
console.log("Wrting scripts for e2e test");
await Promise.all([
fsExtra.outputFile(path.join(localPath, CREATE_ACI_SCRIPT), shellscript),
fsExtra.outputFile(path.join(localPath, CONTAINER_CMD_SCRIPT), exportContainerCmd(workspaceName, await this.resolveContainerCmd(testType))),
]);
console.log("Push scripts to cloudshell");
await Promise.all([
azFilePush(workspaceName, this.tfTerminal.storageAccountName, this.tfTerminal.storageAccountKey, this.tfTerminal.fileShareName, path.join(localPath, CREATE_ACI_SCRIPT)),
azFilePush(workspaceName, this.tfTerminal.storageAccountName, this.tfTerminal.storageAccountKey, this.tfTerminal.fileShareName, path.join(localPath, CONTAINER_CMD_SCRIPT)),
]);
const sentToTerminal: boolean = await this.runTFCommand(`cd ~/clouddrive/${cloudDrivePath} && source ${CREATE_ACI_SCRIPT} && terraform fmt && terraform init && terraform apply -auto-approve && terraform taint azurerm_container_group.TFTest && \
echo "\nRun the following command to get the logs from the ACI container: az container logs -g ${vscode.workspace.getConfiguration("tf-azure").get("aci-ResGroup")} -n ${vscode.workspace.getConfiguration("tf-azure").get("aci-name")}\n"`, cloudDrivePath);
if (sentToTerminal) {

Просмотреть файл

@ -78,12 +78,11 @@ export function activate(ctx: vscode.ExtensionContext) {
}));
ctx.subscriptions.push(vscode.commands.registerCommand("vscode-terraform-azure.push", () => {
ctx.subscriptions.push(vscode.commands.registerCommand("vscode-terraform-azure.push", async () => {
// Create a function that will sync the files to Cloudshell
if (terminalSetToCloudshell()) {
vscode.workspace.findFiles(filesGlobSetting()).then((tfFiles) => {
cloudShell.pushFiles(tfFiles);
});
const tfFiles: vscode.Uri[] = await vscode.workspace.findFiles(filesGlobSetting());
await cloudShell.pushFiles(tfFiles);
} else {
vscode.window.showErrorMessage("Push function only available when using cloudshell.");
}