Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdac5c71

Browse files
committed
impl: ability to start a recent workspace connection after ssh wildcard config was changed
Currently, if a user starts a connection with wildcard enabled and then later on it disablesthe wildcard config then the recent connections becomes unusable because the hostnames are invalid.The issue can reproduce the other way around as well (start with wildcard ssh config disabled,start an IDE and then later on enable wildcard config)This commit addresses the issue by resolving the hostname on demand when the user wants toopen the remote IDE from the recent connections panel.
1 parent49336ca commitdac5c71

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

‎src/main/kotlin/com/coder/gateway/models/WorkspaceProjectIDE.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private val NON_STABLE_RELEASE_TYPES = setOf("EAP", "RC", "NIGHTLY", "PREVIEW")
1818
* Validated parameters for downloading and opening a project using an IDE on a
1919
* workspace.
2020
*/
21-
classWorkspaceProjectIDE(
21+
dataclassWorkspaceProjectIDE(
2222
// Either `workspace.agent` for old connections or `user/workspace.agent`
2323
// for new connections.
2424
valname:String,

‎src/main/kotlin/com/coder/gateway/util/Without.kt‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ fun <A, Z> withoutNull(
1414
return block(a)
1515
}
1616

17+
/**
18+
* Run block with provided arguments after checking they are all non-null. This
19+
* is to enforce non-null values and should be used to signify developer error.
20+
*/
21+
fun <A,B,C,Z>withoutNull(
22+
a:A?,
23+
b:B?,
24+
c:C?,
25+
block: (a:A, b:B, c:C)->Z,
26+
):Z {
27+
if (a==null|| b==null|| c==null) {
28+
throwException("Unexpected null value")
29+
}
30+
return block(a, b, c)
31+
}
32+
1733
/**
1834
* Run block with provided arguments after checking they are all non-null. This
1935
* is to enforce non-null values and should be used to signify developer error.

‎src/main/kotlin/com/coder/gateway/views/CoderGatewayRecentWorkspaceConnectionsView.kt‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.coder.gateway.views
55
importcom.coder.gateway.CoderGatewayBundle
66
importcom.coder.gateway.CoderGatewayConstants
77
importcom.coder.gateway.CoderRemoteConnectionHandle
8+
importcom.coder.gateway.cli.CoderCLIManager
89
importcom.coder.gateway.cli.ensureCLI
910
importcom.coder.gateway.icons.CoderIcons
1011
importcom.coder.gateway.models.WorkspaceAgentListModel
@@ -177,6 +178,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
177178
it.workspace.ownerName+"/"+ it.workspace.name== workspaceName||
178179
(it.workspace.ownerName== me&& it.workspace.name== workspaceName)
179180
}
181+
180182
val status=
181183
if (deploymentError!=null) {
182184
Triple(UIUtil.getErrorForeground(), deploymentError,UIUtil.getBalloonErrorIcon())
@@ -250,10 +252,11 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
250252
ActionLink(workspaceProjectIDE.projectPathDisplay) {
251253
withoutNull(
252254
deployment?.client,
253-
workspaceWithAgent?.workspace
254-
) { client, workspace->
255+
workspaceWithAgent?.workspace,
256+
workspaceWithAgent?.agent
257+
) { client, workspace, agent->
255258
CoderRemoteConnectionHandle().connect {
256-
if (listOf(
259+
val cli=if (listOf(
257260
WorkspaceStatus.STOPPED,
258261
WorkspaceStatus.CANCELED,
259262
WorkspaceStatus.FAILED
@@ -272,8 +275,21 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
272275
}
273276

274277
cli.startWorkspace(workspace.ownerName, workspace.name)
278+
cli
279+
}else {
280+
CoderCLIManager(deploymentURL.toURL(), settings)
275281
}
276-
workspaceProjectIDE
282+
// the ssh config could have changed in the meantime
283+
// so we want to make sure we use a proper hostname
284+
// depending on whether the ssh wildcard config
285+
// is enabled, otherwise the connection will fail.
286+
workspaceProjectIDE.copy(
287+
hostname= cli.getHostName(
288+
workspace,
289+
client.me(),
290+
agent
291+
)
292+
)
277293
}
278294
GatewayUI.getInstance().reset()
279295
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp