(uri: Uri)
| 16 | }; |
| 17 | |
| 18 | export async function handleOpenInVSCode(uri: Uri) { |
| 19 | const queryParams = new URLSearchParams(uri.query); |
| 20 | |
| 21 | if (queryParams.has('vm_id') && queryParams.has('token')) { |
| 22 | //Not yet supported for windows + WSL - will be added in future |
| 23 | if (os.platform() !== 'win32') { |
| 24 | window.showInformationMessage('Setting up devbox'); |
| 25 | // getting ssh keys |
| 26 | try { |
| 27 | console.debug('Calling getVMInfo...'); |
| 28 | const response = await getVMInfo(queryParams.get('token'), queryParams.get('vm_id')); |
| 29 | const res = await response.json() as VmInfo; |
| 30 | console.debug('getVMInfo response: ' + res); |
| 31 | // set ssh config |
| 32 | console.debug('Calling setupSSHConfig...'); |
| 33 | await setupSSHConfig(res.vm_id, res.private_key); |
| 34 | |
| 35 | // connect to remote vm |
| 36 | console.debug('Calling connectToRemote...'); |
| 37 | connectToRemote(res.username, res.vm_id, res.working_directory); |
| 38 | } catch (err: any) { |
| 39 | console.error(err); |
| 40 | window.showInformationMessage('Failed to setup devbox remote connection.'); |
| 41 | } |
| 42 | } else { |
| 43 | window.showErrorMessage('This function is not yet supported in Windows operating system.'); |
| 44 | } |
| 45 | } else { |
| 46 | window.showErrorMessage('Error parsing information for remote environment.'); |
| 47 | console.debug(queryParams.toString()); |
| 48 | }; |
| 49 | } |
| 50 | |
| 51 | async function getVMInfo(token: string | null, vmId: string | null): Promise<any> { |
| 52 | // send post request to gateway to get vm info and ssh keys |
nothing calls this directly
no test coverage detected