Skip to content

Commit 4f57605

Browse files
committed
[TEST COMMIT] test only, need remove before merge
1 parent c3d491c commit 4f57605

File tree

4 files changed

+80
-341
lines changed

4 files changed

+80
-341
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ func (s *IDEServiceServer) resolveReferrerIDE(ideConfig *config.IDEConfig, wsCtx
243243
}
244244

245245
func (s *IDEServiceServer) ResolveWorkspaceConfig(ctx context.Context, req *api.ResolveWorkspaceConfigRequest) (resp *api.ResolveWorkspaceConfigResponse, err error) {
246-
log.WithField("req", req).Debug("receive ResolveWorkspaceConfig request")
246+
// TODO: need change to debug, before merge PR
247+
log.WithField("req", req).Info("receive ResolveWorkspaceConfig request")
247248

248249
// make a copy for ref ideConfig, it's safe because we replace ref in update config
249250
ideConfig := s.ideConfig

components/server/src/ide-service.ts

Lines changed: 18 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
import { JetBrainsConfig, TaskConfig, Workspace } from "@gitpod/gitpod-protocol";
7+
import { TaskConfig, Workspace } from "@gitpod/gitpod-protocol";
88
import { IDEOptions, IDEClient } from "@gitpod/gitpod-protocol/lib/ide-protocol";
9-
import { IDEServiceClient, IDEServiceDefinition } from "@gitpod/ide-service-api/lib/ide.pb";
9+
import {
10+
IDEServiceClient,
11+
IDEServiceDefinition,
12+
ResolveWorkspaceConfigRequest,
13+
ResolveWorkspaceConfigResponse,
14+
} from "@gitpod/ide-service-api/lib/ide.pb";
1015
import { inject, injectable } from "inversify";
1116

1217
export interface IDEConfig {
@@ -37,85 +42,21 @@ export class IDEService {
3742
}
3843
}
3944

40-
resolveGitpodTasks(ws: Workspace): TaskConfig[] {
45+
async resolveWorkspaceConfig(req: ResolveWorkspaceConfigRequest): Promise<ResolveWorkspaceConfigResponse> {
46+
return this.ideService.resolveWorkspaceConfig(req);
47+
}
48+
49+
resolveGitpodTasks(ws: Workspace, ideConfig: ResolveWorkspaceConfigResponse): TaskConfig[] {
4150
const tasks: TaskConfig[] = [];
4251
if (ws.config.tasks) {
4352
tasks.push(...ws.config.tasks);
4453
}
45-
// TODO(ak) it is a hack to get users going, we should rather layer JB products on prebuild workspaces and move logic to corresponding images
46-
if (ws.type === "prebuild" && ws.config.jetbrains) {
47-
let warmUp = "";
48-
for (const key in ws.config.jetbrains) {
49-
let productCode;
50-
if (key === "intellij") {
51-
productCode = "IIU";
52-
} else if (key === "goland") {
53-
productCode = "GO";
54-
} else if (key === "pycharm") {
55-
productCode = "PCP";
56-
} else if (key === "phpstorm") {
57-
productCode = "PS";
58-
} else if (key === "rubymine") {
59-
productCode = "RM";
60-
} else if (key === "webstorm") {
61-
productCode = "WS";
62-
} else if (key === "rider") {
63-
productCode = "RD";
64-
} else if (key === "clion") {
65-
productCode = "CL";
66-
}
67-
const prebuilds = productCode && ws.config.jetbrains[key as keyof JetBrainsConfig]?.prebuilds;
68-
if (prebuilds) {
69-
warmUp +=
70-
prebuilds.version === "latest"
71-
? ""
72-
: `
73-
echo 'warming up stable release of ${key}...'
74-
echo 'downloading stable ${key} backend...'
75-
mkdir /tmp/backend
76-
curl -sSLo /tmp/backend/backend.tar.gz "https://download.jetbrains.com/product?type=release&distribution=linux&code=${productCode}"
77-
tar -xf /tmp/backend/backend.tar.gz --strip-components=1 --directory /tmp/backend
78-
79-
echo 'configuring JB system config and caches aligned with runtime...'
80-
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend/bin/idea.properties"
81-
unset JAVA_TOOL_OPTIONS
82-
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains
83-
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains
84-
85-
echo 'running stable ${key} backend in warmup mode...'
86-
/tmp/backend/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
87-
88-
echo 'removing stable ${key} backend...'
89-
rm -rf /tmp/backend
90-
`;
91-
warmUp +=
92-
prebuilds.version === "stable"
93-
? ""
94-
: `
95-
echo 'warming up latest release of ${key}...'
96-
echo 'downloading latest ${key} backend...'
97-
mkdir /tmp/backend-latest
98-
curl -sSLo /tmp/backend-latest/backend-latest.tar.gz "https://download.jetbrains.com/product?type=release,eap,rc&distribution=linux&code=${productCode}"
99-
tar -xf /tmp/backend-latest/backend-latest.tar.gz --strip-components=1 --directory /tmp/backend-latest
100-
101-
echo 'configuring JB system config and caches aligned with runtime...'
102-
printf '\nshared.indexes.download.auto.consent=true' >> "/tmp/backend-latest/bin/idea.properties"
103-
unset JAVA_TOOL_OPTIONS
104-
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains-latest
105-
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains-latest
106-
107-
echo 'running ${key} backend in warmup mode...'
108-
/tmp/backend-latest/bin/remote-dev-server.sh warmup "$GITPOD_REPO_ROOT"
109-
110-
echo 'removing latest ${key} backend...'
111-
rm -rf /tmp/backend-latest
112-
`;
113-
}
114-
}
115-
if (warmUp) {
116-
tasks.push({
117-
init: warmUp.trim(),
118-
});
54+
if (ideConfig.tasks) {
55+
try {
56+
let ideTasks: TaskConfig[] = JSON.parse(ideConfig.tasks);
57+
tasks.push(...ideTasks);
58+
} catch (e) {
59+
console.error("failed get tasks from ide config:", e);
11960
}
12061
}
12162
return tasks;

components/server/src/workspace/workspace-starter.spec.ts

Lines changed: 1 addition & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*/
66

77
import { User } from "@gitpod/gitpod-protocol";
8-
import { IDEOption, IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol";
98
import * as chai from "chai";
10-
import { migrationIDESettings, chooseIDE } from "./workspace-starter";
9+
import { migrationIDESettings } from "./workspace-starter";
1110
const expect = chai.expect;
1211

1312
describe("workspace-starter", function () {
@@ -150,118 +149,4 @@ describe("workspace-starter", function () {
150149
expect(result?.useLatestVersion ?? false).to.be.true;
151150
});
152151
});
153-
describe("chooseIDE", async function () {
154-
const baseOpt: IDEOption = {
155-
title: "title",
156-
type: "desktop",
157-
logo: "",
158-
image: "image",
159-
latestImage: "latestImage",
160-
};
161-
const ideOptions: IDEOptions = {
162-
options: {
163-
code: Object.assign({}, baseOpt, { type: "browser" }),
164-
goland: Object.assign({}, baseOpt),
165-
"code-desktop": Object.assign({}, baseOpt),
166-
"no-latest": Object.assign({}, baseOpt),
167-
},
168-
defaultIde: "code",
169-
defaultDesktopIde: "code-desktop",
170-
};
171-
delete ideOptions.options["no-latest"].latestImage;
172-
173-
it("code with latest", function () {
174-
const useLatest = true;
175-
const hasPerm = false;
176-
const result = chooseIDE("code", ideOptions, useLatest, hasPerm);
177-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
178-
});
179-
180-
it("code without latest", function () {
181-
const useLatest = false;
182-
const hasPerm = false;
183-
const result = chooseIDE("code", ideOptions, useLatest, hasPerm);
184-
expect(result.ideImage).to.equal(ideOptions.options["code"].image);
185-
});
186-
187-
it("desktop ide with latest", function () {
188-
const useLatest = true;
189-
const hasPerm = false;
190-
const result = chooseIDE("code-desktop", ideOptions, useLatest, hasPerm);
191-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
192-
expect(result.desktopIdeImage).to.equal(ideOptions.options["code-desktop"].latestImage);
193-
});
194-
195-
it("desktop ide (JetBrains) without latest", function () {
196-
const useLatest = false;
197-
const hasPerm = false;
198-
const result = chooseIDE("goland", ideOptions, useLatest, hasPerm);
199-
expect(result.ideImage).to.equal(ideOptions.options["code"].image);
200-
expect(result.desktopIdeImage).to.equal(ideOptions.options["goland"].image);
201-
});
202-
203-
it("desktop ide with no latest image", function () {
204-
const useLatest = true;
205-
const hasPerm = false;
206-
const result = chooseIDE("no-latest", ideOptions, useLatest, hasPerm);
207-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
208-
expect(result.desktopIdeImage).to.equal(ideOptions.options["no-latest"].image);
209-
});
210-
211-
it("unknown ide with custom permission should be unknown", function () {
212-
const customOptions = Object.assign({}, ideOptions);
213-
customOptions.options["unknown-custom"] = {
214-
title: "unknown title",
215-
type: "browser",
216-
logo: "",
217-
image: "",
218-
};
219-
const useLatest = true;
220-
const hasPerm = true;
221-
const result = chooseIDE("unknown-custom", customOptions, useLatest, hasPerm);
222-
expect(result.ideImage).to.equal("unknown-custom");
223-
});
224-
225-
it("unknown desktop ide with custom permission desktop should be unknown", function () {
226-
const customOptions = Object.assign({}, ideOptions);
227-
customOptions.options["unknown-custom"] = {
228-
title: "unknown title",
229-
type: "desktop",
230-
logo: "",
231-
image: "",
232-
};
233-
const useLatest = true;
234-
const hasPerm = true;
235-
const result = chooseIDE("unknown-custom", customOptions, useLatest, hasPerm);
236-
expect(result.desktopIdeImage).to.equal("unknown-custom");
237-
});
238-
239-
it("unknown browser ide without custom permission should fallback to code", function () {
240-
const customOptions = Object.assign({}, ideOptions);
241-
customOptions.options["unknown-custom"] = {
242-
title: "unknown title",
243-
type: "browser",
244-
logo: "",
245-
image: "",
246-
};
247-
const useLatest = true;
248-
const hasPerm = false;
249-
const result = chooseIDE("unknown-custom", customOptions, useLatest, hasPerm);
250-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
251-
});
252-
253-
it("not exists ide with custom permission", function () {
254-
const useLatest = true;
255-
const hasPerm = true;
256-
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
257-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
258-
});
259-
260-
it("not exists ide with custom permission", function () {
261-
const useLatest = true;
262-
const hasPerm = false;
263-
const result = chooseIDE("not-exists", ideOptions, useLatest, hasPerm);
264-
expect(result.ideImage).to.equal(ideOptions.options["code"].latestImage);
265-
});
266-
});
267152
});

0 commit comments

Comments
 (0)