Skip to content

Commit 714989c

Browse files
committed
Impl: use agent's OS and Arch to determine the supported Jetbrains products
- the mechanism to determine the supported jetbrains products based on OS/Arch uses the os/arch properties from the agent data models. - if that is missing we fall back on the old way which opens an SSH connection and runs a few unix commands to determine the properties.
1 parent bdae6e4 commit 714989c

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package com.coder.gateway.views.steps
33
import com.coder.gateway.CoderGatewayBundle
44
import com.coder.gateway.icons.CoderIcons
55
import com.coder.gateway.models.CoderWorkspacesWizardModel
6+
import com.coder.gateway.sdk.Arch
67
import com.coder.gateway.sdk.CoderRestClientService
8+
import com.coder.gateway.sdk.OS
79
import com.coder.gateway.views.LazyBrowserLink
810
import com.intellij.ide.IdeBundle
911
import com.intellij.openapi.Disposable
@@ -25,6 +27,9 @@ import com.intellij.util.ui.JBFont
2527
import com.intellij.util.ui.UIUtil
2628
import com.jetbrains.gateway.api.GatewayUI
2729
import com.jetbrains.gateway.ssh.CachingProductsJsonWrapper
30+
import com.jetbrains.gateway.ssh.DeployTargetOS
31+
import com.jetbrains.gateway.ssh.DeployTargetOS.OSArch
32+
import com.jetbrains.gateway.ssh.DeployTargetOS.OSKind
2833
import com.jetbrains.gateway.ssh.IdeStatus
2934
import com.jetbrains.gateway.ssh.IdeWithStatus
3035
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
@@ -111,7 +116,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
111116

112117
cs.launch {
113118
logger.info("Retrieving available IDE's for ${selectedWorkspace.name} workspace...")
114-
val workspaceOS = withContext(Dispatchers.IO) {
119+
val workspaceOS = if (selectedWorkspace.agentOS != null && selectedWorkspace.agentArch != null) toDeployedOS(selectedWorkspace.agentOS, selectedWorkspace.agentArch) else withContext(Dispatchers.IO) {
115120
try {
116121
RemoteCredentialsHolder().apply {
117122
setHost("coder.${selectedWorkspace.name}")
@@ -149,6 +154,28 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
149154
}
150155
}
151156

157+
private fun toDeployedOS(os: OS, arch: Arch): DeployTargetOS {
158+
return when (os) {
159+
OS.LINUX -> when (arch) {
160+
Arch.AMD64 -> DeployTargetOS(OSKind.Linux, OSArch.X86_64)
161+
Arch.ARM64 -> DeployTargetOS(OSKind.Linux, OSArch.Aarch64)
162+
Arch.ARMV7 -> DeployTargetOS(OSKind.Linux, OSArch.Unknown)
163+
}
164+
165+
OS.WINDOWS -> when (arch) {
166+
Arch.AMD64 -> DeployTargetOS(OSKind.Windows, OSArch.X86_64)
167+
Arch.ARM64 -> DeployTargetOS(OSKind.Windows, OSArch.Aarch64)
168+
Arch.ARMV7 -> DeployTargetOS(OSKind.Windows, OSArch.Unknown)
169+
}
170+
171+
OS.MAC -> when (arch) {
172+
Arch.AMD64 -> DeployTargetOS(OSKind.MacOs, OSArch.X86_64)
173+
Arch.ARM64 -> DeployTargetOS(OSKind.MacOs, OSArch.Aarch64)
174+
Arch.ARMV7 -> DeployTargetOS(OSKind.MacOs, OSArch.Unknown)
175+
}
176+
}
177+
}
178+
152179
override fun onNext(wizardModel: CoderWorkspacesWizardModel): Boolean {
153180
val selectedIDE = cbIDE.selectedItem ?: return false
154181

0 commit comments

Comments
 (0)