From b67f4525b371918412fa20579b1a073da35e0dc8 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 14:08:25 +0300 Subject: [PATCH 01/11] Add REST models for Workspace agents --- .../gateway/sdk/v2/models/WorkspaceAgent.kt | 24 +++++++++++++++++++ .../gateway/sdk/v2/models/WorkspaceApp.kt | 11 +++++++++ .../sdk/v2/models/WorkspaceResource.kt | 15 ++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt create mode 100644 src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceApp.kt create mode 100644 src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceResource.kt diff --git a/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt new file mode 100644 index 00000000..18ed6777 --- /dev/null +++ b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceAgent.kt @@ -0,0 +1,24 @@ +package com.coder.gateway.sdk.v2.models + +import com.google.gson.annotations.SerializedName +import java.time.Instant +import java.util.UUID + +data class WorkspaceAgent( + @SerializedName("id") val id: UUID, + @SerializedName("created_at") val createdAt: Instant, + @SerializedName("updated_at") val updatedAt: Instant, + @SerializedName("first_connected_at") val firstConnectedAt: Instant?, + @SerializedName("last_connected_at") val lastConnectedAt: Instant?, + @SerializedName("disconnected_at") val disconnectedAt: Instant?, + @SerializedName("status") val status: String, + @SerializedName("name") val name: String, + @SerializedName("resource_id") val resourceID: UUID, + @SerializedName("instance_id") val instanceID: String, + @SerializedName("architecture") val architecture: String, + @SerializedName("environment_variables") val envVariables: Map<String, String>, + @SerializedName("operating_system") val operatingSystem: String, + @SerializedName("startup_script") val startupScript: String, + @SerializedName("directory") val directory: String, + @SerializedName("apps") val apps: List<WorkspaceApp> +) \ No newline at end of file diff --git a/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceApp.kt b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceApp.kt new file mode 100644 index 00000000..736dd813 --- /dev/null +++ b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceApp.kt @@ -0,0 +1,11 @@ +package com.coder.gateway.sdk.v2.models + +import com.google.gson.annotations.SerializedName +import java.util.UUID + +data class WorkspaceApp( + @SerializedName("id") val id: UUID, + @SerializedName("name") val name: String, + @SerializedName("command") val command: String?, + @SerializedName("icon") val icon: String?, +) diff --git a/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceResource.kt b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceResource.kt new file mode 100644 index 00000000..8b993232 --- /dev/null +++ b/src/main/kotlin/com/coder/gateway/sdk/v2/models/WorkspaceResource.kt @@ -0,0 +1,15 @@ +package com.coder.gateway.sdk.v2.models + +import com.google.gson.annotations.SerializedName +import java.time.Instant +import java.util.UUID + +data class WorkspaceResource( + @SerializedName("id") val id: UUID, + @SerializedName("created_at") val createdAt: Instant, + @SerializedName("job_id") val jobID: UUID, + @SerializedName("workspace_transition") val workspaceTransition: String, + @SerializedName("type") val type: String, + @SerializedName("name") val name: String, + @SerializedName("agents") val agents: List<WorkspaceAgent>? +) From 50a5e0e822a96bc504121664ef70dab3e3c011d8 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 14:36:17 +0300 Subject: [PATCH 02/11] Impl: REST call to retrieve the workspace resources --- .../com/coder/gateway/sdk/CoderRestClientService.kt | 10 ++++++++++ .../com/coder/gateway/sdk/v2/CoderV2RestFacade.kt | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt index c1d79115..12b54204 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt @@ -7,6 +7,7 @@ import com.coder.gateway.sdk.v2.CoderV2RestFacade import com.coder.gateway.sdk.v2.models.BuildInfo import com.coder.gateway.sdk.v2.models.User import com.coder.gateway.sdk.v2.models.Workspace +import com.coder.gateway.sdk.v2.models.WorkspaceResource import com.google.gson.Gson import com.google.gson.GsonBuilder import com.intellij.openapi.components.Service @@ -93,4 +94,13 @@ class CoderRestClientService { } return buildInfoResponse.body()!! } + + fun workspaceResources(workspace: Workspace): List<WorkspaceResource> { + val workspaceResourcesResponse = retroRestClient.workspaceResourceByBuild(workspace.latestBuild.id).execute() + if (!workspaceResourcesResponse.isSuccessful) { + throw IllegalStateException("Could not retrieve resources for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}") + } + + return workspaceResourcesResponse.body()!! + } } \ No newline at end of file diff --git a/src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt b/src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt index 3355d427..9ef91d52 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt @@ -3,8 +3,11 @@ package com.coder.gateway.sdk.v2 import com.coder.gateway.sdk.v2.models.BuildInfo import com.coder.gateway.sdk.v2.models.User import com.coder.gateway.sdk.v2.models.Workspace +import com.coder.gateway.sdk.v2.models.WorkspaceResource import retrofit2.Call import retrofit2.http.GET +import retrofit2.http.Path +import java.util.UUID interface CoderV2RestFacade { @@ -22,4 +25,7 @@ interface CoderV2RestFacade { @GET("api/v2/buildinfo") fun buildInfo(): Call<BuildInfo> + + @GET("api/v2/workspacebuilds/{buildID}/resources") + fun workspaceResourceByBuild(@Path("buildID") build: UUID): Call<List<WorkspaceResource>> } \ No newline at end of file From 519515cf8aa7d6e9d82af49e65dc51aafebdde73 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 14:43:37 +0300 Subject: [PATCH 03/11] Use custom exception & add docs --- .../kotlin/com/coder/gateway/sdk/CoderRestClientService.kt | 7 ++++++- src/main/kotlin/com/coder/gateway/sdk/ex/exceptions.kt | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt index 12b54204..5f3d4100 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt @@ -2,6 +2,7 @@ package com.coder.gateway.sdk import com.coder.gateway.sdk.convertors.InstantConverter import com.coder.gateway.sdk.ex.AuthenticationResponseException +import com.coder.gateway.sdk.ex.WorkspaceResourcesResponseException import com.coder.gateway.sdk.ex.WorkspaceResponseException import com.coder.gateway.sdk.v2.CoderV2RestFacade import com.coder.gateway.sdk.v2.models.BuildInfo @@ -95,10 +96,14 @@ class CoderRestClientService { return buildInfoResponse.body()!! } + /** + * Retrieves the workspace resources (a workspace is a collection of ojects like, VMs, containers, cloud DBs, etc...) + * @throws WorkspaceResourcesResponseException if workspace resources could not be retrieved. + */ fun workspaceResources(workspace: Workspace): List<WorkspaceResource> { val workspaceResourcesResponse = retroRestClient.workspaceResourceByBuild(workspace.latestBuild.id).execute() if (!workspaceResourcesResponse.isSuccessful) { - throw IllegalStateException("Could not retrieve resources for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}") + throw WorkspaceResourcesResponseException("Could not retrieve resources for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}") } return workspaceResourcesResponse.body()!! diff --git a/src/main/kotlin/com/coder/gateway/sdk/ex/exceptions.kt b/src/main/kotlin/com/coder/gateway/sdk/ex/exceptions.kt index d24e338c..983611b0 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/ex/exceptions.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/ex/exceptions.kt @@ -4,4 +4,6 @@ import java.io.IOException class AuthenticationResponseException(reason: String) : IOException(reason) -class WorkspaceResponseException(reason: String) : IOException(reason) \ No newline at end of file +class WorkspaceResponseException(reason: String) : IOException(reason) + +class WorkspaceResourcesResponseException(reason: String) : IOException(reason) \ No newline at end of file From a3d2ecc9fcfcf467ed72d7dcf0c3b792b8b525a6 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 15:04:33 +0300 Subject: [PATCH 04/11] refactor: return the agents instead the full list of resources --- .../com/coder/gateway/sdk/CoderRestClientService.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt index 5f3d4100..786a1512 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt @@ -8,7 +8,7 @@ import com.coder.gateway.sdk.v2.CoderV2RestFacade import com.coder.gateway.sdk.v2.models.BuildInfo import com.coder.gateway.sdk.v2.models.User import com.coder.gateway.sdk.v2.models.Workspace -import com.coder.gateway.sdk.v2.models.WorkspaceResource +import com.coder.gateway.sdk.v2.models.WorkspaceAgent import com.google.gson.Gson import com.google.gson.GsonBuilder import com.intellij.openapi.components.Service @@ -97,15 +97,17 @@ class CoderRestClientService { } /** - * Retrieves the workspace resources (a workspace is a collection of ojects like, VMs, containers, cloud DBs, etc...) + * Retrieves the workspace agents. A workspace is a collection of objects like, VMs, containers, cloud DBs, etc... + * Agents run on compute hosts like VMs or containers. + * * @throws WorkspaceResourcesResponseException if workspace resources could not be retrieved. */ - fun workspaceResources(workspace: Workspace): List<WorkspaceResource> { + fun workspaceAgents(workspace: Workspace): List<WorkspaceAgent> { val workspaceResourcesResponse = retroRestClient.workspaceResourceByBuild(workspace.latestBuild.id).execute() if (!workspaceResourcesResponse.isSuccessful) { - throw WorkspaceResourcesResponseException("Could not retrieve resources for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}") + throw WorkspaceResourcesResponseException("Could not retrieve agents for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}") } - return workspaceResourcesResponse.body()!! + return workspaceResourcesResponse.body()!!.flatMap { it.agents ?: emptyList() } } } \ No newline at end of file From bd4ba242e62a8e1d31c4bb734c495f5f411a95a5 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 19:41:53 +0300 Subject: [PATCH 05/11] Add new icons for win/mac --- src/main/resources/macOS.svg | 6 ++++++ src/main/resources/unknown.svg | 6 ++++++ src/main/resources/windows.svg | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 src/main/resources/macOS.svg create mode 100644 src/main/resources/unknown.svg create mode 100644 src/main/resources/windows.svg diff --git a/src/main/resources/macOS.svg b/src/main/resources/macOS.svg new file mode 100644 index 00000000..e0c6cbd4 --- /dev/null +++ b/src/main/resources/macOS.svg @@ -0,0 +1,6 @@ +<!-- Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. --> + +<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path d="M13.6454 11.9103C13.4337 12.3994 13.1831 12.8496 12.8927 13.2635C12.4969 13.8278 12.1729 14.2185 11.9231 14.4354C11.536 14.7914 11.1212 14.9737 10.677 14.9841C10.3581 14.9841 9.97356 14.8934 9.52592 14.7093C9.07681 14.5261 8.66408 14.4354 8.2867 14.4354C7.89091 14.4354 7.46643 14.5261 7.01239 14.7093C6.55767 14.8934 6.19134 14.9893 5.91127 14.9988C5.48532 15.0169 5.06075 14.8294 4.63696 14.4354C4.36647 14.1994 4.02815 13.795 3.62285 13.2221C3.188 12.6102 2.8305 11.9007 2.55042 11.0919C2.25046 10.2182 2.1001 9.37218 2.1001 8.55312C2.1001 7.61489 2.30283 6.80568 2.70891 6.12756C3.02804 5.58288 3.45261 5.15321 3.98399 4.83779C4.51537 4.52236 5.08953 4.36163 5.70784 4.35134C6.04616 4.35134 6.48983 4.456 7.04117 4.66167C7.59096 4.86803 7.94397 4.97268 8.09874 4.97268C8.21446 4.97268 8.60662 4.85032 9.27142 4.60636C9.90011 4.38012 10.4307 4.28645 10.8654 4.32335C12.0433 4.4184 12.9282 4.88272 13.5167 5.71924C12.4632 6.35752 11.9421 7.2515 11.9525 8.39834C11.962 9.29164 12.2861 10.035 12.923 10.6252C13.2116 10.8992 13.5339 11.1109 13.8926 11.2613C13.8148 11.4868 13.7327 11.7028 13.6454 11.9103V11.9103ZM10.944 1.28008C10.944 1.98024 10.6882 2.63398 10.1784 3.23907C9.56308 3.95841 8.81886 4.37407 8.01181 4.30848C8.00152 4.22448 7.99556 4.13608 7.99556 4.04318C7.99556 3.37103 8.28817 2.65169 8.8078 2.06354C9.06722 1.76574 9.39716 1.51813 9.79727 1.32061C10.1965 1.12603 10.5742 1.01843 10.9293 1C10.9397 1.0936 10.944 1.18721 10.944 1.28007V1.28008Z" + fill="#ABB6BD" /> +</svg> diff --git a/src/main/resources/unknown.svg b/src/main/resources/unknown.svg new file mode 100644 index 00000000..1f8cd754 --- /dev/null +++ b/src/main/resources/unknown.svg @@ -0,0 +1,6 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> + <g fill="none" fill-rule="evenodd"> + <path fill="#9AA7B0" fill-opacity=".6" d="M15,8 C15,11.866 11.866,15 8,15 C4.134,15 1,11.866 1,8 C1,4.134 4.134,1 8,1 C11.866,1 15,4.134 15,8" /> + <path fill="#231F20" fill-opacity=".7" d="M1.5,6 L2.5,6 L2.5,5 L1.5,5 L1.5,6 Z M2,0 C0.895,0 0,0.895 0,2 L1,2 C1,1.45 1.45,1 2,1 C2.55,1 3,1.45 3,2 C3,3 1.5,2.875 1.5,4.5 L2.5,4.5 C2.5,3.375 4,3.25 4,2 C4,0.895 3.105,0 2,0 Z" transform="translate(6 5)" /> + </g> +</svg> diff --git a/src/main/resources/windows.svg b/src/main/resources/windows.svg new file mode 100644 index 00000000..71da3d35 --- /dev/null +++ b/src/main/resources/windows.svg @@ -0,0 +1,5 @@ +<!-- Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. --> + +<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M7.44479 3.61741L13.0001 3.00015V7.44453H7.44479V3.61741ZM6.3337 3.74086L3.00024 4.11125V7.44453H6.3337V3.74086ZM6.3337 8.55563H3.00024V11.8889L6.3337 12.2593V8.55563ZM7.44479 12.3827L13.0001 13V8.55563H7.44479V12.3827Z" fill="#0EAAE5" /> +</svg> From 061c2f48c89cf72e7cb007d9fd10969b46709b6d Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 19:43:57 +0300 Subject: [PATCH 06/11] Add new view model for workspace - UI needs to present a combination of properties from two data models (Workspace and WorkspaceAgent) --- .../coder/gateway/models/WorkspaceAgentModel.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt diff --git a/src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt b/src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt new file mode 100644 index 00000000..e8c5e157 --- /dev/null +++ b/src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt @@ -0,0 +1,16 @@ +package com.coder.gateway.models + +import com.coder.gateway.sdk.Arch +import com.coder.gateway.sdk.OS +import com.coder.gateway.sdk.v2.models.ProvisionerJobStatus +import com.coder.gateway.sdk.v2.models.WorkspaceBuildTransition + +data class WorkspaceAgentModel( + val name: String, + + val jobStatus: ProvisionerJobStatus, + val buildTransition: WorkspaceBuildTransition, + + val agentOS: OS?, + val agentArch: Arch? +) From bdae6e47d0736e2b5d84b5cf847efb1f2612b946 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 19:48:55 +0300 Subject: [PATCH 07/11] Impl: support for workspaces with multiple agents - the hostname for the connection is `coder.WorkspaceName` if there is at most an agent. - whereas if there are multiple agents, the hostname becomes `coder.WorkspaceName.AgentName` - the OS and Arch are also retrieved from the agent. - removed specific Linux distribution icons - refactored the utilities around OS&Arch resolving - resolves #2 --- .../com/coder/gateway/icons/CoderIcons.kt | 5 +- .../models/CoderWorkspacesWizardModel.kt | 6 +- src/main/kotlin/com/coder/gateway/sdk/os.kt | 57 ++++++++++++------- .../views/steps/CoderWorkspacesStepView.kt | 23 +++++++- .../views/steps/WorkspaceCellRenderer.kt | 35 ++++++------ src/main/resources/centos.svg | 10 ---- src/main/resources/ubuntu.svg | 1 - 7 files changed, 79 insertions(+), 58 deletions(-) delete mode 100644 src/main/resources/centos.svg delete mode 100644 src/main/resources/ubuntu.svg diff --git a/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt b/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt index 3fac2af3..2d084eb0 100644 --- a/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt +++ b/src/main/kotlin/com/coder/gateway/icons/CoderIcons.kt @@ -9,9 +9,10 @@ object CoderIcons { val OPEN_TERMINAL = IconLoader.getIcon("open_terminal.svg", javaClass) - val UBUNTU = IconLoader.getIcon("ubuntu.svg", javaClass) - val CENTOS = IconLoader.getIcon("centos.svg", javaClass) + val WINDOWS = IconLoader.getIcon("windows.svg", javaClass) + val MACOS = IconLoader.getIcon("macOS.svg", javaClass) val LINUX = IconLoader.getIcon("linux.svg", javaClass) + val UNKNOWN = IconLoader.getIcon("unknown.svg", javaClass) val GREEN_CIRCLE = IconLoader.getIcon("green_circle.svg", javaClass) val GRAY_CIRCLE = IconLoader.getIcon("gray_circle.svg", javaClass) diff --git a/src/main/kotlin/com/coder/gateway/models/CoderWorkspacesWizardModel.kt b/src/main/kotlin/com/coder/gateway/models/CoderWorkspacesWizardModel.kt index 9b865644..990b4f43 100644 --- a/src/main/kotlin/com/coder/gateway/models/CoderWorkspacesWizardModel.kt +++ b/src/main/kotlin/com/coder/gateway/models/CoderWorkspacesWizardModel.kt @@ -1,11 +1,9 @@ package com.coder.gateway.models -import com.coder.gateway.sdk.v2.models.Workspace - data class CoderWorkspacesWizardModel( var coderURL: String = "https://localhost", var token: String = "", var buildVersion: String = "", - var workspaces: List<Workspace> = mutableListOf(), - var selectedWorkspace: Workspace? = null + var workspaceAgents: List<WorkspaceAgentModel> = mutableListOf(), + var selectedWorkspace: WorkspaceAgentModel? = null ) \ No newline at end of file diff --git a/src/main/kotlin/com/coder/gateway/sdk/os.kt b/src/main/kotlin/com/coder/gateway/sdk/os.kt index df342173..c8682b32 100644 --- a/src/main/kotlin/com/coder/gateway/sdk/os.kt +++ b/src/main/kotlin/com/coder/gateway/sdk/os.kt @@ -1,35 +1,48 @@ package com.coder.gateway.sdk fun getOS(): OS? { - val os = System.getProperty("os.name").toLowerCase() - return when { - os.contains("win", true) -> { - OS.WINDOWS - } - os.contains("nix", true) || os.contains("nux", true) || os.contains("aix", true) -> { - OS.LINUX - } - os.contains("mac", true) -> { - OS.MAC - } - else -> null - } + return OS.from(System.getProperty("os.name")) } fun getArch(): Arch? { - val arch = System.getProperty("os.arch").toLowerCase() - return when { - arch.contains("amd64", true) || arch.contains("x86_64", true) -> Arch.AMD64 - arch.contains("arm64", true) || arch.contains("aarch64", true) -> Arch.ARM64 - arch.contains("armv7", true) -> Arch.ARMV7 - else -> null - } + return Arch.from(System.getProperty("os.arch").toLowerCase()) } enum class OS { - WINDOWS, LINUX, MAC + WINDOWS, LINUX, MAC; + + companion object { + fun from(os: String): OS? { + return when { + os.contains("win", true) -> { + WINDOWS + } + + os.contains("nix", true) || os.contains("nux", true) || os.contains("aix", true) -> { + LINUX + } + + os.contains("mac", true) -> { + MAC + } + + else -> null + } + } + } } enum class Arch { - AMD64, ARM64, ARMV7 + AMD64, ARM64, ARMV7; + + companion object { + fun from(arch: String): Arch? { + return when { + arch.contains("amd64", true) || arch.contains("x86_64", true) -> AMD64 + arch.contains("arm64", true) || arch.contains("aarch64", true) -> ARM64 + arch.contains("armv7", true) -> ARMV7 + else -> null + } + } + } } \ No newline at end of file diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 822fef7b..88712ea4 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -3,8 +3,10 @@ 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.models.WorkspaceAgentModel +import com.coder.gateway.sdk.Arch import com.coder.gateway.sdk.CoderRestClientService -import com.coder.gateway.sdk.v2.models.Workspace +import com.coder.gateway.sdk.OS import com.intellij.ide.IdeBundle import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager @@ -28,7 +30,7 @@ class CoderWorkspacesStepView : CoderWorkspacesWizardStep, Disposable { private val cs = CoroutineScope(Dispatchers.Main) private val coderClient: CoderRestClientService = ApplicationManager.getApplication().getService(CoderRestClientService::class.java) - private var workspaces = CollectionListModel<Workspace>() + private var workspaces = CollectionListModel<WorkspaceAgentModel>() private var workspacesView = JBList(workspaces) private lateinit var wizard: CoderWorkspacesWizardModel @@ -60,7 +62,22 @@ class CoderWorkspacesStepView : CoderWorkspacesWizardStep, Disposable { cs.launch { val workspaceList = withContext(Dispatchers.IO) { try { - coderClient.workspaces() + val workspaces = coderClient.workspaces() + return@withContext workspaces.flatMap { workspace -> + val agents = coderClient.workspaceAgents(workspace) + val shouldContainAgentName = agents.size > 1 + agents.map { agent -> + val workspaceName = if (shouldContainAgentName) "${workspace.name}.${agent.operatingSystem}" else workspace.name + WorkspaceAgentModel( + workspaceName, + workspace.latestBuild.job.status, + workspace.latestBuild.workspaceTransition, + OS.from(agent.operatingSystem), + Arch.from(agent.operatingSystem) + + ) + } + } } catch (e: Exception) { logger.error("Could not retrieve workspaces for ${coderClient.me.username} on ${coderClient.coderURL}. Reason: $e") emptyList() diff --git a/src/main/kotlin/com/coder/gateway/views/steps/WorkspaceCellRenderer.kt b/src/main/kotlin/com/coder/gateway/views/steps/WorkspaceCellRenderer.kt index e7170a6c..e89773ef 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/WorkspaceCellRenderer.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/WorkspaceCellRenderer.kt @@ -1,13 +1,12 @@ package com.coder.gateway.views.steps -import com.coder.gateway.icons.CoderIcons.CENTOS +import com.coder.gateway.icons.CoderIcons import com.coder.gateway.icons.CoderIcons.GRAY_CIRCLE import com.coder.gateway.icons.CoderIcons.GREEN_CIRCLE -import com.coder.gateway.icons.CoderIcons.LINUX import com.coder.gateway.icons.CoderIcons.RED_CIRCLE -import com.coder.gateway.icons.CoderIcons.UBUNTU +import com.coder.gateway.models.WorkspaceAgentModel +import com.coder.gateway.sdk.OS import com.coder.gateway.sdk.v2.models.ProvisionerJobStatus -import com.coder.gateway.sdk.v2.models.Workspace import com.coder.gateway.sdk.v2.models.WorkspaceBuildTransition import com.intellij.ui.dsl.builder.panel import com.intellij.util.ui.JBFont @@ -15,9 +14,9 @@ import java.awt.Component import javax.swing.JList import javax.swing.ListCellRenderer -class WorkspaceCellRenderer : ListCellRenderer<Workspace> { +class WorkspaceCellRenderer : ListCellRenderer<WorkspaceAgentModel> { - override fun getListCellRendererComponent(list: JList<out Workspace>, workspace: Workspace, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component { + override fun getListCellRendererComponent(list: JList<out WorkspaceAgentModel>, workspace: WorkspaceAgentModel, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component { return panel { indent { row { @@ -44,32 +43,36 @@ class WorkspaceCellRenderer : ListCellRenderer<Workspace> { } } - private fun iconForImageTag(workspace: Workspace) = when (workspace.templateName) { - "ubuntu" -> UBUNTU - "centos" -> CENTOS - else -> LINUX + private fun iconForImageTag(workspace: WorkspaceAgentModel) = when (workspace?.agentOS) { + OS.LINUX -> CoderIcons.LINUX + OS.WINDOWS -> CoderIcons.WINDOWS + OS.MAC -> CoderIcons.MACOS + else -> CoderIcons.UNKNOWN } - private fun iconForStatus(workspace: Workspace) = when (workspace.latestBuild.job.status) { - ProvisionerJobStatus.SUCCEEDED -> if (workspace.latestBuild.workspaceTransition == WorkspaceBuildTransition.START) GREEN_CIRCLE else RED_CIRCLE - ProvisionerJobStatus.RUNNING -> when (workspace.latestBuild.workspaceTransition) { + private fun iconForStatus(workspace: WorkspaceAgentModel) = when (workspace.jobStatus) { + ProvisionerJobStatus.SUCCEEDED -> if (workspace.buildTransition == WorkspaceBuildTransition.START) GREEN_CIRCLE else RED_CIRCLE + ProvisionerJobStatus.RUNNING -> when (workspace.buildTransition) { WorkspaceBuildTransition.START, WorkspaceBuildTransition.STOP, WorkspaceBuildTransition.DELETE -> GRAY_CIRCLE } + else -> RED_CIRCLE } - private fun labelForStatus(workspace: Workspace) = when (workspace.latestBuild.job.status) { + private fun labelForStatus(workspace: WorkspaceAgentModel) = when (workspace.jobStatus) { ProvisionerJobStatus.PENDING -> "◍ Queued" - ProvisionerJobStatus.RUNNING -> when (workspace.latestBuild.workspaceTransition) { + ProvisionerJobStatus.RUNNING -> when (workspace.buildTransition) { WorkspaceBuildTransition.START -> "⦿ Starting" WorkspaceBuildTransition.STOP -> "◍ Stopping" WorkspaceBuildTransition.DELETE -> "⦸ Deleting" } - ProvisionerJobStatus.SUCCEEDED -> when (workspace.latestBuild.workspaceTransition) { + + ProvisionerJobStatus.SUCCEEDED -> when (workspace.buildTransition) { WorkspaceBuildTransition.START -> "⦿ Running" WorkspaceBuildTransition.STOP -> "◍ Stopped" WorkspaceBuildTransition.DELETE -> "⦸ Deleted" } + ProvisionerJobStatus.CANCELING -> "◍ Canceling action" ProvisionerJobStatus.CANCELED -> "◍ Canceled action" ProvisionerJobStatus.FAILED -> "ⓧ Failed" diff --git a/src/main/resources/centos.svg b/src/main/resources/centos.svg deleted file mode 100644 index 62da80c5..00000000 --- a/src/main/resources/centos.svg +++ /dev/null @@ -1,10 +0,0 @@ -<svg width="32px" height="32px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid"> - <g> - <path d="M107.860446,118.641168 L117.088645,127.817911 L107.860446,136.99288 L42.9010976,136.99288 L42.9010976,167.564282 L3.28602642,127.817911 L42.9010976,88.7386823 L42.9010976,118.641168 L107.860446,118.641168 L107.860446,118.641168 L107.860446,118.641168 L107.860446,118.641168 Z M136.414454,40.5732 L215.342964,40.5732 L215.342964,119.503484 L136.414454,119.503484 L136.414454,40.5732 L136.414454,40.5732 L136.414454,40.5732 L136.414454,40.5732 Z" fill="#932279"></path> - <path d="M137.274996,107.860446 L128.100027,117.088645 L118.925058,107.860446 L118.925058,42.9010976 L88.3518821,42.9010976 L128.100027,3.28602642 L167.177481,42.9010976 L137.274996,42.9010976 L137.274996,107.860446 L137.274996,107.860446 L137.274996,107.860446 L137.274996,107.860446 Z M136.414454,136.414454 L215.342964,136.414454 L215.342964,215.344738 L136.414454,215.344738 L136.414454,136.414454 L136.414454,136.414454 L136.414454,136.414454 L136.414454,136.414454 Z" fill="#EFA724"></path> - <path d="M148.057492,137.274996 L138.827519,128.100027 L148.057492,118.925058 L213.015067,118.925058 L213.015067,88.3518821 L252.631911,128.100027 L213.015067,167.177481 L213.015067,137.274996 L148.057492,137.274996 L148.057492,137.274996 L148.057492,137.274996 L148.057492,137.274996 Z M40.5732,136.414454 L119.501709,136.414454 L119.501709,215.344738 L40.5732,215.344738 L40.5732,136.414454 L40.5732,136.414454 L40.5732,136.414454 L40.5732,136.414454 Z" fill="#262577"></path> - <path d="M118.641168,148.057492 L127.816137,138.827519 L136.99288,148.057492 L136.99288,213.016841 L167.564282,213.016841 L127.816137,252.631911 L88.7404565,213.016841 L118.641168,213.016841 L118.641168,148.057492 L118.641168,148.057492 L118.641168,148.057492 L118.641168,148.057492 Z M40.5732,40.5732 L119.501709,40.5732 L119.501709,119.503484 L40.5732,119.503484 L40.5732,40.5732 L40.5732,40.5732 L40.5732,40.5732 L40.5732,40.5732 Z" fill="#9CCD2A"></path> - <path d="M37.7538176,37.7538176 L122.321092,37.7538176 L122.321092,122.321092 L37.7538176,122.321092 L37.7538176,37.7538176 L37.7538176,37.7538176 L37.7538176,37.7538176 L37.7538176,37.7538176 L37.7538176,37.7538176 Z M43.3908078,116.684101 L116.682327,116.684101 L116.682327,43.3925822 L43.3908078,43.3925822 L43.3908078,116.684101 L43.3908078,116.684101 L43.3908078,116.684101 L43.3908078,116.684101 Z M133.596846,37.7538176 L218.164121,37.7538176 L218.164121,122.321092 L133.596846,122.321092 L133.596846,37.7538176 L133.596846,37.7538176 L133.596846,37.7538176 L133.596846,37.7538176 Z M139.233837,116.684101 L212.525356,116.684101 L212.525356,43.3925822 L139.233837,43.3925822 L139.233837,116.684101 L139.233837,116.684101 L139.233837,116.684101 L139.233837,116.684101 Z M133.596846,133.596846 L218.164121,133.596846 L218.164121,218.165895 L133.596846,218.165895 L133.596846,133.596846 L133.596846,133.596846 L133.596846,133.596846 L133.596846,133.596846 Z M139.233837,212.525356 L212.525356,212.525356 L212.525356,139.233837 L139.233837,139.233837 L139.233837,212.525356 L139.233837,212.525356 L139.233837,212.525356 L139.233837,212.525356 Z M37.7538176,133.596846 L122.321092,133.596846 L122.321092,218.165895 L37.7538176,218.165895 L37.7538176,133.596846 L37.7538176,133.596846 L37.7538176,133.596846 L37.7538176,133.596846 Z M43.3908078,212.525356 L116.682327,212.525356 L116.682327,139.233837 L43.3908078,139.233837 L43.3908078,212.525356 L43.3908078,212.525356 L43.3908078,212.525356 L43.3908078,212.525356 L43.3908078,212.525356 Z" fill="#FFFFFF"></path> - <path d="M60.1882226,187.75773 L0.388574398,127.958082 L60.1864484,68.160208 L119.986097,127.958082 L60.1882226,187.75773 L60.1882226,187.75773 L60.1882226,187.75773 L60.1882226,187.75773 L60.1882226,187.75773 L60.1882226,187.75773 Z M8.36233399,127.958082 L60.1882226,179.78397 L112.012337,127.958082 L60.1864484,76.1339675 L8.36233399,127.958082 L8.36233399,127.958082 L8.36233399,127.958082 L8.36233399,127.958082 Z M127.958082,119.986097 L68.160208,60.1882226 L127.958082,0.388574398 L187.755956,60.1882226 L127.958082,119.986097 L127.958082,119.986097 L127.958082,119.986097 L127.958082,119.986097 Z M76.1339675,60.1882226 L127.958082,112.012337 L179.78397,60.1882226 L127.958082,8.36233399 L76.1339675,60.1882226 L76.1339675,60.1882226 L76.1339675,60.1882226 L76.1339675,60.1882226 Z M195.729716,187.75773 L135.931841,127.958082 L195.729716,68.160208 L255.527589,127.958082 L195.729716,187.75773 L195.729716,187.75773 L195.729716,187.75773 L195.729716,187.75773 Z M143.903827,127.958082 L195.729716,179.78397 L247.553829,127.958082 L195.729716,76.1339675 L143.903827,127.958082 L143.903827,127.958082 L143.903827,127.958082 L143.903827,127.958082 Z M127.958082,255.527589 L68.160208,195.729716 L127.958082,135.931841 L187.755956,195.729716 L127.958082,255.527589 L127.958082,255.527589 L127.958082,255.527589 L127.958082,255.527589 Z M76.1339675,195.729716 L127.958082,247.553829 L179.78397,195.729716 L127.958082,143.905601 L76.1339675,195.729716 L76.1339675,195.729716 L76.1339675,195.729716 L76.1339675,195.729716 L76.1339675,195.729716 L76.1339675,195.729716 Z" fill="#FFFFFF"></path> - </g> -</svg> diff --git a/src/main/resources/ubuntu.svg b/src/main/resources/ubuntu.svg deleted file mode 100644 index 0150e343..00000000 --- a/src/main/resources/ubuntu.svg +++ /dev/null @@ -1 +0,0 @@ -<svg width="32" height="32" viewBox="0 0 256 256" aria-hidden="true" id="ubuntu" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" preserveAspectRatio="xMidYMid"><g><path d="M255.637396,127.683191 C255.637396,198.196551 198.47207,255.363378 127.954205,255.363378 C57.4348387,255.363378 0.27026393,198.196551 0.27026393,127.683191 C0.27026393,57.1653255 57.4355894,0 127.954205,0 C198.472821,0 255.637396,57.1653255 255.637396,127.683191 L255.637396,127.683191 Z" fill="#DD4814"></path><path d="M41.1334194,110.63254 C31.7139707,110.63254 24.0827683,118.264493 24.0827683,127.683191 C24.0827683,137.097384 31.7139707,144.728587 41.1334194,144.728587 C50.5476129,144.728587 58.1788152,137.097384 58.1788152,127.683191 C58.1788152,118.264493 50.5476129,110.63254 41.1334194,110.63254 L41.1334194,110.63254 Z M162.848282,188.111202 C154.694569,192.820551 151.898839,203.240727 156.608938,211.389935 C161.313032,219.543648 171.733208,222.338628 179.886921,217.629279 C188.039883,212.925185 190.835613,202.505009 186.126264,194.350545 C181.42217,186.202088 170.995988,183.407109 162.848282,188.111202 L162.848282,188.111202 Z M78.1618299,127.683191 C78.1618299,110.836739 86.5295015,95.9534545 99.3332551,86.9409032 L86.8703343,66.0667683 C71.9555191,76.0365044 60.8581818,91.271132 56.2464282,109.113806 C61.6276833,113.504845 65.0720469,120.189372 65.0720469,127.68244 C65.0720469,135.171003 61.6276833,141.855531 56.2464282,146.246569 C60.852176,164.094499 71.9495132,179.329877 86.8703343,189.299613 L99.3332551,168.420223 C86.5295015,159.412927 78.1618299,144.530393 78.1618299,127.683191 L78.1618299,127.683191 Z M127.954205,77.8855601 C153.967109,77.8855601 175.30895,97.8302874 177.549138,123.265877 L201.839859,122.907777 C200.644692,104.129689 192.441431,87.2719765 179.836622,74.875871 C173.354792,77.3247625 165.86773,76.9501466 159.396411,73.2197537 C152.91383,69.4788504 148.849361,63.1681877 147.738276,56.3177478 C141.438123,54.5790499 134.807648,53.6271202 127.952704,53.6271202 C116.168446,53.6271202 105.026815,56.3950733 95.1344047,61.2913548 L106.979472,82.5175836 C113.351695,79.5521877 120.460387,77.8855601 127.954205,77.8855601 L127.954205,77.8855601 Z M127.954205,177.475566 C120.460387,177.475566 113.351695,175.808188 106.980223,172.843543 L95.1351554,194.069021 C105.027566,198.971308 116.169196,201.740012 127.954205,201.740012 C134.80915,201.740012 141.439625,200.787331 147.739026,199.043378 C148.850111,192.192938 152.916082,185.888282 159.397161,182.140622 C165.872985,178.404223 173.355543,178.036364 179.837372,180.485255 C192.442182,168.08915 200.645443,151.231437 201.84061,132.453349 L177.543883,132.095249 C175.30895,157.537595 153.967859,177.475566 127.954205,177.475566 L127.954205,177.475566 Z M162.842276,67.2446686 C170.995988,71.9532669 181.416915,69.1642933 186.121009,61.0105806 C190.830358,52.856868 188.041384,42.4359413 179.886921,37.7258416 C171.733208,33.0217478 161.313032,35.8167273 156.602182,43.9704399 C151.898839,52.1196481 154.693818,62.5405748 162.842276,67.2446686 L162.842276,67.2446686 Z" fill="#FFFFFF"></path></g></svg> \ No newline at end of file From 714989c2296175a7a5a460348f5bb7e26523c4ee Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 22:37:59 +0300 Subject: [PATCH 08/11] 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. --- .../steps/CoderLocateRemoteProjectStepView.kt | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt index 63a854bd..5f59e8b6 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt @@ -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 @@ -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 @@ -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}") @@ -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 From c82f7fda570cc9d5a8af3dd16a70fd6ee271ef37 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 23:16:22 +0300 Subject: [PATCH 09/11] Fix: use agent name instead of OS in the workspace view --- .../com/coder/gateway/views/steps/CoderWorkspacesStepView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 88712ea4..14dcddc3 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -67,7 +67,7 @@ class CoderWorkspacesStepView : CoderWorkspacesWizardStep, Disposable { val agents = coderClient.workspaceAgents(workspace) val shouldContainAgentName = agents.size > 1 agents.map { agent -> - val workspaceName = if (shouldContainAgentName) "${workspace.name}.${agent.operatingSystem}" else workspace.name + val workspaceName = if (shouldContainAgentName) "${workspace.name}.${agent.name}" else workspace.name WorkspaceAgentModel( workspaceName, workspace.latestBuild.job.status, From 6984b4afa985b60c90a06358cf27ac9aec9d81f7 Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 23:20:54 +0300 Subject: [PATCH 10/11] Fix: arch resolving from agent data model --- .../com/coder/gateway/views/steps/CoderWorkspacesStepView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt index 14dcddc3..76ca28d0 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt @@ -73,7 +73,7 @@ class CoderWorkspacesStepView : CoderWorkspacesWizardStep, Disposable { workspace.latestBuild.job.status, workspace.latestBuild.workspaceTransition, OS.from(agent.operatingSystem), - Arch.from(agent.operatingSystem) + Arch.from(agent.architecture) ) } From c06299d739d2d2e8255beb9872e2bd6993b49f3f Mon Sep 17 00:00:00 2001 From: Ioan Faur <fioan89@gmail.com> Date: Tue, 28 Jun 2022 23:29:41 +0300 Subject: [PATCH 11/11] Fix: deployed os resolving is not allowed on EDT --- .../gateway/views/steps/CoderLocateRemoteProjectStepView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt index 5f59e8b6..7944d224 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt @@ -116,7 +116,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit cs.launch { logger.info("Retrieving available IDE's for ${selectedWorkspace.name} workspace...") - val workspaceOS = if (selectedWorkspace.agentOS != null && selectedWorkspace.agentArch != null) toDeployedOS(selectedWorkspace.agentOS, selectedWorkspace.agentArch) else withContext(Dispatchers.IO) { + val workspaceOS = if (selectedWorkspace.agentOS != null && selectedWorkspace.agentArch != null) withContext(Dispatchers.IO) { toDeployedOS(selectedWorkspace.agentOS, selectedWorkspace.agentArch) } else withContext(Dispatchers.IO) { try { RemoteCredentialsHolder().apply { setHost("coder.${selectedWorkspace.name}")