Skip to content

Impl support for multi agent workspaces #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Impl: use agent's OS and Arch to determine the supported Jetbrains pr…
…oducts

- 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.
  • Loading branch information
fioan89 committed Jun 28, 2022
commit 714989c2296175a7a5a460348f5bb7e26523c4ee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.coder.gateway.views.steps
import com.coder.gateway.CoderGatewayBundle
import com.coder.gateway.icons.CoderIcons
import com.coder.gateway.models.CoderWorkspacesWizardModel
import com.coder.gateway.sdk.Arch
import com.coder.gateway.sdk.CoderRestClientService
import com.coder.gateway.sdk.OS
import com.coder.gateway.views.LazyBrowserLink
import com.intellij.ide.IdeBundle
import com.intellij.openapi.Disposable
Expand All @@ -25,6 +27,9 @@ import com.intellij.util.ui.JBFont
import com.intellij.util.ui.UIUtil
import com.jetbrains.gateway.api.GatewayUI
import com.jetbrains.gateway.ssh.CachingProductsJsonWrapper
import com.jetbrains.gateway.ssh.DeployTargetOS
import com.jetbrains.gateway.ssh.DeployTargetOS.OSArch
import com.jetbrains.gateway.ssh.DeployTargetOS.OSKind
import com.jetbrains.gateway.ssh.IdeStatus
import com.jetbrains.gateway.ssh.IdeWithStatus
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
Expand Down Expand Up @@ -111,7 +116,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit

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

private fun toDeployedOS(os: OS, arch: Arch): DeployTargetOS {
return when (os) {
OS.LINUX -> when (arch) {
Arch.AMD64 -> DeployTargetOS(OSKind.Linux, OSArch.X86_64)
Arch.ARM64 -> DeployTargetOS(OSKind.Linux, OSArch.Aarch64)
Arch.ARMV7 -> DeployTargetOS(OSKind.Linux, OSArch.Unknown)
}

OS.WINDOWS -> when (arch) {
Arch.AMD64 -> DeployTargetOS(OSKind.Windows, OSArch.X86_64)
Arch.ARM64 -> DeployTargetOS(OSKind.Windows, OSArch.Aarch64)
Arch.ARMV7 -> DeployTargetOS(OSKind.Windows, OSArch.Unknown)
}

OS.MAC -> when (arch) {
Arch.AMD64 -> DeployTargetOS(OSKind.MacOs, OSArch.X86_64)
Arch.ARM64 -> DeployTargetOS(OSKind.MacOs, OSArch.Aarch64)
Arch.ARMV7 -> DeployTargetOS(OSKind.MacOs, OSArch.Unknown)
}
}
}

override fun onNext(wizardModel: CoderWorkspacesWizardModel): Boolean {
val selectedIDE = cbIDE.selectedItem ?: return false

Expand Down