Skip to content

Commit 5cabda7

Browse files
authored
Merge pull request #34 from coder/impl-support-gw-2022
Upgrade GW platform to latest EAP, i.e 2022.x also increase the major version due to backward incompatible changes introduced by the new GW platform (see semver for how to increase the version)
2 parents 40949e8 + 263bce2 commit 5cabda7

File tree

7 files changed

+76
-63
lines changed

7 files changed

+76
-63
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: actions/setup-java@v3
4747
with:
4848
distribution: zulu
49-
java-version: 11
49+
java-version: 17
5050
cache: gradle
5151

5252
# Set environment variables

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
with:
2020
ref: ${{ github.event.release.tag_name }}
2121

22-
# Setup Java 11 environment for the next steps
22+
# Setup Java 17 environment for the next steps
2323
- name: Setup Java
2424
uses: actions/setup-java@v2
2525
with:
2626
distribution: zulu
27-
java-version: 11
27+
java-version: 17
2828
cache: gradle
2929

3030
# Set environment variables

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
## [Unreleased]
66
### Added
7+
- support for Gateway 2022.2
8+
9+
### Changed
10+
- Java 17 is now required to run the plugin
11+
- adapted the code to the new SSH API provided by Gateway
12+
13+
## [1.0.0]
14+
### Added
715
- initial scaffold for Gateway plugin
816
- browser based authentication on Coder environments
917
- REST client for Coder V2 public API

build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ tasks {
9292
compilerVersion.set(properties("instrumentationCompiler"))
9393
}
9494

