Skip to content

Commit 4df6c94

Browse files
committed
Implement custom ssh connector for the coder workspaces
1 parent e4bebd8 commit 4df6c94

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

src/main/kotlin/com/coder/gateway/CoderGatewayConnectionProvider.kt

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.coder.gateway
22

33
import com.coder.gateway.views.CoderGatewayConnectionComponent
4+
import com.intellij.openapi.rd.util.launchUnderBackgroundProgress
45
import com.intellij.remote.AuthType
56
import com.intellij.remote.RemoteCredentialsHolder
67
import com.intellij.ssh.config.unified.SshConfig
@@ -10,11 +11,12 @@ import com.jetbrains.gateway.api.GatewayConnectionProvider
1011
import com.jetbrains.gateway.ssh.IdeInfo
1112
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
1213
import com.jetbrains.gateway.ssh.SshCommandsExecutor
14+
import com.jetbrains.gateway.ssh.SshDeployFlowUtil
1315
import com.jetbrains.gateway.ssh.SshDownloadMethod
1416
import com.jetbrains.gateway.ssh.SshMultistagePanelContext
1517
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
1820
import java.util.logging.Logger
1921
import javax.swing.JComponent
2022

@@ -39,38 +41,35 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
3941
userName = "coder"
4042
authType = AuthType.OPEN_SSH
4143
}
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-
}
5544

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()
6868

69-
GlobalScope.launch {
70-
val cmdExecutor = SshCommandsExecutor.Companion.create(credentials)
71-
cmdExecutor.getInstalledIDEs()
69+
logger.info(">>>$deployPair")
7270
}
7371

72+
7473
return object : GatewayConnectionHandle(clientLifetime) {
7574
override fun createComponent(): JComponent {
7675
return CoderGatewayConnectionComponent(clientLifetime, coderUrl, workspaceName)

0 commit comments

Comments
 (0)