@@ -99,7 +99,7 @@ export default class ClusterViewLoader {
9999 @vsCommand ( 'openshift.explorer.addCluster.crcSetup' )
100100 static async crcSetup ( event : any ) {
101101 const terminal : vscode . Terminal = WindowUtil . createTerminal ( 'OpenShift: CRC Setup' , undefined ) ;
102- terminal . sendText ( `${ event . data } setup` ) ;
102+ terminal . sendText ( `" ${ event . data . tool } " setup` ) ;
103103 terminal . show ( ) ;
104104 }
105105
@@ -112,13 +112,15 @@ export default class ClusterViewLoader {
112112 const pullSecretFromSetting = vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get ( 'crcPullSecretPath' ) ;
113113 const cpuFromSetting = vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get ( 'crcCpuCores' ) ;
114114 const memoryFromSetting = vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get ( 'crcMemoryAllocated' ) ;
115- const crcOptions = [ 'start' , '-p' , `${ pullSecretFromSetting } ` , '-c' , `${ cpuFromSetting } ` , '-m' , `${ memoryFromSetting } ` , '-ojson' ] ;
115+ const nameserver = vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get < string > ( 'crcNameserver' ) ;
116+ const nameserverOption = nameserver ? [ '-n' , nameserver ] : [ ] ;
117+ const crcOptions = [ 'start' , '-p' , `${ pullSecretFromSetting } ` , '-c' , `${ cpuFromSetting } ` , '-m' , `${ memoryFromSetting } ` , ...nameserverOption , '-o json' ] ;
118+
116119 startProcess = spawn ( `${ binaryFromSetting } ` , crcOptions ) ;
117- channel . append ( `\n\n${ binaryFromSetting } ${ crcOptions . join ( ' ' ) } \n` ) ;
120+ channel . append ( `\n\n" ${ binaryFromSetting } " ${ crcOptions . join ( ' ' ) } \n` ) ;
118121 } else {
119- const [ tool , ...params ] = event . data . split ( ' ' ) ;
120- startProcess = spawn ( tool , params ) ;
121- channel . append ( `\n\n${ tool } ${ params . join ( ' ' ) } \n` ) ;
122+ startProcess = spawn ( `${ event . data . tool } ` , event . data . options . split ( ' ' ) ) ;
123+ channel . append ( `\n\n"${ event . data . tool } " ${ event . data . options } \n` ) ;
122124 }
123125 startProcess . stdout . setEncoding ( 'utf8' ) ;
124126 startProcess . stderr . setEncoding ( 'utf8' ) ;
@@ -137,32 +139,42 @@ export default class ClusterViewLoader {
137139 const binaryLoc = event . isSetting ? vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get ( 'crcBinaryLocation' ) : event . crcLoc ;
138140 ClusterViewLoader . checkCrcStatus ( binaryLoc , 'crcstartstatus' , panel ) ;
139141 } ) ;
142+ startProcess . on ( 'error' , ( err ) => {
143+ console . log ( err ) ;
144+ } ) ;
140145 }
141146
142147 @vsCommand ( 'openshift.explorer.addCluster.crcStop' )
143148 static async crcStop ( event ) {
144149 let filePath : string ;
145150 channel . show ( ) ;
146- if ( event . data === '' ) {
151+ if ( event . data . tool === '' ) {
147152 filePath = vscode . workspace . getConfiguration ( 'openshiftConnector' ) . get ( 'crcBinaryLocation' ) ;
148153 } else {
149- filePath = event . data ;
154+ filePath = event . data . tool ;
155+ }
156+ try {
157+ const stopProcess = spawn ( `${ filePath } ` , [ 'stop' ] ) ;
158+ channel . append ( `\n\n"${ filePath } " stop\n` ) ;
159+ stopProcess . stdout . setEncoding ( 'utf8' ) ;
160+ stopProcess . stderr . setEncoding ( 'utf8' ) ;
161+ stopProcess . stdout . on ( 'data' , ( chunk ) => {
162+ channel . append ( chunk ) ;
163+ } ) ;
164+ stopProcess . stderr . on ( 'data' , ( chunk ) => {
165+ channel . append ( chunk ) ;
166+ } ) ;
167+ stopProcess . on ( 'close' , ( code ) => {
168+ // eslint-disable-next-line no-console
169+ console . log ( `crc stop exited with code ${ code } ` ) ;
170+ ClusterViewLoader . checkCrcStatus ( filePath , 'crcstopstatus' , panel ) ;
171+ } ) ;
172+ stopProcess . on ( 'error' , ( err ) => {
173+ console . log ( err ) ;
174+ } ) ;
175+ } catch ( err ) {
176+ console . log ( err ) ;
150177 }
151- const stopProcess = spawn ( `${ filePath } ` , [ 'stop' ] ) ;
152- channel . append ( `\n\n$${ filePath } stop\n` ) ;
153- stopProcess . stdout . setEncoding ( 'utf8' ) ;
154- stopProcess . stderr . setEncoding ( 'utf8' ) ;
155- stopProcess . stdout . on ( 'data' , ( chunk ) => {
156- channel . append ( chunk ) ;
157- } ) ;
158- stopProcess . stderr . on ( 'data' , ( chunk ) => {
159- channel . append ( chunk ) ;
160- } ) ;
161- stopProcess . on ( 'close' , ( code ) => {
162- // eslint-disable-next-line no-console
163- console . log ( `crc stop exited with code ${ code } ` ) ;
164- ClusterViewLoader . checkCrcStatus ( filePath , 'crcstopstatus' , panel ) ;
165- } ) ;
166178 }
167179
168180 static async crcSaveSettings ( event ) {
@@ -199,11 +211,11 @@ export default class ClusterViewLoader {
199211
200212 public static async checkCrcStatus ( filePath : string , postCommand : string , p : vscode . WebviewPanel | undefined = undefined ) {
201213 const crcCredArray = [ ] ;
202- const crcVerInfo = await CliChannel . getInstance ( ) . execute ( `${ filePath } version -ojson ` ) ;
203- channel . append ( `\n\n${ filePath } version -ojson \n` ) ;
214+ const crcVerInfo = await CliChannel . getInstance ( ) . execute ( `" ${ filePath } " version -o json ` ) ;
215+ channel . append ( `\n\n" ${ filePath } " version -o json \n` ) ;
204216 channel . append ( crcVerInfo . stdout ) ;
205- const result = await CliChannel . getInstance ( ) . execute ( `${ filePath } status -ojson ` ) ;
206- channel . append ( `\n\n${ filePath } status -ojson \n` ) ;
217+ const result = await CliChannel . getInstance ( ) . execute ( `" ${ filePath } " status -o json ` ) ;
218+ channel . append ( `\n\n" ${ filePath } " status -o json \n` ) ;
207219 channel . append ( result . stdout ) ;
208220 if ( result . error || crcVerInfo . error ) {
209221 p . webview . postMessage ( { action : postCommand , errorStatus : true } ) ;
@@ -216,7 +228,7 @@ export default class ClusterViewLoader {
216228 creds : crcCredArray
217229 } ) ;
218230 }
219- const crcCreds = await CliChannel . getInstance ( ) . execute ( `${ filePath } console --credentials -ojson ` ) ;
231+ const crcCreds = await CliChannel . getInstance ( ) . execute ( `" ${ filePath } " console --credentials -o json ` ) ;
220232 if ( ! crcCreds . error ) {
221233 try {
222234 crcCredArray . push ( JSON . parse ( crcCreds . stdout ) . clusterConfig ) ;
0 commit comments