95+
// TODO - this fails with linkage error, remove when it works
96+
buildSearchableOptions {
97+
isEnabled = false
98+
}
99+
95100
patchPluginXml {
96101
version.set(properties("pluginVersion"))
97102
sinceBuild.set(properties("pluginSinceBuild"))

gradle.properties

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
pluginGroup=com.coder.gateway
44
pluginName=coder-gateway
55
# SemVer format -> https://semver.org
6-
pluginVersion=1.0.0
6+
pluginVersion=2.0.0
77
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
88
# for insight into build numbers and IntelliJ Platform versions.
9-
pluginSinceBuild=213
10-
pluginUntilBuild=221.*
9+
pluginSinceBuild=222.3345.108
10+
pluginUntilBuild=222.*
1111
# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
1212
# Gateway available build versions https://www.jetbrains.com/intellij-repository/snapshots and https://www.jetbrains.com/intellij-repository/releases
1313
platformType=GW
14-
platformVersion=221.5921.22-CUSTOM-SNAPSHOT
15-
instrumentationCompiler=221.5921.22
14+
platformVersion=222.3345.108-CUSTOM-SNAPSHOT
15+
instrumentationCompiler=222.3345.108-CUSTOM-SNAPSHOT
1616
platformDownloadSources=true
1717
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
1818
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
1919
platformPlugins=
20-
# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
21-
javaVersion=11
20+
# Java language level used to compile sources and to generate the files for - Java 17 is required since 2022.2
21+
javaVersion=17
2222
# Gradle Releases -> https://github.com/gradle/gradle/releases
2323
gradleVersion=7.4
2424
# Opt-out flag for bundling Kotlin standard library.

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

+37-42
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,34 @@ package com.coder.gateway
44

55
import com.coder.gateway.models.RecentWorkspaceConnection
66
import com.coder.gateway.services.CoderRecentWorkspaceConnectionsService
7-
import com.coder.gateway.views.CoderGatewayConnectionComponent
87
import com.intellij.openapi.components.service
98
import com.intellij.openapi.diagnostic.Logger
109
import com.intellij.openapi.rd.util.launchUnderBackgroundProgress
1110
import com.intellij.remote.AuthType
1211
import com.intellij.remote.RemoteCredentialsHolder
1312
import com.intellij.ssh.config.unified.SshConfig
13+
import com.intellij.ssh.config.unified.SshConfigManager
1414
import com.jetbrains.gateway.api.ConnectionRequestor
1515
import com.jetbrains.gateway.api.GatewayConnectionHandle
1616
import com.jetbrains.gateway.api.GatewayConnectionProvider
17+
import com.jetbrains.gateway.ssh.HighLevelHostAccessor
18+
import com.jetbrains.gateway.ssh.HostDeployInputs
1719
import com.jetbrains.gateway.ssh.IdeInfo
1820
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
19-
import com.jetbrains.gateway.ssh.SshCommandsExecutor
2021
import com.jetbrains.gateway.ssh.SshDeployFlowUtil
21-
import com.jetbrains.gateway.ssh.SshDownloadMethod
2222
import com.jetbrains.gateway.ssh.SshMultistagePanelContext
23+
import com.jetbrains.gateway.ssh.deploy.DeployTargetInfo.DeployWithDownload
2324
import com.jetbrains.rd.util.lifetime.LifetimeDefinition
2425
import kotlinx.coroutines.launch
26+
import java.net.URI
2527
import java.time.Duration
2628
import java.time.LocalDateTime
2729
import java.time.format.DateTimeFormatter
28-
import javax.swing.JComponent
2930

3031
class CoderGatewayConnectionProvider : GatewayConnectionProvider {
3132
private val recentConnectionsService = service<CoderRecentWorkspaceConnectionsService>()
33+
private val sshConfigService = service<SshConfigManager>()
34+
3235
private val connections = mutableSetOf<CoderConnectionMetadata>()
3336
private val localTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm")
3437

@@ -46,62 +49,54 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
4649
logger.warn("There is already a connection started on ${connection.workspaceHostname}")
4750
return null
4851
}
49-
val clientLifetime = LifetimeDefinition()
50-
51-
val credentials = RemoteCredentialsHolder().apply {
52-
setHost(coderWorkspaceHostname)
53-
userName = "coder"
54-
authType = AuthType.OPEN_SSH
55-
}
56-
5752
val sshConfiguration = SshConfig(true).apply {
5853
setHost(coderWorkspaceHostname)
5954
setUsername("coder")
55+
port = 22
6056
authType = AuthType.OPEN_SSH
6157
}
6258

63-
val ideConfig = IdeInfo(
64-
product = IntelliJPlatformProduct.fromProductCode(ideProductCode)!!,
65-
buildNumber = ideBuildNumber
66-
)
67-
59+
val clientLifetime = LifetimeDefinition()
6860
clientLifetime.launchUnderBackgroundProgress("Coder Gateway Deploy", canBeCancelled = true, isIndeterminate = true, project = null) {
69-
val context = SshMultistagePanelContext().apply {
70-
deploy = true
71-
sshConfig = sshConfiguration
72-
remoteProjectPath = projectPath
73-
remoteCommandsExecutor = SshCommandsExecutor.Companion.create(credentials)
74-
downloadMethod = SshDownloadMethod.CustomizedLink
75-
customDownloadLink = ideDownloadLink
76-
ide = ideConfig
77-
}
61+
val context = SshMultistagePanelContext(
62+
HostDeployInputs.FullySpecified(
63+
remoteProjectPath = projectPath,
64+
deployTarget = DeployWithDownload(
65+
URI(ideDownloadLink),
66+
null,
67+
IdeInfo(
68+
product = IntelliJPlatformProduct.fromProductCode(ideProductCode)!!,
69+
buildNumber = ideBuildNumber
70+
)
71+
),
72+
remoteInfo = HostDeployInputs.WithDeployedWorker(
73+
HighLevelHostAccessor.create(
74+
RemoteCredentialsHolder().apply {
75+
setHost(coderWorkspaceHostname)
76+
userName = "coder"
77+
port = 22
78+
authType = AuthType.OPEN_SSH
79+
},
80+
true
81+
),
82+
HostDeployInputs.WithHostInfo(sshConfiguration)
83+
)
84+
)
85+
)
7886
launch {
79-
@Suppress("UnstableApiUsage")
80-
SshDeployFlowUtil.fullDeployCycle(
81-
clientLifetime,
82-
context,
83-
Duration.ofMinutes(10)
87+
@Suppress("UnstableApiUsage") SshDeployFlowUtil.fullDeployCycle(
88+
clientLifetime, context, Duration.ofMinutes(10)
8489
)
8590
}
8691
}
8792

8893
recentConnectionsService.addRecentConnection(
8994
RecentWorkspaceConnection(
90-
coderWorkspaceHostname,
91-
projectPath,
92-
localTimeFormatter.format(LocalDateTime.now()),
93-
ideProductCode,
94-
ideBuildNumber,
95-
ideDownloadLink,
96-
webTerminalLink,
95+
coderWorkspaceHostname, projectPath, localTimeFormatter.format(LocalDateTime.now()), ideProductCode, ideBuildNumber, ideDownloadLink, webTerminalLink
9796
)
9897
)
9998

10099
return object : GatewayConnectionHandle(clientLifetime) {
101-
override fun createComponent(): JComponent {
102-
return CoderGatewayConnectionComponent(clientLifetime, coderWorkspaceHostname)
103-
}
104-
105100
override fun getTitle(): String {
106101
return "Connection to Coder Workspaces"
107102
}

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

+16-11
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ import com.jetbrains.gateway.ssh.CachingProductsJsonWrapper
3030
import com.jetbrains.gateway.ssh.DeployTargetOS
3131
import com.jetbrains.gateway.ssh.DeployTargetOS.OSArch
3232
import com.jetbrains.gateway.ssh.DeployTargetOS.OSKind
33+
import com.jetbrains.gateway.ssh.HighLevelHostAccessor
3334
import com.jetbrains.gateway.ssh.IdeStatus
3435
import com.jetbrains.gateway.ssh.IdeWithStatus
3536
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
36-
import com.jetbrains.gateway.ssh.guessOs
37+
import com.jetbrains.gateway.ssh.deploy.guessOs
3738
import kotlinx.coroutines.CoroutineScope
3839
import kotlinx.coroutines.Dispatchers
3940
import kotlinx.coroutines.cancel
@@ -116,11 +117,15 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
116117
logger.info("Retrieving available IDE's for ${selectedWorkspace.name} workspace...")
117118
val workspaceOS = if (selectedWorkspace.agentOS != null && selectedWorkspace.agentArch != null) withContext(Dispatchers.IO) { toDeployedOS(selectedWorkspace.agentOS, selectedWorkspace.agentArch) } else withContext(Dispatchers.IO) {
118119
try {
119-
RemoteCredentialsHolder().apply {
120+
val credentialsHolder = RemoteCredentialsHolder().apply {
120121
setHost("coder.${selectedWorkspace.name}")
121122
userName = "coder"
122123
authType = AuthType.OPEN_SSH
123-
}.guessOs
124+
}
125+
HighLevelHostAccessor.create(
126+
credentialsHolder,
127+
true
128+
).hostCommandExecutor.guessOs()
124129
} catch (e: Exception) {
125130
logger.error("Could not resolve any IDE for workspace ${selectedWorkspace.name}. Reason: $e")
126131
null
@@ -141,7 +146,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
141146
IntelliJPlatformProduct.values()
142147
.filter { it.showInGateway }
143148
.flatMap { CachingProductsJsonWrapper.getAvailableIdes(it, workspaceOS) }
144-
.map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.DOWNLOAD, ide.downloadLink, ide.presentableVersion) }
149+
.map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.DOWNLOAD, ide.download, null, ide.presentableVersion) }
145150
}
146151

