@@ -9,6 +9,8 @@ import { executeCommand } from "./cpUtils";
99import { BaseRunner } from "./baseRunner" ;
1010import { openUrlHintOrNotShowAgain } from "./uiUtils" ;
1111
12+ export const defaultProduct = [ "vpc" , "subnet" , "security_group" ] ;
13+
1214export enum CommandType {
1315 Import = "import tencentcloud" ,
1416 Plan = "plan tencentcloud" ,
@@ -34,6 +36,7 @@ export interface FlagsMap {
3436}
3537
3638export class TerraformerRunner extends BaseRunner {
39+ static defaultProduct : any ;
3740 private constructor ( ) {
3841 super ( ) ;
3942 }
@@ -48,34 +51,26 @@ export class TerraformerRunner extends BaseRunner {
4851 }
4952
5053 public init ( ) : void {
51- throw new Error ( "Method not implemented." ) ;
54+ // throw new Error("Method not implemented.");
5255 }
5356
5457
5558 public async preImport ( cwd : string , args ?: any , path ?: string ) : Promise < any > {
56- await executeCommand (
59+ console . debug ( "[DEBUG]#### TerraformerRunner.preImport begin, cwd:[%s], args:[%s], path:[%s]" , cwd , args , path ) ;
60+ return await executeCommand (
5761 "terraform" ,
5862 [ "init" , "-upgrade" ] ,
5963 {
6064 shell : true ,
6165 cwd,
6266 } ,
6367 ) ;
64-
65-
66- // return await executeCommand(
67- // "terraformer",
68- // exeArgs,
69- // {
70- // shell: true,
71- // cwd,
72- // }
73- // );
7468 }
7569
7670 public async executeImport ( cwd : string , args ?: string , cmd ?: CommandType , flags ?: FlagsMap [ ] ) : Promise < string > {
71+ console . debug ( "[DEBUG]#### TerraformerRunner.executeImport begin, cwd:[%s], args:[%s], cmd:[%s], flags:[%s]" , cwd , args , cmd . toString ( ) , flags . toString ( ) ) ;
7772 const exeArgs : string [ ] = [ ] ;
78- if ( args ) {
73+ if ( args ) {
7974 exeArgs . push ( args ) ;
8075 }
8176
@@ -85,13 +80,13 @@ export class TerraformerRunner extends BaseRunner {
8580
8681 if ( flags ) {
8782 flags . forEach ( ( vv ) => {
88- exeArgs . push ( vv . flag . toString ( ) , " " , vv . value ) ;
83+ exeArgs . push ( vv . flag . toString ( ) , vv . value ) ;
8984 } ) ;
9085 }
9186
9287 const opExeArgs : string = exeArgs . join ( " " ) ;
9388
94- console . debug ( "[DEBUG]#### import opExeArgs :[%s]" , "terraformer" + opExeArgs ) ;
89+ console . debug ( "[DEBUG]#### import exeArgs :[%s]" , opExeArgs ) ;
9590
9691 return await executeCommand (
9792 "terraformer" ,
@@ -104,11 +99,21 @@ export class TerraformerRunner extends BaseRunner {
10499 }
105100
106101 public async postImport ( cwd : string , args ?: string ) : Promise < any > {
107- throw new Error ( "Method not implemented." ) ;
102+ console . debug ( "[DEBUG]#### TerraformerRunner.postImport begin, cwd:[%s], args:[%s]" , cwd , args ) ;
103+ const exeArgs = args . split ( "," ) ;
104+
105+ return await executeCommand (
106+ "terraformer" ,
107+ exeArgs ,
108+ {
109+ shell : true ,
110+ cwd,
111+ }
112+ ) ;
108113 }
109114
110115 public async executeShow ( cwd : string , args ?: string ) : Promise < string > {
111- console . debug ( "[DEBUG]#### terraformer not need this step, skip it." ) ;
116+ console . debug ( "[DEBUG]#### TerraformerRunner not need this step, skip it." ) ;
112117 return "" ;
113118 }
114119
0 commit comments