From 98add3361ca0ef9753fe4cd9920ebe75da08747c Mon Sep 17 00:00:00 2001 From: nickyinluo Date: Tue, 17 Oct 2023 14:40:43 +0800 Subject: [PATCH] 1.enable the terraformer. 2.adjust code format. --- README.md | 3 +- package.json | 9 +- src/{utils => client/runner}/baseRunner.ts | 19 +- .../runner}/terraformRunner.ts | 79 +++++--- .../runner}/terraformerRunner.ts | 18 +- src/{ => client/terminal}/baseShell.ts | 0 src/{ => client/terminal}/cloudShell.ts | 9 +- src/{ => client/terminal}/integratedShell.ts | 76 ++++++-- src/{ => client/terminal}/terraformChannel.ts | 0 .../terminal}/terraformShellManager.ts | 32 +-- src/commons/commands.ts | 49 ----- src/{ => commons}/constants.ts | 1 + src/commons/customCmdRegister.ts | 57 ++++++ src/commons/index.ts | 8 +- src/extension.ts | 40 ++-- src/import/mysql.ts | 2 +- src/import/tke.ts | 2 +- src/utils/cpUtils.ts | 2 +- src/utils/gitUtils.ts | 96 +++++++++ src/utils/uiUtils.ts | 2 +- src/views/resources/resExplorer.ts | 2 +- terraform.log | 184 ++++++++++++++++++ terraform.tfstate | 8 + 23 files changed, 537 insertions(+), 161 deletions(-) rename src/{utils => client/runner}/baseRunner.ts (67%) rename src/{utils => client/runner}/terraformRunner.ts (65%) rename src/{utils => client/runner}/terraformerRunner.ts (88%) rename src/{ => client/terminal}/baseShell.ts (100%) rename src/{ => client/terminal}/cloudShell.ts (93%) rename src/{ => client/terminal}/integratedShell.ts (70%) rename src/{ => client/terminal}/terraformChannel.ts (100%) rename src/{ => client/terminal}/terraformShellManager.ts (53%) delete mode 100644 src/commons/commands.ts rename src/{ => commons}/constants.ts (86%) create mode 100644 src/commons/customCmdRegister.ts create mode 100644 src/utils/gitUtils.ts create mode 100644 terraform.log create mode 100644 terraform.tfstate diff --git a/README.md b/README.md index b24d94b..4a1672e 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,10 @@ This extension supports the following features: - Terraform commands: init, plan, apply, validate, refresh and destroy. - Auto complete: Autocomplete resource types, parameters, and resource definitions. -- Import resource: display the existing `CVM` resource and then import it as a tf file by `terraform import`. +- Import resource: display the existing `CVM` resource and then import it as a tf file by [Terraformer](https://github.com/GoogleCloudPlatform/terraformer). *TO-DO(Features to be supported in the future):* - Visualize: graph the terraform resources and modules. -- Resource Import: support import of more kinds of resources by [Terraformer](https://github.com/GoogleCloudPlatform/terraformer). - Autocomplete: provider code snippets of the specified resource. - Connect to Tencent Cloud: login to Tencent Cloud and sync your account info(eg: obtain AKSK/Token automatically). diff --git a/package.json b/package.json index 03896ef..ba5178f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-tencentcloud-terraform", "displayName": "Tencent Cloud Terraform", "description": "VS Code extension for developing with Terraform on Tencent Cloud", - "version": "0.0.5", + "version": "0.0.6", "license": "MIT", "publisher": "Tencent-Cloud", "icon": "images/tc-tf-logo.png", @@ -150,9 +150,10 @@ "category": "TencentCloud Terraform" }, { - "command": "tcTerraform.push", - "title": "Push", - "category": "TencentCloud Terraform" + "command": "tcTerraform.git.push", + "title": "Push to git", + "category": "TencentCloud Terraform", + "shortTitle": "Push" }, { "command": "tcTerraformer.import", diff --git a/src/utils/baseRunner.ts b/src/client/runner/baseRunner.ts similarity index 67% rename from src/utils/baseRunner.ts rename to src/client/runner/baseRunner.ts index 4dea3b0..3014e6d 100644 --- a/src/utils/baseRunner.ts +++ b/src/client/runner/baseRunner.ts @@ -18,7 +18,7 @@ export abstract class BaseRunner { * @param cwd * @returns */ - public abstract preImport(cwd: string, args?: any, path?: string): Promise; + public abstract preImport(cwd: string, args?: any, file?: string): Promise; /** * execute this command to import the existing resource from tencentcloud @@ -26,15 +26,26 @@ export abstract class BaseRunner { * @param args * @returns */ - public abstract executeImport(cwd: string, args?: string): Promise; + public abstract executeImport(cwd: string, args?: any, cmd?: any, flags?: any): Promise; /** * execute this command to handle post of the terraform import. * @param cwd * @param executor Choose who will execute this command? terraform or terraformer + * @param cmd + * @param flags * @returns */ - public abstract postImport(cwd: string, executor?:string, args?: string): Promise; + public abstract postImport(cwd: string, executor?: string, args?: string): Promise; + + /** + * execute this command to plan the tf code + * @param cwd + * @param args + * @param cmd + * @param flags + */ + public abstract executePlan(cwd: string, args?: any, cmd?: any, flags?: any): Promise; /** * check binary whether ready or not @@ -46,5 +57,5 @@ export abstract class BaseRunner { * @param cwd * @returns */ - public abstract executeShow(cwd: string, args?: string): Promise; + public abstract executeShow(cwd: string, args?: any): Promise; } diff --git a/src/utils/terraformRunner.ts b/src/client/runner/terraformRunner.ts similarity index 65% rename from src/utils/terraformRunner.ts rename to src/client/runner/terraformRunner.ts index 5ad5388..33b3c79 100644 --- a/src/utils/terraformRunner.ts +++ b/src/client/runner/terraformRunner.ts @@ -7,12 +7,12 @@ import * as path from "path"; import * as fse from "fs-extra"; import * as vscode from "vscode"; -import { executeCommand } from "./cpUtils"; import { BaseRunner } from "./baseRunner"; -import { TerraformCommand } from "../commons/commands"; -import { terraformShellManager } from "../terraformShellManager"; -import * as settingUtils from "./settingUtils"; -import { openUrlHintOrNotShowAgain } from "./uiUtils"; +import { TerraformCommand } from "../../commons/customCmdRegister"; +import { terraformShellManager } from "../terminal/terraformShellManager"; +import { executeCommand } from "../../utils/cpUtils"; +import * as settingUtils from "../../utils/settingUtils"; +import { openUrlHintOrNotShowAgain } from "../../utils/uiUtils"; export class TerraformRunner extends BaseRunner { @@ -33,21 +33,23 @@ export class TerraformRunner extends BaseRunner { // throw new Error("Method not implemented."); } - public async executeShow(cwd: string, args?: string): Promise { - return await executeCommand( - "terraform", - ["show"], - { - shell: true, - cwd, - } - ); + public async executePlan(cwd: string, args: any): Promise { + console.debug("[DEBUG]#### TerraformRunner executePlan begin."); + + const resAddress = `${args.resource.type}.${args.resource.name}`; + + // reset state + await this.resetTFState(resAddress); + + terraformShellManager.getIntegratedShell(TerraformRunner.getInstance()).runTerraformCmd(TerraformCommand.Plan); + + return ""; } - public async executeImport(cwd: string, args?: string): Promise { + public async executeShow(cwd: string, args?: any): Promise { return await executeCommand( "terraform", - [args], + ["show"], { shell: true, cwd, @@ -55,11 +57,11 @@ export class TerraformRunner extends BaseRunner { ); } - public async preImport(cwd: string, params: any, file: string): Promise<{ importArgs: string, tfFile: string }> { - const fileName = (file === undefined) ? params.resource.type + '.tf' : file; + public async preImport(cwd: string, args: any, file: string): Promise<{ importArgs: string, tfFile: string }> { + const fileName = (file === undefined) ? args.resource.type + '.tf' : file; - const defaultContents = `resource "${params.resource.type}" "${params.resource.name}" {}`; - const resAddress = `${params.resource.type}.${params.resource.name}`; + const defaultContents = `resource "${args.resource.type}" "${args.resource.name}" {}`; + const resAddress = `${args.resource.type}.${args.resource.name}`; const tfFile: string = path.join(cwd, fileName); @@ -68,22 +70,20 @@ export class TerraformRunner extends BaseRunner { // reset state await this.resetTFState(resAddress); - const importArgs = ['import ', params.resource.type, '.', params.resource.name, ' ', params.resource.id].join(''); + const importArgs = ['import ', args.resource.type, '.', args.resource.name, ' ', args.resource.id].join(''); console.debug("[DEBUG]#### import cmd: args=[%s], defaultContents=[%s]", importArgs, defaultContents); return { importArgs, tfFile }; } - - private async resetFileContent(tfFile: string, defaultContents: string) { - if (!fse.existsSync(tfFile)) { - fse.writeFileSync(tfFile, defaultContents); - } else { - await fse.writeFile(tfFile, defaultContents); - } - } - - private async resetTFState(resAddress: string) { - await terraformShellManager.getIntegratedShell().runTerraformCmd(TerraformCommand.State, ['rm', '-lock=false', resAddress]); + public async executeImport(cwd: string, args?: string): Promise { + return await executeCommand( + "terraform", + [args], + { + shell: true, + cwd, + } + ); } /** @@ -110,6 +110,21 @@ export class TerraformRunner extends BaseRunner { } return; } + + private async resetFileContent(tfFile: string, defaultContents: string) { + if (!fse.existsSync(tfFile)) { + fse.writeFileSync(tfFile, defaultContents); + } else { + await fse.writeFile(tfFile, defaultContents); + } + } + + public async resetTFState(resAddress: string) { + console.debug("[DEBUG]#### TerraformRunner resetTFState begin."); + + await terraformShellManager.getIntegratedShell(TerraformRunner.getInstance()) + .runTerraformCmd(TerraformCommand.State, ['rm', '-lock=false', resAddress]); + } } export function getCheckTerraformCmd(): boolean { diff --git a/src/utils/terraformerRunner.ts b/src/client/runner/terraformerRunner.ts similarity index 88% rename from src/utils/terraformerRunner.ts rename to src/client/runner/terraformerRunner.ts index 99f2c7f..df005e2 100644 --- a/src/utils/terraformerRunner.ts +++ b/src/client/runner/terraformerRunner.ts @@ -1,13 +1,14 @@ +/* eslint-disable @typescript-eslint/naming-convention */ /*--------------------------------------------------------------------------------------------- * Copyright (c) Tencent Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; import * as vscode from "vscode"; -import * as settingUtils from "./settingUtils"; -import { executeCommand } from "./cpUtils"; +import * as settingUtils from "../../utils/settingUtils"; +import { executeCommand } from "../../utils/cpUtils"; import { BaseRunner } from "./baseRunner"; -import { openUrlHintOrNotShowAgain } from "./uiUtils"; +import { openUrlHintOrNotShowAgain } from "../../utils/uiUtils"; export const defaultProduct = ["vpc", "subnet", "security_group"]; @@ -55,8 +56,8 @@ export class TerraformerRunner extends BaseRunner { } - public async preImport(cwd: string, args?: any, path?: string): Promise { - console.debug("[DEBUG]#### TerraformerRunner.preImport begin, cwd:[%s], args:[%s], path:[%s]", cwd, args, path); + public async preImport(cwd: string, args?: any, file?: string): Promise { + console.debug("[DEBUG]#### TerraformerRunner.preImport begin, cwd:[%s], args:[%s], path:[%s]", cwd, args, file); return await executeCommand( "terraform", ["init", "-upgrade"], @@ -101,7 +102,7 @@ export class TerraformerRunner extends BaseRunner { public async postImport(cwd: string, args?: string): Promise { console.debug("[DEBUG]#### TerraformerRunner.postImport begin, cwd:[%s], args:[%s]", cwd, args); const exeArgs = args.split(","); - + return await executeCommand( "terraformer", exeArgs, @@ -112,6 +113,11 @@ export class TerraformerRunner extends BaseRunner { ); } + public async executePlan(cwd: string, args?: string): Promise { + console.debug("[DEBUG]#### TerraformerRunner not need this step, skip it."); + return ""; + } + public async executeShow(cwd: string, args?: string): Promise { console.debug("[DEBUG]#### TerraformerRunner not need this step, skip it."); return ""; diff --git a/src/baseShell.ts b/src/client/terminal/baseShell.ts similarity index 100% rename from src/baseShell.ts rename to src/client/terminal/baseShell.ts diff --git a/src/cloudShell.ts b/src/client/terminal/cloudShell.ts similarity index 93% rename from src/cloudShell.ts rename to src/client/terminal/cloudShell.ts index 1428d1c..a10bfff 100644 --- a/src/cloudShell.ts +++ b/src/client/terminal/cloudShell.ts @@ -5,21 +5,16 @@ "use strict"; -import * as fsExtra from "fs-extra"; -import * as path from "path"; -import { MessageItem } from "vscode"; import * as vscode from "vscode"; import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; // import { AzureAccount, CloudShell } from "./azure-account.api"; import { BaseShell } from "./baseShell"; // import { aciConfig, Constants, exportContainerCmd, exportTestScript } from "./constants"; // import { azFileDelete, azFilePush, escapeFile, TerraformCommand, TestOption } from "./shared"; -import { TerraformCommand } from "./commons/commands"; +import { TerraformCommand } from "../../commons/customCmdRegister"; import { terraformChannel } from "./terraformChannel"; // import { getStorageAccountforCloudShell, IStorageAccount } from "./utils/cloudShellUtils"; -import * as settingUtils from "./utils/settingUtils"; -import { DialogOption, DialogType, promptForOpenOutputChannel } from "./utils/uiUtils"; -import { selectWorkspaceFolder } from "./utils/workspaceUtils"; +import { DialogOption, DialogType, promptForOpenOutputChannel } from "../../utils/uiUtils"; export class TencentCloudShell extends BaseShell { diff --git a/src/integratedShell.ts b/src/client/terminal/integratedShell.ts similarity index 70% rename from src/integratedShell.ts rename to src/client/terminal/integratedShell.ts index a42bd85..54b437d 100644 --- a/src/integratedShell.ts +++ b/src/client/terminal/integratedShell.ts @@ -12,29 +12,35 @@ import * as vscode from "vscode"; import { commands, Uri, ViewColumn } from "vscode"; import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { BaseShell } from "./baseShell"; -import { Constants } from "./constants"; -import { executeCommand } from "./utils/cpUtils"; -import { drawGraph } from "./utils/dotUtils"; -import { isDotInstalled } from "./utils/dotUtils"; -import { selectWorkspaceFolder } from "./utils/workspaceUtils"; -import { TerraformCommand } from "./commons/commands"; -import * as helper from "./utils/helper"; -import { command } from "./commons/tencent/commands"; +import { Constants } from "../../commons/constants"; +import { executeCommand } from "../../utils/cpUtils"; +import { drawGraph } from "../../utils/dotUtils"; +import { isDotInstalled } from "../../utils/dotUtils"; +import { selectWorkspaceFolder } from "../../utils/workspaceUtils"; import { promisify } from "util"; -import { ChildProcess } from "child_process"; import * as cp from "child_process"; -import { TerraformerRunner, CommandType, FlagType, FlagsMap, defaultProduct } from "./utils/terraformerRunner"; -import { values } from "lodash"; +import { BaseRunner } from "../runner/baseRunner"; +import { TerraformerRunner, CommandType, FlagType, FlagsMap, defaultProduct } from "../../client/runner/terraformerRunner"; +import { TerraformRunner } from "../runner/terraformRunner"; // import stripAnsi from 'strip-ansi'; export class IntegratedShell extends BaseShell { + // eslint-disable-next-line @typescript-eslint/naming-convention private static readonly GRAPH_FILE_NAME = "graph.png"; + private readonly runner: BaseRunner; + + constructor(rr: BaseRunner) { + super(); + // terraform or terraformer? + this.runner = rr; + } // Creates a png of terraform resource graph to visualize the resources under management. public async visualize(): Promise { - if (!await isDotInstalled()) { + console.debug("[DEBUG]#### IntegratedShell visualize begin."); + if (!await isDotInstalled()) { TelemetryWrapper.sendError(Error("dotNotInstalled")); return; } @@ -66,11 +72,12 @@ export class IntegratedShell extends BaseShell { await commands.executeCommand("vscode.open", Uri.file(path.join(cwd, IntegratedShell.GRAPH_FILE_NAME)), ViewColumn.Two); } + // import a existed resource into terraform public async import(params: any, file?: string): Promise { + console.debug("[DEBUG]#### IntegratedShell import begin."); - const runner = TerraformerRunner.getInstance();// terraform or terraformer - - await runner.checkInstalled(); + // const runner = TerraformerRunner.getInstance(); + await this.runner.checkInstalled(); const cwd: string = await selectWorkspaceFolder(); if (!cwd) { @@ -78,7 +85,7 @@ export class IntegratedShell extends BaseShell { return; } - const preRet = await runner.preImport(cwd); + const preRet = await this.runner.preImport(cwd, params); console.debug("[DEBUG]#### Executed pre-import. result:[%s]", preRet); const resource = defaultProduct; @@ -106,14 +113,14 @@ export class IntegratedShell extends BaseShell { }, ]; - const importRet = await runner.executeImport(cwd, "", cmd, flags); + const importRet = await this.runner.executeImport(cwd, "", cmd, flags); console.debug("[DEBUG]#### Executed import command. result:[%s]", importRet); // terraform state replace-provider registry.terraform.io/-/tencentcloud tencentcloudstack/tencentcloud const args = ""; - const postRet = await runner.postImport(cwd, args); + const postRet = await this.runner.postImport(cwd, args); - const content: string = await runner.executeShow(cwd); + const content: string = await this.runner.executeShow(cwd); const tfFile: string = importRet; @@ -122,6 +129,30 @@ export class IntegratedShell extends BaseShell { await commands.executeCommand("vscode.open", Uri.file(tfFile), ViewColumn.Active || ViewColumn.One); } + // run terraform plan command + public async plan(params: any): Promise { + console.debug("[DEBUG]#### IntegratedShell plan begin. params:[%v]", params); + + await this.runner.checkInstalled(); + if (this.runner instanceof TerraformRunner) { + + const cwd: string = await selectWorkspaceFolder(); + if (!cwd) { + TelemetryWrapper.sendError(Error("noWorkspaceSelected")); + return; + } + + const result = await this.runner.executePlan(cwd, params); + console.debug("[DEBUG]#### Executed plan. result:[%s]", result); + } + } + + // run terraform push command + public async push(params: any): Promise { + console.debug("[DEBUG]#### IntegratedShell push begin. params:[%v]", params); + + + } public async runTerraformCmdWithoutTerminal(tfCommand: string, args?: string[]) { const cmd = [tfCommand, ...(args || [])].join(' '); @@ -134,8 +165,11 @@ export class IntegratedShell extends BaseShell { this.terminal.show(); // const cmd= [tfCommand, args.values].join(' '); - let tmp: string[] = [tfCommand]; - args.forEach((arg) => tmp.push(arg)); + + const tmp: string[] = [tfCommand]; + if (args) { + args.forEach((arg) => tmp.push(arg)); + } const cmd = tmp.join(' '); this.terminal.sendText(cmd); } diff --git a/src/terraformChannel.ts b/src/client/terminal/terraformChannel.ts similarity index 100% rename from src/terraformChannel.ts rename to src/client/terminal/terraformChannel.ts diff --git a/src/terraformShellManager.ts b/src/client/terminal/terraformShellManager.ts similarity index 53% rename from src/terraformShellManager.ts rename to src/client/terminal/terraformShellManager.ts index a882aae..08db68c 100644 --- a/src/terraformShellManager.ts +++ b/src/client/terminal/terraformShellManager.ts @@ -9,40 +9,50 @@ import * as TelemetryWrapper from "vscode-extension-telemetry-wrapper"; import { BaseShell } from "./baseShell"; import { TencentCloudShell } from "./cloudShell"; import { IntegratedShell } from "./integratedShell"; -import { isTerminalSetToCloudShell } from "./utils/settingUtils"; +import { isTerminalSetToCloudShell } from "../../utils/settingUtils"; +import { TerraformerRunner } from "../runner/terraformerRunner"; export interface ITerraformShellManager { getShell(): BaseShell; // getCloudShell(): TCCloudShell; - getIntegratedShell(): IntegratedShell; + getIntegratedShell(runner?: any): IntegratedShell; dispose(): void; } class TerraformShellManager implements ITerraformShellManager { - private readonly cloudShell = new TencentCloudShell(); - private readonly integratedShell = new IntegratedShell(); + private static cloudShell = new TencentCloudShell(); + private static integratedShell: IntegratedShell; public getShell(): BaseShell { const isCloudShell: boolean = isTerminalSetToCloudShell(); TelemetryWrapper.addContextProperty("isCloudShell", isCloudShell.toString()); if (isCloudShell) { - return this.cloudShell; + return TerraformShellManager.cloudShell; } - return this.integratedShell; + return TerraformShellManager.integratedShell; } public getCloudShell(): TencentCloudShell { - return this.cloudShell; + return TerraformShellManager.cloudShell; } - public getIntegratedShell(): IntegratedShell { - return this.integratedShell; + public getIntegratedShell(runner?: any): IntegratedShell { + if (!TerraformShellManager.integratedShell) { + if (runner) { + TerraformShellManager.integratedShell = new IntegratedShell(runner); + } else { + // default runner is Terraformer + TerraformShellManager.integratedShell = new IntegratedShell(TerraformerRunner.getInstance()); + } + } + + return TerraformShellManager.integratedShell; } public dispose(): void { - this.cloudShell.dispose(); - this.integratedShell.dispose(); + TerraformShellManager.cloudShell.dispose(); + TerraformShellManager.integratedShell.dispose(); } } diff --git a/src/commons/commands.ts b/src/commons/commands.ts deleted file mode 100644 index f69631f..0000000 --- a/src/commons/commands.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { commands, env, Uri } from "vscode"; -import { terraformShellManager } from "../terraformShellManager"; - -"use strict"; - -export enum TerraformCommand { - Init = "terraform init", - Plan = "terraform plan", - Apply = "terraform apply", - Import = "terraform import", - Refresh = "terraform refresh", - Destroy = "terraform destroy", - Validate = "terraform validate", - Show = "terraform show", - State = "terraform state" -} - -export enum TerraformerCommand { - Plan = "terraformer plan", - Import = "terraformer import" -} - -export enum TcCliCommand { - Login = "tccli configure", - Service = "tccli service", -} - - -const openURL = "tcTerraform.openurl"; -// const executeImport = TerraformCommand.Import; -const executeImport = TerraformerCommand.Import; - -export function registerHelpCommands() { - commands.registerCommand(cmds.openURL, function (url: string) { - env.openExternal(Uri.parse(url)); - }); -} - -export function registerResourceCommands() { - commands.registerCommand(cmds.executeImport, function (param: any) { - // terraformShellManager.getShell().runTerraformCmd(importObject); - terraformShellManager.getIntegratedShell().import(param, param.fileName); - }); -} - -export const cmds = { - openURL, - executeImport, -}; diff --git a/src/constants.ts b/src/commons/constants.ts similarity index 86% rename from src/constants.ts rename to src/commons/constants.ts index 1ba4bc9..19cbd10 100644 --- a/src/constants.ts +++ b/src/commons/constants.ts @@ -6,6 +6,7 @@ "use strict"; export class Constants { + // eslint-disable-next-line @typescript-eslint/naming-convention public static TerraformTerminalName = "TIAT-Terraform"; } diff --git a/src/commons/customCmdRegister.ts b/src/commons/customCmdRegister.ts new file mode 100644 index 0000000..5cde677 --- /dev/null +++ b/src/commons/customCmdRegister.ts @@ -0,0 +1,57 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { commands, env, Uri } from "vscode"; +import { terraformShellManager } from "../client/terminal/terraformShellManager"; +import { TerraformerRunner } from "../client/runner/terraformerRunner"; +import { TerraformRunner } from "../client/runner/terraformRunner"; + +"use strict"; + +export enum TerraformCommand { + Init = "terraform init", + Plan = "terraform plan", + Apply = "terraform apply", + Import = "terraform import", + Refresh = "terraform refresh", + Destroy = "terraform destroy", + Validate = "terraform validate", + Show = "terraform show", + State = "terraform state" +} + +export enum TerraformerCommand { + Plan = "terraformer plan", + Import = "terraformer import" +} + +export enum TcCliCommand { + Login = "tccli configure", + Service = "tccli service", +} + +const openURL = "tcTerraform.openurl"; +const executeTfImport = TerraformCommand.Import; +const executeTferImport = TerraformerCommand.Import; + +export function regHelpCommands() { + commands.registerCommand(cmds.openURL, function (url: string) { + env.openExternal(Uri.parse(url)); + }); +} + +export function regResourceRelatedCommands() { + commands.registerCommand(cmds.executeTferImport, function (param: any) { + // terraformShellManager.getShell().runTerraformCmd(importObject); + terraformShellManager.getIntegratedShell(TerraformerRunner.getInstance()).import(param, param.fileName); + }); + + commands.registerCommand("tcTerraform.plan", function (param: any) { + // terraformShellManager.getShell().runTerraformCmd(importObject); + terraformShellManager.getIntegratedShell(TerraformRunner.getInstance()).plan(param); + }); +} + +export const cmds = { + openURL, + executeTfImport, + executeTferImport +}; diff --git a/src/commons/index.ts b/src/commons/index.ts index 619b5f0..4263d10 100644 --- a/src/commons/index.ts +++ b/src/commons/index.ts @@ -1,11 +1,11 @@ -import * as command from "./commands"; +import * as customerCmd from "./customCmdRegister"; export { tencent } from "./tencent"; export * from "./container"; export * from "./context"; -export {cmds} from "./commands"; +export { cmds } from "./customCmdRegister"; export function registerCommon() { // registerTencent(); - command.registerHelpCommands(); - command.registerResourceCommands(); + customerCmd.regHelpCommands(); + customerCmd.regResourceRelatedCommands(); } diff --git a/src/extension.ts b/src/extension.ts index 9f7948f..e491c9f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,15 +3,17 @@ import * as vscode from 'vscode'; import * as settingUtils from "./utils/settingUtils"; import { init } from "vscode-nls-i18n"; -import { TerraformCommand } from "./commons/commands"; -import { terraformShellManager } from "./terraformShellManager"; +import { TerraformCommand, TerraformerCommand } from "./commons/customCmdRegister"; +import { terraformShellManager } from "./client/terminal/terraformShellManager"; import { DialogOption } from "./utils/uiUtils"; import { TerraformCompletionProvider } from './autocomplete/TerraformCompletionProvider'; import { TerraformDefinitionProvider } from './autocomplete/TerraformDefinitionProvider'; import { registerCommon } from './commons'; import { registerView } from './views'; -import { TerraformRunner } from './utils/terraformRunner'; -import { TerraformerRunner } from './utils/terraformerRunner'; +import { TerraformRunner } from './client/runner/terraformRunner'; +import { TerraformerRunner } from './client/runner/terraformerRunner'; +import { GitUtils } from './utils/gitUtils'; +import _ from 'lodash'; const TF_MODE: vscode.DocumentFilter = { language: 'terraform', scheme: 'file' }; @@ -40,14 +42,16 @@ export async function activate(context: vscode.ExtensionContext) { }); context.subscriptions.push(disposableLogin); - + // terraform cmd context.subscriptions.push(vscode.commands.registerCommand('tcTerraform.init', () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Init); })); - context.subscriptions.push(vscode.commands.registerCommand('tcTerraform.plan', () => { - terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Plan); - })); + // move plan to customCmdRegister + // context.subscriptions.push(vscode.commands.registerCommand('tcTerraform.plan', () => { + // await terraformShellManager.getIntegratedShell(TerraformRunner.getInstance()).plan(); + + // })); context.subscriptions.push(vscode.commands.registerCommand('tcTerraform.apply', () => { terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Apply); @@ -80,7 +84,7 @@ export async function activate(context: vscode.ExtensionContext) { return; } } - await terraformShellManager.getIntegratedShell().visualize(); + await terraformShellManager.getIntegratedShell(TerraformRunner.getInstance()).visualize(); }); context.subscriptions.push(disposableGraph); @@ -91,22 +95,26 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(disposableTest); - let disposablePush = vscode.commands.registerCommand('tcTerraform.push', async () => { - // to-do - // wait for cloudshell implement ready + // git operations + let disposablePush = vscode.commands.registerCommand('tcTerraform.git.push', async () => { + if (_.isEmpty(vscode.workspace.workspaceFolders)) { + vscode.window.showInformationMessage("Please open a workspace in VS Code first."); + return; + } + await GitUtils.getInstance().submitToGit(); }); context.subscriptions.push(disposablePush); - // terraformer + // terraformer cmd let disposableTferImport = vscode.commands.registerCommand('tcTerraformer.import', async () => { - terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Destroy); + terraformShellManager.getShell().runTerraformCmd(TerraformerCommand.Import); }); context.subscriptions.push(disposableTferImport); let disposableTferPlan = vscode.commands.registerCommand('tcTerraformer.plan', async () => { - terraformShellManager.getShell().runTerraformCmd(TerraformCommand.Destroy); + terraformShellManager.getShell().runTerraformCmd(TerraformerCommand.Plan); }); context.subscriptions.push(disposableTferPlan); @@ -116,7 +124,7 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.languages.registerCompletionItemProvider(TF_MODE, new TerraformCompletionProvider(), '.')); context.subscriptions.push(vscode.languages.registerDefinitionProvider(TF_MODE, new TerraformDefinitionProvider())); - // import + // import-resource console.log('activate the import feature'); init(context.extensionPath); registerCommon(); diff --git a/src/import/mysql.ts b/src/import/mysql.ts index 6a773c5..58c3954 100644 --- a/src/import/mysql.ts +++ b/src/import/mysql.ts @@ -1,4 +1,4 @@ -import { ITencentCloudAPI } from "@/commons/tencent/sdkApi"; +import { ITencentCloudAPI } from "../commons/tencent/sdkApi"; export class MysqlService implements ITencentCloudAPI { describeInstances(params?: any): Promise { diff --git a/src/import/tke.ts b/src/import/tke.ts index b49eec4..2205a80 100644 --- a/src/import/tke.ts +++ b/src/import/tke.ts @@ -1,4 +1,4 @@ -import { ITencentCloudAPI } from "@/commons/tencent/sdkApi"; +import { ITencentCloudAPI } from "../commons/tencent/sdkApi"; export class TkeService implements ITencentCloudAPI { describeInstances(params?: any): Promise { diff --git a/src/utils/cpUtils.ts b/src/utils/cpUtils.ts index 752fe60..a79d471 100644 --- a/src/utils/cpUtils.ts +++ b/src/utils/cpUtils.ts @@ -6,7 +6,7 @@ "use strict"; import * as cp from "child_process"; -import { terraformChannel } from "../terraformChannel"; +import { terraformChannel } from "../client/terminal/terraformChannel"; export async function executeCommand(command: string, args: string[], options: cp.SpawnOptions): Promise { return new Promise((resolve: (res: string) => void, reject: (e: Error) => void): void => { diff --git a/src/utils/gitUtils.ts b/src/utils/gitUtils.ts new file mode 100644 index 0000000..ae30f45 --- /dev/null +++ b/src/utils/gitUtils.ts @@ -0,0 +1,96 @@ +import * as vscode from 'vscode'; +import { exec } from 'child_process'; +import path from 'path'; +import * as fs from 'fs'; + +export class GitUtils { + private static instance: GitUtils; + + public static getInstance(): GitUtils { + if (!GitUtils.instance) { + GitUtils.instance = new GitUtils(); + } + return GitUtils.instance; + } + + public async submitToGit(): Promise { + console.debug("[DEBUG]#### GitUtils submitToGit begin."); + const gitRootPath = vscode.workspace.rootPath; + if (!gitRootPath) { + vscode.window.showErrorMessage('Please open a workspace folder first!'); + return; + } + + while (true) { + if (fs.existsSync(path.join(gitRootPath, '.git'))) { + vscode.window.showInformationMessage('Trying to fetch from Git, please wait...'); + await this.fetchFromGit(); + break; + } else { + vscode.window.showInformationMessage(`You are not in a git repository yet, trying to clone from your Git repo...`); + await this.cloneFromGit(); + // retry + } + } + + exec('git add . && git commit -m "committed by VS Code" && git push', { cwd: gitRootPath }, (error, stdout, stderr) => { + if (error) { + vscode.window.showErrorMessage(`Failed to submit code: ${error.message}`); + return; + } + if (stderr) { + vscode.window.showErrorMessage(`Failed to submit code: ${stderr}`); + return; + } + vscode.window.showInformationMessage('Code has been successfully submitted to Git repo!'); + }); + return; + } + + private async cloneFromGit(): Promise { + console.debug("[DEBUG]#### GitUtils cloneFromGit begin."); + await vscode.window.showInputBox({ prompt: 'Please enter the Git repository URL:' }).then((url) => { + if (url) { + const folderName = url.split('/').pop()?.replace('.git', ''); + const clonePath = vscode.workspace.rootPath ? `${vscode.workspace.rootPath}/${folderName}` : folderName || ''; + if (fs.existsSync(clonePath)) { + console.debug("[DEBUG]#### GitUtils cloneFromGit: clean and remove the clonePath before cloning the repository."); + fs.rm(clonePath, { recursive: true }, () => { }); + } + + console.debug("[DEBUG]#### GitUtils cloneFromGit exec:[git clone %s %s].", url, clonePath); + exec(`git clone ${url} ${clonePath}`, {}, (error, stdout, stderr) => { + if (error) { + vscode.window.showErrorMessage(`Failed to clone code: ${error.message}`); + return; + } + if (stderr) { + vscode.window.showErrorMessage(`Failed to clone code: ${stderr}`); + return; + } + vscode.window.showInformationMessage('Code has been successfully cloned from Git repo!'); + }); + } + }); + return; + } + + private async fetchFromGit(): Promise { + console.debug("[DEBUG]#### GitUtils fetchFromGit begin."); + const gitRootPath = vscode.workspace.rootPath; + exec('git pull', { cwd: gitRootPath }, (error, stdout, stderr) => { + if (error) { + vscode.window.showErrorMessage(`Failed to fetch code: ${error.message}`); + return; + } + if (stderr) { + vscode.window.showErrorMessage(`Failed to fetch code: ${stderr}`); + return; + } + vscode.window.showInformationMessage('Code has been successfully fetched from Git repo!'); + }); + } + +} + + diff --git a/src/utils/uiUtils.ts b/src/utils/uiUtils.ts index f5441cb..802b8b6 100644 --- a/src/utils/uiUtils.ts +++ b/src/utils/uiUtils.ts @@ -8,7 +8,7 @@ // import * as opn from "opn"; import opn from "opn"; import * as vscode from "vscode"; -import { terraformChannel } from "../terraformChannel"; +import { terraformChannel } from "../client/terminal/terraformChannel"; export async function openUrlHintOrNotShowAgain(message: string, url: string, notShowCallback: () => void): Promise { const response = await vscode.window.showInformationMessage(message, DialogOption.learnMore, DialogOption.notShownAgain); diff --git a/src/views/resources/resExplorer.ts b/src/views/resources/resExplorer.ts index e9a8c11..5c2cc71 100644 --- a/src/views/resources/resExplorer.ts +++ b/src/views/resources/resExplorer.ts @@ -28,7 +28,7 @@ export class CvmResProvider extends tencent.tree.TreeDataProvider { id: instance.InstanceId, // iconPath: Icons.getIcon("book"), command: { - command: cmds.executeImport, + command: cmds.executeTferImport, title: "", arguments: [{ resource: { diff --git a/terraform.log b/terraform.log new file mode 100644 index 0000000..167f663 --- /dev/null +++ b/terraform.log @@ -0,0 +1,184 @@ +2023-06-20T13:00:29.785+0800 [INFO] Terraform version: 1.2.9 +2023-06-20T13:00:29.785+0800 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0 +2023-06-20T13:00:29.785+0800 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0 +2023-06-20T13:00:29.785+0800 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 +2023-06-20T13:00:29.785+0800 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 +2023-06-20T13:00:29.785+0800 [DEBUG] using github.com/zclconf/go-cty v1.11.0 +2023-06-20T13:00:29.785+0800 [INFO] Go runtime version: go1.18.1 +2023-06-20T13:00:29.785+0800 [INFO] CLI args: []string{"terraform", "refresh"} +2023-06-20T13:00:29.785+0800 [TRACE] Stdout is a terminal of width 128 +2023-06-20T13:00:29.786+0800 [TRACE] Stderr is a terminal of width 128 +2023-06-20T13:00:29.786+0800 [TRACE] Stdin is a terminal +2023-06-20T13:00:29.786+0800 [DEBUG] Attempting to open CLI config file: /Users/luoyin/dev.tfrc +2023-06-20T13:00:29.786+0800 [INFO] Loading CLI configuration from /Users/luoyin/dev.tfrc +2023-06-20T13:00:29.787+0800 [DEBUG] Not reading CLI config directory because config location is overridden by environment variable +2023-06-20T13:00:29.788+0800 [DEBUG] checking for credentials in "/Users/luoyin/.terraform.d/plugins" +2023-06-20T13:00:29.788+0800 [DEBUG] checking for credentials in "/Users/luoyin/.terraform.d/plugins/darwin_amd64" +2023-06-20T13:00:29.789+0800 [DEBUG] Explicit provider installation configuration is set +2023-06-20T13:00:29.789+0800 [TRACE] Selected provider installation method cliconfig.ProviderInstallationNetworkMirror("https://mirrors.tencent.com/terraform/") with includes [] and excludes [] +2023-06-20T13:00:29.789+0800 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [] +2023-06-20T13:00:29.791+0800 [INFO] CLI command args: []string{"refresh"} +2023-06-20T13:00:29.793+0800 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config +2023-06-20T13:00:29.793+0800 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory +2023-06-20T13:00:29.794+0800 [DEBUG] New state was assigned lineage "1410a536-5e2e-93bc-11fa-f12b9219c1fa" +2023-06-20T13:00:29.794+0800 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend) +2023-06-20T13:00:29.794+0800 [TRACE] Meta.Backend: instantiated backend of type +2023-06-20T13:00:29.794+0800 [DEBUG] Provider registry.terraform.io/tencentcloudstack/tencentcloud is overridden by dev_overrides +2023-06-20T13:00:29.794+0800 [DEBUG] Provider registry.terraform.io/tencentcloudstack/tencentcloud is overridden to load from /Users/luoyin/Code/terraform-provider-tencentcloud +2023-06-20T13:00:29.794+0800 [DEBUG] checking for provisioner in "." +2023-06-20T13:00:29.895+0800 [DEBUG] checking for provisioner in "/usr/local/bin" +2023-06-20T13:00:29.895+0800 [DEBUG] checking for provisioner in "/Users/luoyin/.terraform.d/plugins" +2023-06-20T13:00:29.895+0800 [DEBUG] checking for provisioner in "/Users/luoyin/.terraform.d/plugins/darwin_amd64" +2023-06-20T13:00:29.895+0800 [TRACE] Meta.Backend: backend does not support operations, so wrapping it in a local backend +2023-06-20T13:00:29.897+0800 [DEBUG] Provider registry.terraform.io/tencentcloudstack/tencentcloud is overridden by dev_overrides +2023-06-20T13:00:29.899+0800 [TRACE] backend/local: requesting state manager for workspace "default" +2023-06-20T13:00:29.901+0800 [TRACE] backend/local: state manager for workspace "default" will: + - read initial snapshot from terraform.tfstate + - write new snapshots to terraform.tfstate + - create any backup at terraform.tfstate.backup +2023-06-20T13:00:29.901+0800 [TRACE] backend/local: requesting state lock for workspace "default" +2023-06-20T13:00:29.905+0800 [TRACE] statemgr.Filesystem: preparing to manage state snapshots at terraform.tfstate +2023-06-20T13:00:29.905+0800 [TRACE] statemgr.Filesystem: no previously-stored snapshot exists +2023-06-20T13:00:29.905+0800 [TRACE] statemgr.Filesystem: locking terraform.tfstate using fcntl flock +2023-06-20T13:00:29.905+0800 [TRACE] statemgr.Filesystem: writing lock metadata to .terraform.tfstate.lock.info +2023-06-20T13:00:29.906+0800 [TRACE] backend/local: reading remote state for workspace "default" +2023-06-20T13:00:29.906+0800 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate +2023-06-20T13:00:29.906+0800 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay +2023-06-20T13:00:29.906+0800 [TRACE] statemgr.Filesystem: read nil snapshot +2023-06-20T13:00:29.906+0800 [TRACE] backend/local: populating backend.LocalRun for current working directory +2023-06-20T13:00:29.908+0800 [TRACE] terraform.NewContext: starting +2023-06-20T13:00:29.908+0800 [TRACE] terraform.NewContext: complete +2023-06-20T13:00:29.908+0800 [TRACE] backend/local: requesting interactive input, if necessary +2023-06-20T13:00:29.909+0800 [TRACE] Context.Input: Prompting for provider arguments +2023-06-20T13:00:29.909+0800 [TRACE] backend/local: running validation operation +2023-06-20T13:00:29.909+0800 [DEBUG] Building and walking validate graph +2023-06-20T13:00:29.909+0800 [TRACE] Executing graph transform *terraform.ConfigTransformer +2023-06-20T13:00:29.909+0800 [TRACE] ConfigTransformer: Starting for path: +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.ConfigTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.RootVariableTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.LocalTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.OutputTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.StateTransformer +2023-06-20T13:00:29.910+0800 [TRACE] StateTransformer: creating nodes for deposed instance objects only +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.StateTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.AttachStateTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.graphTransformerMulti +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer +2023-06-20T13:00:29.910+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.graphTransformerMulti (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.ReferenceTransformer +2023-06-20T13:00:29.910+0800 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes) +2023-06-20T13:00:29.910+0800 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes) +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes) +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.TargetsTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes) +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes) +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.CloseProviderTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.CloseProviderTransformer (no changes) +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph: + root - *terraform.nodeCloseModule + ------ +2023-06-20T13:00:29.911+0800 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer +2023-06-20T13:00:29.911+0800 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer (no changes) +2023-06-20T13:00:29.911+0800 [DEBUG] Starting graph walk: walkValidate +2023-06-20T13:00:29.912+0800 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule) +2023-06-20T13:00:29.912+0800 [TRACE] vertex "root": visit complete +2023-06-20T13:00:29.912+0800 [DEBUG] Refresh is really just plan now, so creating a NormalMode plan +2023-06-20T13:00:29.912+0800 [DEBUG] Building and walking plan graph for NormalMode +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.ConfigTransformer +2023-06-20T13:00:29.913+0800 [TRACE] ConfigTransformer: Starting for path: +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.ConfigTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.RootVariableTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.LocalTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.OutputTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.StateTransformer +2023-06-20T13:00:29.913+0800 [TRACE] StateTransformer: creating nodes for deposed instance objects only +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.StateTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.AttachStateTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.graphTransformerMulti +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer +2023-06-20T13:00:29.913+0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.graphTransformerMulti (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.ReferenceTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.TargetsTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.CloseProviderTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.CloseProviderTransformer (no changes) +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph: + root - *terraform.nodeCloseModule + ------ +2023-06-20T13:00:29.913+0800 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer +2023-06-20T13:00:29.913+0800 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer (no changes) +2023-06-20T13:00:29.913+0800 [DEBUG] Starting graph walk: walkPlan +2023-06-20T13:00:29.913+0800 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule) +2023-06-20T13:00:29.913+0800 [TRACE] vertex "root": visit complete +2023-06-20T13:00:29.913+0800 [DEBUG] no planned changes, skipping apply graph check +2023-06-20T13:00:29.913+0800 [INFO] backend/local: refresh calling Refresh +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: read nil snapshot +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: no original state snapshot to back up +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 1 +2023-06-20T13:00:29.913+0800 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate +2023-06-20T13:00:29.943+0800 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info +2023-06-20T13:00:29.944+0800 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock diff --git a/terraform.tfstate b/terraform.tfstate new file mode 100644 index 0000000..f10eabb --- /dev/null +++ b/terraform.tfstate @@ -0,0 +1,8 @@ +{ + "version": 4, + "terraform_version": "1.2.9", + "serial": 1, + "lineage": "1383ce09-0e23-874b-4a85-5e70c134da3b", + "outputs": {}, + "resources": [] +}