147152
if (idesWithStatus.isEmpty()) {
@@ -158,20 +163,20 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
158163
return when (os) {
159164
OS.LINUX -> when (arch) {
160165
Arch.AMD64 -> DeployTargetOS(OSKind.Linux, OSArch.X86_64)
161-
Arch.ARM64 -> DeployTargetOS(OSKind.Linux, OSArch.Aarch64)
162-
Arch.ARMV7 -> DeployTargetOS(OSKind.Linux, OSArch.Unknown)
166+
Arch.ARM64 -> DeployTargetOS(OSKind.Linux, OSArch.ARM_64)
167+
Arch.ARMV7 -> DeployTargetOS(OSKind.Linux, OSArch.UNKNOWN)
163168
}
164169

165170
OS.WINDOWS -> when (arch) {
166171
Arch.AMD64 -> DeployTargetOS(OSKind.Windows, OSArch.X86_64)
167-
Arch.ARM64 -> DeployTargetOS(OSKind.Windows, OSArch.Aarch64)
168-
Arch.ARMV7 -> DeployTargetOS(OSKind.Windows, OSArch.Unknown)
172+
Arch.ARM64 -> DeployTargetOS(OSKind.Windows, OSArch.ARM_64)
173+
Arch.ARMV7 -> DeployTargetOS(OSKind.Windows, OSArch.UNKNOWN)
169174
}
170175

171176
OS.MAC -> when (arch) {
172177
Arch.AMD64 -> DeployTargetOS(OSKind.MacOs, OSArch.X86_64)
173-
Arch.ARM64 -> DeployTargetOS(OSKind.MacOs, OSArch.Aarch64)
174-
Arch.ARMV7 -> DeployTargetOS(OSKind.MacOs, OSArch.Unknown)
178+
Arch.ARM64 -> DeployTargetOS(OSKind.MacOs, OSArch.ARM_64)
179+
Arch.ARMV7 -> DeployTargetOS(OSKind.MacOs, OSArch.UNKNOWN)
175180
}
176181
}
177182
}
@@ -187,7 +192,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
187192
"project_path" to tfProject.text,
188193
"ide_product_code" to selectedIDE.product.productCode,
189194
"ide_build_number" to selectedIDE.buildNumber,
190-
"ide_download_link" to selectedIDE.source,
195+
"ide_download_link" to selectedIDE.download!!.link,
191196
"web_terminal_link" to "${terminalLink.url}"
192197
)
193198
)

0 commit comments

Comments
 (0)