Skip to content

Commit 495961f

Browse files
committed
13
1 parent d9f307e commit 495961f

File tree

6 files changed

+110
-53
lines changed

6 files changed

+110
-53
lines changed

components/ide-service/pkg/server/server.go

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ type Task struct {
216216
var JetbrainsCode map[string]string
217217

218218
func init() {
219+
JetbrainsCode = make(map[string]string)
219220
JetbrainsCode["intellij"] = "IIU"
220221
JetbrainsCode["goland"] = "GO"
221222
JetbrainsCode["pycharm"] = "PCP"
@@ -372,65 +373,74 @@ func (s *IDEServiceServer) ResolveWorkspaceConfig(ctx context.Context, req *api.
372373

373374
jbGW, ok := s.ideConfig.IdeOptions.Clients["jetbrains-gateway"]
374375
if ok {
376+
warmUpTask := ""
375377
for _, alias := range jbGW.DesktopIDEs {
376378
prebuilds := getPrebuilds(wsConfig, alias)
377-
warmUpTask := ""
378379
if prebuilds != nil {
379-
if prebuilds.Version == "latest" {
380-
warmUpTask += `
381-
echo 'warming up stable release of ${key}...'
382-
echo 'downloading stable ${key} backend...'
383-
mkdir /tmp/backend
384-
curl -sSLo /tmp/backend/backend.tar.gz "https://download.jetbrains.com/product?type=release&distribution=linux&code=${productCode}"
385-
tar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend
386-
387-
echo 'configuring JB system config and caches aligned with runtime...'
388-
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend/bin/idea.properties"
389-
unset JAVA_TOOL_OPTIONS
390-
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains
391-
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains
392-
393-
echo 'running stable ${key} backend in warmup mode...'
394-
/tmp/backend/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
395-
396-
echo 'removing stable ${key} backend...'
397-
rm -rf /tmp/backend
398-
`
380+
if prebuilds.Version != "latest" {
381+
template := `
382+
echo 'warming up stable release of ${key}...'
383+
echo 'downloading stable ${key} backend...'
384+
mkdir /tmp/backend
385+
curl -sSLo /tmp/backend/backend.tar.gz "https://download.jetbrains.com/product?type=release&distribution=linux&code=${productCode}"
386+
tar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend
387+
388+
echo 'configuring JB system config and caches aligned with runtime...'
389+
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend/bin/idea.properties"
390+
unset JAVA_TOOL_OPTIONS
391+
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains
392+
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains
393+
394+
echo 'running stable ${key} backend in warmup mode...'
395+
/tmp/backend/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
396+
397+
echo 'removing stable ${key} backend...'
398+
rm -rf /tmp/backend
399+
`
400+
if code, ok := JetbrainsCode[alias]; ok {
401+
template = strings.ReplaceAll(template, "${key}", alias)
402+
template = strings.ReplaceAll(template, "${productCode}", code)
403+
warmUpTask += template
404+
}
399405
}
400406

401-
if prebuilds.Version == "stable" {
402-
warmUpTask += `
403-
echo 'warming up latest release of ${key}...'
404-
echo 'downloading latest ${key} backend...'
405-
mkdir /tmp/backend-latest
406-
curl -sSLo /tmp/backend-latest/backend-latest.tar.gz "https://download.jetbrains.com/product?type=release,eap,rc&distribution=linux&code=${productCode}"
407-
tar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest
408-
409-
echo 'configuring JB system config and caches aligned with runtime...'
410-
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend-latest/bin/idea.properties"
411-
unset JAVA_TOOL_OPTIONS
412-
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest
413-
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest
414-
415-
echo 'running ${key} backend in warmup mode...'
416-
/tmp/backend-latest/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
417-
418-
echo 'removing latest ${key} backend...'
419-
rm -rf /tmp/backend-latest
420-
`
407+
if prebuilds.Version != "stable" {
408+
template := `
409+
echo 'warming up latest release of ${key}...'
410+
echo 'downloading latest ${key} backend...'
411+
mkdir /tmp/backend-latest
412+
curl -sSLo /tmp/backend-latest/backend-latest.tar.gz "https://download.jetbrains.com/product?type=release,eap,rc&distribution=linux&code=${productCode}"
413+
tar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest
414+
415+
echo 'configuring JB system config and caches aligned with runtime...'
416+
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend-latest/bin/idea.properties"
417+
unset JAVA_TOOL_OPTIONS
418+
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest
419+
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest
420+
421+
echo 'running ${key} backend in warmup mode...'
422+
/tmp/backend-latest/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
423+
424+
echo 'removing latest ${key} backend...'
425+
rm -rf /tmp/backend-latest
426+
`
427+
if code, ok := JetbrainsCode[alias]; ok {
428+
template = strings.ReplaceAll(template, "${key}", alias)
429+
template = strings.ReplaceAll(template, "${productCode}", code)
430+
warmUpTask += template
431+
}
421432
}
422433
}
423-
424-
if warmUpTask != "" {
425-
warmUpEncoded, err := json.Marshal(Task{
426-
Init: strings.TrimSpace(warmUpTask),
427-
})
428-
if err != nil {
429-
log.WithError(err).Error("cannot marshal warm up task")
430-
}
431-
432-
resp.Tasks = string(warmUpEncoded)
434+
}
435+
if warmUpTask != "" {
436+
warmUpEncoded, err := json.Marshal([]Task{{
437+
Init: strings.TrimSpace(warmUpTask),
438+
}})
439+
if err != nil {
440+
log.WithError(err).Error("cannot marshal warm up task")
433441
}
442+
443+
resp.Tasks = string(warmUpEncoded)
434444
}
435445
}
436446
return
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Resp": {
3+
"envvars": [
4+
{
5+
"name": "GITPOD_IDE_ALIAS",
6+
"value": "intellij"
7+
}
8+
],
9+
"supervisor_image": "eu.gcr.io/gitpod-core-dev/build/supervisor:commit-ff38b98b7dde4929159bcaeec68d178898dc2139",
10+
"web_image": "eu.gcr.io/gitpod-core-dev/build/ide/code:commit-d6329814c2aa34c414574fd0d1301447d6fe82c9",
11+
"ide_image_layers": [
12+
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
13+
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
14+
],
15+
"tasks": "[{\"init\":\"echo 'warming up stable release of intellij...'\\necho 'downloading stable intellij backend...'\\nmkdir /tmp/backend\\ncurl -sSLo /tmp/backend/backend.tar.gz \\\"https://download.jetbrains.com/product?type=release\\u0026distribution=linux\\u0026code=IIU\\\"\\ntar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains\\n\\necho 'running stable intellij backend in warmup mode...'\\n/tmp/backend/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing stable intellij backend...'\\nrm -rf /tmp/backend\\n\\necho 'warming up latest release of intellij...'\\necho 'downloading latest intellij backend...'\\nmkdir /tmp/backend-latest\\ncurl -sSLo /tmp/backend-latest/backend-latest.tar.gz \\\"https://download.jetbrains.com/product?type=release,eap,rc\\u0026distribution=linux\\u0026code=IIU\\\"\\ntar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend-latest/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest\\n\\necho 'running intellij backend in warmup mode...'\\n/tmp/backend-latest/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing latest intellij backend...'\\nrm -rf /tmp/backend-latest\"}]"
16+
},
17+
"Err": ""
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": 1,
3+
"context": "{\"isFile\":false,\"path\":\"\",\"title\":\"gitpod-io/empty \",\"revision\":\"\",\"repository\":{\"cloneUrl\":\"https://github.com/gitpod-io/empty.git\",\"host\":\"github.com\",\"name\":\"empty\",\"owner\":\"gitpod-io\",\"private\":false},\"normalizedContextURL\":\"https://github.com/gitpod-io/empty\",\"checkoutLocation\":\"empty\"}",
4+
"ide_settings": "{\"settingVersion\":\"2.0\",\"defaultIde\":\"intellij\",\"useLatestVersion\":false}",
5+
"workspace_config": "{\"tasks\":[{\"init\":\"echo 'init script'\",\"command\":\"echo 'start script'\"}],\"jetbrains\":{\"intellij\":{\"prebuilds\":{\"version\":\"both\"}}},\"_origin\":\"repo\",\"image\":\"docker.io/gitpod/workspace-full:latest\",\"vscode\":{\"extensions\":[]}}"
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Resp": {
3+
"envvars": [
4+
{
5+
"name": "GITPOD_IDE_ALIAS",
6+
"value": "intellij"
7+
}
8+
],
9+
"supervisor_image": "eu.gcr.io/gitpod-core-dev/build/supervisor:commit-ff38b98b7dde4929159bcaeec68d178898dc2139",
10+
"web_image": "eu.gcr.io/gitpod-core-dev/build/ide/code:commit-d6329814c2aa34c414574fd0d1301447d6fe82c9",
11+
"ide_image_layers": [
12+
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
13+
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
14+
],
15+
"tasks": "[{\"init\":\"echo 'warming up stable release of intellij...'\\necho 'downloading stable intellij backend...'\\nmkdir /tmp/backend\\ncurl -sSLo /tmp/backend/backend.tar.gz \\\"https://download.jetbrains.com/product?type=release\\u0026distribution=linux\\u0026code=IIU\\\"\\ntar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains\\n\\necho 'running stable intellij backend in warmup mode...'\\n/tmp/backend/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing stable intellij backend...'\\nrm -rf /tmp/backend\\n\\necho 'warming up stable release of goland...'\\necho 'downloading stable goland backend...'\\nmkdir /tmp/backend\\ncurl -sSLo /tmp/backend/backend.tar.gz \\\"https://download.jetbrains.com/product?type=release\\u0026distribution=linux\\u0026code=GO\\\"\\ntar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains\\n\\necho 'running stable goland backend in warmup mode...'\\n/tmp/backend/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing stable goland backend...'\\nrm -rf /tmp/backend\\n\\necho 'warming up latest release of goland...'\\necho 'downloading latest goland backend...'\\nmkdir /tmp/backend-latest\\ncurl -sSLo /tmp/backend-latest/backend-latest.tar.gz \\\"https://download.jetbrains.com/product?type=release,eap,rc\\u0026distribution=linux\\u0026code=GO\\\"\\ntar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend-latest/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest\\n\\necho 'running goland backend in warmup mode...'\\n/tmp/backend-latest/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing latest goland backend...'\\nrm -rf /tmp/backend-latest\\n\\necho 'warming up latest release of phpstorm...'\\necho 'downloading latest phpstorm backend...'\\nmkdir /tmp/backend-latest\\ncurl -sSLo /tmp/backend-latest/backend-latest.tar.gz \\\"https://download.jetbrains.com/product?type=release,eap,rc\\u0026distribution=linux\\u0026code=PS\\\"\\ntar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest\\n\\necho 'configuring JB system config and caches aligned with runtime...'\\nprintf '\\\\nshared.indexes.download.auto.consent=true' \\u003e\\u003e \\\"/tmp/backend-latest/bin/idea.properties\\\"\\nunset JAVA_TOOL_OPTIONS\\nexport IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest\\nexport IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest\\n\\necho 'running phpstorm backend in warmup mode...'\\n/tmp/backend-latest/bin/remote-dev-server.sh warmup \\\"$GITPOD_REPO_ROOT\\\"\\n\\necho 'removing latest phpstorm backend...'\\nrm -rf /tmp/backend-latest\"}]"
16+
},
17+
"Err": ""
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": 1,
3+
"context": "{\"isFile\":false,\"path\":\"\",\"title\":\"gitpod-io/empty \",\"revision\":\"\",\"repository\":{\"cloneUrl\":\"https://github.com/gitpod-io/empty.git\",\"host\":\"github.com\",\"name\":\"empty\",\"owner\":\"gitpod-io\",\"private\":false},\"normalizedContextURL\":\"https://github.com/gitpod-io/empty\",\"checkoutLocation\":\"empty\"}",
4+
"ide_settings": "{\"settingVersion\":\"2.0\",\"defaultIde\":\"intellij\",\"useLatestVersion\":false}",
5+
"workspace_config": "{\"tasks\":[{\"init\":\"echo 'init script'\",\"command\":\"echo 'start script'\"}],\"jetbrains\":{\"intellij\":{\"prebuilds\":{\"version\":\"stable\"}},\"phpstorm\":{\"prebuilds\":{\"version\":\"latest\"}},\"goland\":{\"prebuilds\":{\"version\":\"both\"}}},\"_origin\":\"repo\",\"image\":\"docker.io/gitpod/workspace-full:latest\",\"vscode\":{\"extensions\":[]}}"
6+
}

components/server/src/ide-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class IDEService {
4646
return this.ideService.resolveWorkspaceConfig(req);
4747
}
4848

49-
resolveGitpodTasks(ws: Workspace, ideConfig: IDEConfig): TaskConfig[] {
49+
resolveGitpodTasks(ws: Workspace, ideConfig: ResolveWorkspaceConfigResponse): TaskConfig[] {
5050
const tasks: TaskConfig[] = [];
5151
if (ws.config.tasks) {
5252
tasks.push(...ws.config.tasks);
@@ -57,7 +57,6 @@ export class IDEService {
5757
tasks.push(...ideTasks);
5858
} catch (e) {
5959
console.error("failed get tasks from ide config:", e);
60-
// shall we throw?
6160
}
6261
}
6362
return tasks;

0 commit comments

Comments
 (0)