Skip to content
Binary file removed lib/webrtc-java-0.6.0-windows-x86_64.jar
Binary file not shown.
Binary file removed lib/webrtc-java-0.6.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DialogTitleCapitalization")

package com.coder.gateway

import com.coder.gateway.models.RecentWorkspaceConnection
Expand Down Expand Up @@ -63,7 +65,7 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
buildNumber = ideBuildNumber
)

clientLifetime.launchUnderBackgroundProgress("Coder Gateway Deploy", true, true, null) {
clientLifetime.launchUnderBackgroundProgress("Coder Gateway Deploy", canBeCancelled = true, isIndeterminate = true, project = null) {
val context = SshMultistagePanelContext().apply {
deploy = true
sshConfig = sshConfiguration
Expand All @@ -74,6 +76,7 @@ class CoderGatewayConnectionProvider : GatewayConnectionProvider {
ide = ideConfig
}
launch {
@Suppress("UnstableApiUsage")
SshDeployFlowUtil.fullDeployCycle(
clientLifetime,
context,
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/coder/gateway/CoderGatewayMainView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class CoderGatewayMainView : GatewayConnector {
return CoderGatewayBundle.message("gateway.connector.action.text")
}

override fun getDescription(): String? {
override fun getDescription(): String {
return CoderGatewayBundle.message("gateway.connector.description")
}

override fun getDocumentationLink(): ActionLink? {
override fun getDocumentationLink(): ActionLink {
return BrowserLink(null, "Learn more about Coder Workspaces", null, "https://coder.com/docs/coder/latest/workspaces")
}

override fun getRecentConnections(setContentCallback: (Component) -> Unit): GatewayRecentConnections? {
override fun getRecentConnections(setContentCallback: (Component) -> Unit): GatewayRecentConnections {
return CoderGatewayRecentWorkspaceConnectionsView()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.nio.file.StandardCopyOption
class CoderCLIDownloader(private val buildVersion: String) {

fun downloadCLI(url: URL, outputName: String, ext: String): Path {
val filename = if (ext.isNullOrBlank()) "${outputName}-$buildVersion" else "${outputName}-${buildVersion}.${ext}"
val filename = if (ext.isBlank()) "${outputName}-$buildVersion" else "${outputName}-${buildVersion}.${ext}"
val cliPath = Paths.get(System.getProperty("java.io.tmpdir"), filename)
if (Files.exists(cliPath)) {
logger.info("${cliPath.toAbsolutePath()} already exists, skipping download")
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/com/coder/gateway/sdk/CoderCLIManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.openapi.diagnostic.Logger
import java.net.URL
import java.nio.file.Path

class CoderCLIManager(private val url: URL, private val buildVersion: String) {
class CoderCLIManager(private val url: URL, buildVersion: String) {
private val coderCLIDownloader = CoderCLIDownloader(buildVersion)

fun download(): Path? {
Expand All @@ -21,19 +21,19 @@ class CoderCLIManager(private val url: URL, private val buildVersion: String) {
}
return when (os) {
OS.WINDOWS -> when (arch) {
Arch.amd64 -> "coder-windows-amd64"
Arch.arm64 -> "coder-windows-arm64"
Arch.AMD64 -> "coder-windows-amd64"
Arch.ARM64 -> "coder-windows-arm64"
else -> "coder-windows-amd64"
}
OS.LINUX -> when (arch) {
Arch.amd64 -> "coder-linux-amd64"
Arch.arm64 -> "coder-linux-arm64"
Arch.armv7 -> "coder-linux-armv7"
Arch.AMD64 -> "coder-linux-amd64"
Arch.ARM64 -> "coder-linux-arm64"
Arch.ARMV7 -> "coder-linux-armv7"
else -> "coder-linux-amd64"
}
OS.MAC -> when (arch) {
Arch.amd64 -> "coder-darwin-amd64"
Arch.arm64 -> "coder-darwin-arm64"
Arch.AMD64 -> "coder-darwin-amd64"
Arch.ARM64 -> "coder-darwin-arm64"
else -> "coder-darwin-amd64"
}
}
Expand Down
16 changes: 3 additions & 13 deletions src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.coder.gateway.sdk
import com.coder.gateway.sdk.convertors.InstantConverter
import com.coder.gateway.sdk.ex.AuthenticationException
import com.coder.gateway.sdk.v2.CoderV2RestFacade
import com.coder.gateway.sdk.v2.models.AgentGitSSHKeys
import com.coder.gateway.sdk.v2.models.BuildInfo
import com.coder.gateway.sdk.v2.models.User
import com.coder.gateway.sdk.v2.models.Workspace
Expand All @@ -24,16 +23,16 @@ import java.time.Instant
@Service(Service.Level.APP)
class CoderRestClientService {
private lateinit var retroRestClient: CoderV2RestFacade
private lateinit var sessionToken: String
lateinit var coderURL: URL
lateinit var sessionToken: String
lateinit var me: User
lateinit var buildVersion: String

/**
* This must be called before anything else. It will authenticate with coder and retrieve a session token
* @throws [AuthenticationException] if authentication failed
*/
fun initClientSession(url: URL, token: String): User? {
fun initClientSession(url: URL, token: String): User {
val cookieUrl = url.toHttpUrlOrNull()!!
val cookieJar = JavaNetCookieJar(CookieManager()).apply {
saveFromResponse(
Expand Down Expand Up @@ -82,16 +81,7 @@ class CoderRestClientService {
return workspacesResponse.body()!!
}

fun userSSHKeys(): AgentGitSSHKeys {
val sshKeysResponse = retroRestClient.sshKeys().execute()
if (!sshKeysResponse.isSuccessful) {
throw IllegalStateException("Could not retrieve Coder Workspaces:${sshKeysResponse.code()}, reason: ${sshKeysResponse.message()}")
}

return sshKeysResponse.body()!!
}

fun buildInfo(): BuildInfo {
private fun buildInfo(): BuildInfo {
val buildInfoResponse = retroRestClient.buildInfo().execute()
if (!buildInfoResponse.isSuccessful) {
throw java.lang.IllegalStateException("Could not retrieve build information for Coder instance $coderURL, reason:${buildInfoResponse.message()}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InstantConverter : JsonSerializer<Instant?>, JsonDeserializer<Instant?> {
* @param typeOfSrc the actual type (fully genericized version) of the source object.
* @return a JsonElement corresponding to the specified object.
*/
override fun serialize(src: Instant?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement? {
override fun serialize(src: Instant?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
return JsonPrimitive(FORMATTER.format(src))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.coder.gateway.sdk.ex

import java.io.IOException

class AuthenticationException(val reason: String) : IOException(reason)
class AuthenticationException(reason: String) : IOException(reason)
8 changes: 4 additions & 4 deletions src/main/kotlin/com/coder/gateway/sdk/os.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fun getOS(): OS? {
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
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
}
}
Expand All @@ -31,5 +31,5 @@ enum class OS {
}

enum class Arch {
amd64, arm64, armv7
AMD64, ARM64, ARMV7
}
25 changes: 0 additions & 25 deletions src/main/kotlin/com/coder/gateway/sdk/v1/CoderV1RestFacade.kt

This file was deleted.

54 changes: 0 additions & 54 deletions src/main/kotlin/com/coder/gateway/sdk/v1/CoderWebSocket.kt

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/kotlin/com/coder/gateway/sdk/v1/LoginRequest.kt

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/kotlin/com/coder/gateway/sdk/v1/LoginResponse.kt

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/kotlin/com/coder/gateway/sdk/v1/RebuildMessage.kt

This file was deleted.

5 changes: 0 additions & 5 deletions src/main/kotlin/com/coder/gateway/sdk/v1/SSHKeys.kt

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/kotlin/com/coder/gateway/sdk/v1/User.kt

This file was deleted.

28 changes: 0 additions & 28 deletions src/main/kotlin/com/coder/gateway/sdk/v1/Workspace.kt

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/kotlin/com/coder/gateway/sdk/v1/WorkspaceStat.kt

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
package com.coder.gateway.sdk.v2

import com.coder.gateway.sdk.v2.models.AgentGitSSHKeys
import com.coder.gateway.sdk.v2.models.BuildInfo
import com.coder.gateway.sdk.v2.models.LoginWithPasswordRequest
import com.coder.gateway.sdk.v2.models.LoginWithPasswordResponse
import com.coder.gateway.sdk.v2.models.User
import com.coder.gateway.sdk.v2.models.Workspace
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface CoderV2RestFacade {

/**
* Retrieves a session token authenticating with an email and password.
*/
@POST("api/v2/users/login")
fun authenticate(@Body loginRequest: LoginWithPasswordRequest): Call<LoginWithPasswordResponse>

/**
* Retrieves details about the authenticated user.
*/
Expand All @@ -31,9 +20,6 @@ interface CoderV2RestFacade {
@GET("api/v2/workspaces")
fun workspaces(): Call<List<Workspace>>

@GET("api/v2/workspaceagents/me/gitsshkey")
fun sshKeys(): Call<AgentGitSSHKeys>

@GET("api/v2/buildinfo")
fun buildInfo(): Call<BuildInfo>
}

This file was deleted.

Loading