Skip to content

Commit 9600152

Browse files
akosyakoviQQBot
authored andcommitted
[rebuild] support desktop IDEs
1 parent 0e37cdc commit 9600152

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

components/gitpod-cli/cmd/validate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
256256
Target string
257257
Source string
258258
Permission os.FileMode
259+
Optional bool
259260
}
260261

261262
prepareFS := []mnte{
262263
{Source: "/workspace"},
263264
{Source: "/.supervisor"},
264265
{Source: "/ide"},
266+
{Source: "/ide-desktop", Optional: true},
267+
{Source: "/ide-desktop-plugins", Optional: true},
265268
{Source: "/workspace/.gitpod-debug/.docker-root", Target: "/workspace/.docker-root", Permission: 0710},
266269
{Source: "/workspace/.gitpod-debug/.gitpod", Target: "/workspace/.gitpod", Permission: 0751},
267270
{Source: "/workspace/.gitpod-debug/.vscode-remote", Target: "/workspace/.vscode-remote", Permission: 0751},
@@ -291,6 +294,9 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
291294
for _, mnt := range prepareFS {
292295
fd, err := os.Stat(mnt.Source)
293296
if err != nil {
297+
if (os.IsPermission(err) || os.IsNotExist(err)) && mnt.Optional {
298+
continue
299+
}
294300
if !os.IsNotExist(err) {
295301
return err
296302
}

components/ide/jetbrains/gateway-plugin/BUILD.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ packages:
1313
- "src/main/resources-stable/*"
1414
- "*.kts"
1515
- "*.md"
16+
argdeps:
17+
- publishToJBMarketplace
1618
env:
1719
- DO_PUBLISH=${publishToJBMarketplace}
1820
config:
@@ -32,6 +34,8 @@ packages:
3234
- "src/main/resources-latest/*"
3335
- "*.kts"
3436
- "*.md"
37+
argdeps:
38+
- publishToJBMarketplace
3539
env:
3640
- DO_PUBLISH=${publishToJBMarketplace}
3741
config:

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
7474
val connectParams = ConnectParams(
7575
parameters["gitpodHost"]!!,
7676
parameters["workspaceId"]!!,
77-
parameters["backendPort"]
77+
parameters["backendPort"],
78+
parameters["debugWorkspace"] == "true"
7879
)
7980

80-
val connectionKeyId = "${connectParams.gitpodHost}-${connectParams.workspaceId}-${connectParams.backendPort}"
81+
var connectionKeyId = "${connectParams.gitpodHost}-${connectParams.resolvedWorkspaceId}-${connectParams.backendPort}"
8182

8283
var found = true
8384
val connectionLifetime = activeConnections.computeIfAbsent(connectionKeyId) {
@@ -88,7 +89,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
8889
if (found) {
8990
val message =
9091
"You are trying to connect to a workspace that has a client already open. Check for opened JetBrains clients on your machine"
91-
val title = "${connectParams.workspaceId} (${connectParams.gitpodHost})"
92+
val title = connectParams.title
9293
val okButton = Messages.getOkButton()
9394
val options = arrayOf(okButton)
9495
val defaultIndex = 0
@@ -104,8 +105,8 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
104105
}
105106

106107
val client = gitpod.obtainClient(connectParams.gitpodHost)
107-
val updates = client.listenToWorkspace(connectionLifetime, connectParams.workspaceId)
108-
val workspace = client.syncWorkspace(connectParams.workspaceId).workspace
108+
val updates = client.listenToWorkspace(connectionLifetime, connectParams.actualWorkspaceId)
109+
val workspace = client.syncWorkspace(connectParams.actualWorkspaceId).workspace
109110

110111
val phaseMessage = JLabel()
111112
val statusMessage = JLabel()
@@ -120,7 +121,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
120121
background = phaseMessage.background
121122
columns = 30
122123
}
123-
var ideUrl = ""
124+
var resolvedIdeUrl = ""
124125
val connectionPanel = panel {
125126
indent {
126127
row {
@@ -144,9 +145,9 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
144145
}
145146
panel {
146147
row {
147-
link(connectParams.workspaceId) {
148-
if (ideUrl.isNotBlank()) {
149-
BrowserUtil.browse(ideUrl)
148+
link(connectParams.resolvedWorkspaceId) {
149+
if (resolvedIdeUrl.isNotBlank()) {
150+
BrowserUtil.browse(resolvedIdeUrl)
150151
}
151152
}
152153
}
@@ -183,7 +184,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
183184
if (WorkspaceInstance.isUpToDate(lastUpdate, update)) {
184185
continue
185186
}
186-
ideUrl = update.ideUrl
187+
resolvedIdeUrl = update.ideUrl.replace(connectParams.actualWorkspaceId, connectParams.resolvedWorkspaceId)
187188
lastUpdate = update
188189
if (!update.status.conditions.failed.isNullOrBlank()) {
189190
setErrorMessage(update.status.conditions.failed)
@@ -243,18 +244,17 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
243244
if (thinClientJob == null && update.status.phase == "running") {
244245
thinClientJob = launch {
245246
try {
246-
val updatedIdeUrl = URL(update.ideUrl)
247-
val sshHostUrl =
248-
URL(update.ideUrl.replace(update.workspaceId, "${update.workspaceId}.ssh"))
249-
val hostKeys = resolveHostKeys(updatedIdeUrl, connectParams)
247+
val hostKeys = resolveHostKeys(URL(update.ideUrl), connectParams)
250248
if (hostKeys.isNullOrEmpty()) {
251249
setErrorMessage("${connectParams.gitpodHost} installation does not allow SSH access, public keys cannot be found")
252250
return@launch
253251
}
254252
val ownerToken = client.server.getOwnerToken(update.workspaceId).await()
253+
val sshHostUrl =
254+
URL(resolvedIdeUrl.replace(connectParams.resolvedWorkspaceId, "${connectParams.resolvedWorkspaceId}.ssh"))
255255
val credentials =
256-
resolveCredentials(sshHostUrl, update.workspaceId, ownerToken, hostKeys)
257-
val joinLink = resolveJoinLink(updatedIdeUrl, ownerToken, connectParams)
256+
resolveCredentials(sshHostUrl, connectParams.resolvedWorkspaceId, ownerToken, hostKeys)
257+
val joinLink = resolveJoinLink(URL(resolvedIdeUrl), ownerToken, connectParams)
258258
if (joinLink.isNullOrEmpty()) {
259259
setErrorMessage("failed to fetch JetBrains Gateway Join Link.")
260260
return@launch
@@ -283,7 +283,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
283283
throw t
284284
}
285285
thisLogger().error(
286-
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to connect:",
286+
"${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to connect:",
287287
t
288288
)
289289
setErrorMessage("" + t.message)
@@ -292,15 +292,15 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
292292
}
293293
} catch (e: Throwable) {
294294
thisLogger().error(
295-
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to process workspace update:",
295+
"${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace update:",
296296
e
297297
)
298298
}
299299
}
300300
connectionLifetime.terminate()
301301
} catch (t: Throwable) {
302302
thisLogger().error(
303-
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to process workspace updates:",
303+
"${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to process workspace updates:",
304304
t
305305
)
306306
setErrorMessage("failed to process workspace updates ${t.message}")
@@ -451,16 +451,16 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
451451
return response.body()
452452
}
453453
if (response.statusCode() < 500) {
454-
thisLogger().error("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl': ${response.statusCode()}")
454+
thisLogger().error("${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to fetch '$endpointUrl': ${response.statusCode()}")
455455
return null
456456
}
457-
thisLogger().warn("${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl', trying again...: ${response.statusCode()}")
457+
thisLogger().warn("${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to fetch '$endpointUrl', trying again...: ${response.statusCode()}")
458458
} catch (t: Throwable) {
459459
if (t is CancellationException) {
460460
throw t
461461
}
462462
thisLogger().warn(
463-
"${connectParams.gitpodHost}: ${connectParams.workspaceId}: failed to fetch '$endpointUrl', trying again...:",
463+
"${connectParams.gitpodHost}: ${connectParams.resolvedWorkspaceId}: failed to fetch '$endpointUrl', trying again...:",
464464
t
465465
)
466466
}
@@ -476,9 +476,13 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
476476

477477
private data class ConnectParams(
478478
val gitpodHost: String,
479-
val workspaceId: String,
480-
val backendPort: String?
481-
)
479+
val actualWorkspaceId: String,
480+
val backendPort: String?,
481+
val debugWorkspace: Boolean,
482+
) {
483+
val resolvedWorkspaceId = "${if (debugWorkspace) "debug-" else ""}$actualWorkspaceId"
484+
val title = "$resolvedWorkspaceId ($gitpodHost)"
485+
}
482486

483487
private class GitpodConnectionHandle(
484488
lifetime: Lifetime,
@@ -491,7 +495,7 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
491495
}
492496

493497
override fun getTitle(): String {
494-
return "${params.workspaceId} (${params.gitpodHost})"
498+
return params.title
495499
}
496500

497501
override fun hideToTrayOnStart(): Boolean {

0 commit comments

Comments
 (0)