Skip to content

Commit d07641d

Browse files
akosyakoviQQBotfelladrinAndrea Falzetti
committed
[server] move workspace ide configuration to ide service
Co-authored-by: Pudong Zheng <[email protected]> Co-authored-by: Victor Nogueira <[email protected]> Co-authored-by: Andrea Falzetti <[email protected]>
1 parent a5d6744 commit d07641d

File tree

8 files changed

+468
-459
lines changed

8 files changed

+468
-459
lines changed

components/gitpod-protocol/src/workspace-instance.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,16 @@ export interface WorkspaceInstanceConfiguration {
243243
// ideImage is the ref of the IDE image this instance uses.
244244
ideImage: string;
245245

246+
// ideImageLayers are images needed for the ide to run,
247+
// including ide-desktop, desktop-plugin and so on
248+
ideImageLayers?: string[];
249+
246250
// desktopIdeImage is the ref of the desktop IDE image this instance uses.
251+
// @deprected: replaced with the ideImageLayers field
247252
desktopIdeImage?: string;
248253

249254
// desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
255+
// @deprected: replaced with the desktopIdePluginImage field
250256
desktopIdePluginImage?: string;
251257

252258
// supervisorImage is the ref of the supervisor image this instance uses.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package server
66

77
import (
8+
"bytes"
89
"context"
910
"encoding/json"
1011
"fmt"
@@ -417,14 +418,18 @@ rm -rf /tmp/backend-latest
417418
}
418419
}
419420
if warmUpTask != "" {
420-
warmUpEncoded, err := json.Marshal([]gitpodapi.TaskConfig{{
421+
warmUpEncoded := new(bytes.Buffer)
422+
enc := json.NewEncoder(warmUpEncoded)
423+
enc.SetEscapeHTML(false)
424+
425+
err := enc.Encode(&[]gitpodapi.TaskConfig{{
421426
Init: strings.TrimSpace(warmUpTask),
422427
}})
423428
if err != nil {
424429
log.WithError(err).Error("cannot marshal warm up task")
425430
}
426431

427-
resp.Tasks = string(warmUpEncoded)
432+
resp.Tasks = warmUpEncoded.String()
428433
}
429434
}
430435
return

components/ide-service/pkg/server/testdata/resolve_ws_config_prebuild_intellij.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
1313
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
1414
],
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\"}]"
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\"}]\n"
1616
},
1717
"Err": ""
18-
}
18+
}

components/ide-service/pkg/server/testdata/resolve_ws_config_prebuild_multiple_ide.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
1313
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
1414
],
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\"}]"
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\"}]\n"
1616
},
1717
"Err": ""
18-
}
18+
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/**
2+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { User } from "@gitpod/gitpod-protocol";
8+
import * as chai from "chai";
9+
import { IDEService } from "./ide-service";
10+
const expect = chai.expect;
11+
12+
describe("ide-service", function () {
13+
describe("migrateSettings", function () {
14+
const ideService = new IDEService();
15+
it("with no ideSettings should be undefined", function () {
16+
const user: User = {
17+
id: "string",
18+
19+
creationDate: "string",
20+
identities: [],
21+
additionalData: {},
22+
};
23+
const result = ideService.migrateSettings(user);
24+
expect(result).to.undefined;
25+
});
26+
27+
it("with settingVersion 2.0 should be undefined", function () {
28+
const user: User = {
29+
id: "string",
30+
creationDate: "string",
31+
identities: [],
32+
additionalData: {
33+
ideSettings: {
34+
settingVersion: "2.0",
35+
defaultIde: "code-latest",
36+
useDesktopIde: false,
37+
},
38+
},
39+
};
40+
const result = ideService.migrateSettings(user);
41+
expect(result).to.undefined;
42+
});
43+
44+
it("with code-latest should be code latest", function () {
45+
const user: User = {
46+
id: "string",
47+
creationDate: "string",
48+
identities: [],
49+
additionalData: {
50+
ideSettings: {
51+
defaultIde: "code-latest",
52+
useDesktopIde: false,
53+
},
54+
},
55+
};
56+
const result = ideService.migrateSettings(user);
57+
expect(result?.defaultIde).to.equal("code");
58+
expect(result?.useLatestVersion ?? false).to.be.true;
59+
});
60+
61+
it("with code-desktop-insiders should be code-desktop latest", function () {
62+
const user: User = {
63+
id: "string",
64+
creationDate: "string",
65+
identities: [],
66+
additionalData: {
67+
ideSettings: {
68+
defaultIde: "code",
69+
defaultDesktopIde: "code-desktop-insiders",
70+
useDesktopIde: true,
71+
},
72+
},
73+
};
74+
const result = ideService.migrateSettings(user);
75+
expect(result?.defaultIde).to.equal("code-desktop");
76+
expect(result?.useLatestVersion ?? false).to.be.true;
77+
});
78+
79+
it("with code-desktop should be code-desktop", function () {
80+
const user: User = {
81+
id: "string",
82+
creationDate: "string",
83+
identities: [],
84+
additionalData: {
85+
ideSettings: {
86+
defaultIde: "code",
87+
defaultDesktopIde: "code-desktop",
88+
useDesktopIde: true,
89+
},
90+
},
91+
};
92+
const result = ideService.migrateSettings(user);
93+
expect(result?.defaultIde).to.equal("code-desktop");
94+
expect(result?.useLatestVersion ?? false).to.be.false;
95+
});
96+
97+
it("with intellij should be intellij", function () {
98+
const user: User = {
99+
id: "string",
100+
creationDate: "string",
101+
identities: [],
102+
additionalData: {
103+
ideSettings: {
104+
defaultIde: "code",
105+
defaultDesktopIde: "intellij",
106+
useLatestVersion: false,
107+
useDesktopIde: true,
108+
},
109+
},
110+
};
111+
const result = ideService.migrateSettings(user);
112+
expect(result?.defaultIde).to.equal("intellij");
113+
expect(result?.useLatestVersion ?? false).to.be.false;
114+
});
115+
116+
it("with intellij latest version should be intellij latest", function () {
117+
const user: User = {
118+
id: "string",
119+
creationDate: "string",
120+
identities: [],
121+
additionalData: {
122+
ideSettings: {
123+
defaultIde: "code",
124+
defaultDesktopIde: "intellij",
125+
useLatestVersion: true,
126+
useDesktopIde: true,
127+
},
128+
},
129+
};
130+
const result = ideService.migrateSettings(user);
131+
expect(result?.defaultIde).to.equal("intellij");
132+
expect(result?.useLatestVersion ?? false).to.be.true;
133+
});
134+
135+
it("with user desktopIde false should be code latest", function () {
136+
const user: User = {
137+
id: "string",
138+
creationDate: "string",
139+
identities: [],
140+
additionalData: {
141+
ideSettings: {
142+
defaultIde: "code-latest",
143+
defaultDesktopIde: "intellij",
144+
useLatestVersion: false,
145+
useDesktopIde: false,
146+
},
147+
},
148+
};
149+
const result = ideService.migrateSettings(user);
150+
expect(result?.defaultIde).to.equal("code");
151+
expect(result?.useLatestVersion ?? false).to.be.true;
152+
});
153+
});
154+
});

0 commit comments

Comments
 (0)