feat: get default public key from vscode
This commit is contained in:
		@@ -570,7 +570,7 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
 | 
			
		||||
                    const devContainerUsername =  data.data.devContainerUsername
 | 
			
		||||
                    const devContainerPassword = data.data.devContainerPassword
 | 
			
		||||
                    const devContainerPort = data.data.devContainerPort
 | 
			
		||||
                    const devContainerWorkDir = `${data.data.devContainerWorkDir}/${devContainerUsername}`
 | 
			
		||||
                    const devContainerWorkDir = '/data/workspace'
 | 
			
		||||
 | 
			
		||||
                    // default: open with password
 | 
			
		||||
                    firstOpenRemoteFolder(devContainerHost, devContainerUsername, devContainerPassword, devContainerPort, devContainerWorkDir)
 | 
			
		||||
@@ -623,13 +623,18 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO: create container
 | 
			
		||||
        function createDevContainer(repoId) {
 | 
			
		||||
            return new Promise((resolve, reject) => {
 | 
			
		||||
        async function createDevContainer(repoId) {
 | 
			
		||||
            return new Promise(async (resolve, reject) => {
 | 
			
		||||
                // get public key
 | 
			
		||||
                const publicKey = await getDefaultPublicKeyFromVSCode()
 | 
			
		||||
 | 
			
		||||
                // request creating container
 | 
			
		||||
                const url = DEVSTAR_HOME + "/api/devcontainer"  
 | 
			
		||||
                var token = USERTOKEN
 | 
			
		||||
 | 
			
		||||
                const postData = {
 | 
			
		||||
                    "repoId": repoId.toString(),
 | 
			
		||||
                    "sshPublicKeyList": [publicKey]
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                fetch(url, {
 | 
			
		||||
@@ -663,6 +668,17 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
 | 
			
		||||
            })
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        async function getDefaultPublicKeyFromVSCode() {
 | 
			
		||||
            try {
 | 
			
		||||
                const data = await biCommunication2Webview('getDefaultPublicKey', null);
 | 
			
		||||
                const defaultPublicKey = data.defaultPublicKey;
 | 
			
		||||
 | 
			
		||||
                return defaultPublicKey;
 | 
			
		||||
            } catch (error) {
 | 
			
		||||
                console.log("Failed to get default public key: ", error)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO: delete container
 | 
			
		||||
        function deleteDevContainer(repoId) {
 | 
			
		||||
            return new Promise((resolve, reject) => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user