Skip to content

Commit

Permalink
[server] move workspace ide configuration to ide service
Browse files Browse the repository at this point in the history
Co-authored-by: Pudong Zheng <[email protected]>
Co-authored-by: Victor Nogueira <[email protected]>
Co-authored-by: Andrea Falzetti <[email protected]>
  • Loading branch information
4 people committed Dec 5, 2022
1 parent a5d6744 commit d07641d
Show file tree
Hide file tree
Showing 8 changed files with 468 additions and 459 deletions.
6 changes: 6 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,16 @@ export interface WorkspaceInstanceConfiguration {
// ideImage is the ref of the IDE image this instance uses.
ideImage: string;

// ideImageLayers are images needed for the ide to run,
// including ide-desktop, desktop-plugin and so on
ideImageLayers?: string[];

// desktopIdeImage is the ref of the desktop IDE image this instance uses.
// @deprected: replaced with the ideImageLayers field
desktopIdeImage?: string;

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

// supervisorImage is the ref of the supervisor image this instance uses.
Expand Down
9 changes: 7 additions & 2 deletions components/ide-service/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package server

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -417,14 +418,18 @@ rm -rf /tmp/backend-latest
}
}
if warmUpTask != "" {
warmUpEncoded, err := json.Marshal([]gitpodapi.TaskConfig{{
warmUpEncoded := new(bytes.Buffer)
enc := json.NewEncoder(warmUpEncoded)
enc.SetEscapeHTML(false)

err := enc.Encode(&[]gitpodapi.TaskConfig{{
Init: strings.TrimSpace(warmUpTask),
}})
if err != nil {
log.WithError(err).Error("cannot marshal warm up task")
}

resp.Tasks = string(warmUpEncoded)
resp.Tasks = warmUpEncoded.String()
}
}
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
],
"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\"}]"
"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"
},
"Err": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-9a6c79a91b2b1f583d5bcb7f9f1ef54ee977e0df",
"eu.gcr.io/gitpod-core-dev/build/ide/jb-backend-plugin:commit-b38092639d1783a1957894ddd4f492b3cdc9794a"
],
"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\"}]"
"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"
},
"Err": ""
}
}
154 changes: 154 additions & 0 deletions components/server/src/ide-service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import { User } from "@gitpod/gitpod-protocol";
import * as chai from "chai";
import { IDEService } from "./ide-service";
const expect = chai.expect;

describe("ide-service", function () {
describe("migrateSettings", function () {
const ideService = new IDEService();
it("with no ideSettings should be undefined", function () {
const user: User = {
id: "string",

creationDate: "string",
identities: [],
additionalData: {},
};
const result = ideService.migrateSettings(user);
expect(result).to.undefined;
});

it("with settingVersion 2.0 should be undefined", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
settingVersion: "2.0",
defaultIde: "code-latest",
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result).to.undefined;
});

it("with code-latest should be code latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code-latest",
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with code-desktop-insiders should be code-desktop latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "code-desktop-insiders",
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code-desktop");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with code-desktop should be code-desktop", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "code-desktop",
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code-desktop");
expect(result?.useLatestVersion ?? false).to.be.false;
});

it("with intellij should be intellij", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "intellij",
useLatestVersion: false,
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("intellij");
expect(result?.useLatestVersion ?? false).to.be.false;
});

it("with intellij latest version should be intellij latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code",
defaultDesktopIde: "intellij",
useLatestVersion: true,
useDesktopIde: true,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("intellij");
expect(result?.useLatestVersion ?? false).to.be.true;
});

it("with user desktopIde false should be code latest", function () {
const user: User = {
id: "string",
creationDate: "string",
identities: [],
additionalData: {
ideSettings: {
defaultIde: "code-latest",
defaultDesktopIde: "intellij",
useLatestVersion: false,
useDesktopIde: false,
},
},
};
const result = ideService.migrateSettings(user);
expect(result?.defaultIde).to.equal("code");
expect(result?.useLatestVersion ?? false).to.be.true;
});
});
});
Loading

0 comments on commit d07641d

Please sign in to comment.