1
1
package com.coder.gateway
2
2
3
3
import com.coder.gateway.views.CoderGatewayConnectionComponent
4
+ import com.intellij.openapi.rd.util.launchUnderBackgroundProgress
4
5
import com.intellij.remote.AuthType
5
6
import com.intellij.remote.RemoteCredentialsHolder
6
7
import com.intellij.ssh.config.unified.SshConfig
@@ -10,11 +11,12 @@ import com.jetbrains.gateway.api.GatewayConnectionProvider
10
11
import com.jetbrains.gateway.ssh.IdeInfo
11
12
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
12
13
import com.jetbrains.gateway.ssh.SshCommandsExecutor
14
+ import com.jetbrains.gateway.ssh.SshDeployFlowUtil
13
15
import com.jetbrains.gateway.ssh.SshDownloadMethod
14
16
import com.jetbrains.gateway.ssh.SshMultistagePanelContext
15
17
import com.jetbrains.rd.util.lifetime.LifetimeDefinition
16
- import kotlinx.coroutines.GlobalScope
17
- import kotlinx.coroutines.launch
18
+ import kotlinx.coroutines.async
19
+ import java.time.Duration
18
20
import java.util.logging.Logger
19
21
import javax.swing.JComponent
20
22
@@ -39,38 +41,35 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
39
41
userName = " coder"
40
42
authType = AuthType .OPEN_SSH
41
43
}
42
- val context = SshMultistagePanelContext ().apply {
43
- deploy = true
44
- sshConfig = SshConfig (true ).apply {
45
- setHost(" coder.${workspaceName} " )
46
- setUsername(user)
47
- authType = AuthType .OPEN_SSH
48
- }
49
- downloadMethod = SshDownloadMethod .SftpUpload
50
- ide = IdeInfo (
51
- IntelliJPlatformProduct .IDEA ,
52
- buildNumber = " 221.5787.30"
53
- )
54
- }
55
44
56
- // GlobalScope.launch {
57
- // val deployPair = withContext(Dispatchers.IO) {
58
- // SshDeployFlowUtil.fullDeployCycle(
59
- // clientLifetime,
60
- // context,
61
- // Duration.ofMinutes(10)
62
- // )
63
- // }
64
- //
65
- //
66
- // println(deployPair)
67
- // }
45
+ clientLifetime.launchUnderBackgroundProgress(" Coder Gateway Deploy" , true , true , null ) {
46
+ val context = SshMultistagePanelContext ().apply {
47
+ deploy = true
48
+ sshConfig = SshConfig (true ).apply {
49
+ setHost(" coder.${workspaceName} " )
50
+ setUsername(user)
51
+ authType = AuthType .OPEN_SSH
52
+ }
53
+ remoteProjectPath = projectPath
54
+ remoteCommandsExecutor = SshCommandsExecutor .Companion .create(credentials)
55
+ downloadMethod = SshDownloadMethod .SftpUpload
56
+ ide = IdeInfo (
57
+ IntelliJPlatformProduct .IDEA ,
58
+ buildNumber = " 221.5787.30"
59
+ )
60
+ }
61
+ val deployPair = async {
62
+ SshDeployFlowUtil .fullDeployCycle(
63
+ clientLifetime,
64
+ context,
65
+ Duration .ofMinutes(10 )
66
+ )
67
+ }.await()
68
68
69
- GlobalScope .launch {
70
- val cmdExecutor = SshCommandsExecutor .Companion .create(credentials)
71
- cmdExecutor.getInstalledIDEs()
69
+ logger.info(" >>>$deployPair " )
72
70
}
73
71
72
+
74
73
return object : GatewayConnectionHandle (clientLifetime) {
75
74
override fun createComponent (): JComponent {
76
75
return CoderGatewayConnectionComponent (clientLifetime, coderUrl, workspaceName)
0 commit comments