Skip to content

Commit

Permalink
[server] Pass selected desktop IDE to ws-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusludmann committed Oct 25, 2021
1 parent 1d01b3d commit c931375
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,7 @@ export interface WorkspaceInstanceConfiguration {

// ideImage is the ref of the IDE image this instance uses.
ideImage: string;

// desktopIdeImage is the ref of the desktop IDE image this instance uses.
desktopIdeImage?: string
}
12 changes: 10 additions & 2 deletions components/server/src/ide-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface RawIDEConfig {
ideVersion: string;
ideImageRepo: string;
ideImageAliases?: { [index: string]: string };
desktopIdeImageAliases?: { [index: string]: string };
}
const scheme = {
"type": "object",
Expand All @@ -30,7 +31,11 @@ const scheme = {
"ideImageAliases": {
"type": "object",
"additionalProperties": { "type": "string" }
}
},
"desktopIdeImageAliases": {
"type": "object",
"additionalProperties": { "type": "string" }
},
},
"required": [
"ideVersion",
Expand All @@ -42,7 +47,7 @@ export interface IDEConfig {
ideVersion: string;
ideImageRepo: string;
ideImageAliases: { [index: string]: string };

desktopIdeImageAliases: { [index: string]: string };
ideImage: string;
}

Expand Down Expand Up @@ -112,6 +117,9 @@ export class IDEConfigService {
ideImageAliases: {
...raw.ideImageAliases,
"theia": ideImage,
},
desktopIdeImageAliases: {
...raw.desktopIdeImageAliases
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ export class WorkspaceStarter {
}
}

const useDesktopIdeChoice = user.additionalData?.ideSettings?.useDesktopIde || false;
if (useDesktopIdeChoice) {
const desktopIdeChoice = user.additionalData?.ideSettings?.defaultDesktopIde;
if (!!desktopIdeChoice) {
const mappedImage = ideConfig.desktopIdeImageAliases[desktopIdeChoice];
if (!!mappedImage) {
configuration.desktopIdeImage = mappedImage;
} else if (this.authService.hasPermission(user, "ide-settings")) {
// if the IDE choice isn't one of the preconfiured choices, we assume its the image name.
// For now, this feature requires special permissions.
configuration.desktopIdeImage = desktopIdeChoice;
}
}
}

let featureFlags: NamedWorkspaceFeatureFlag[] = workspace.config._featureFlags || [];
featureFlags = featureFlags.concat(this.config.workspaceDefaults.defaultFeatureFlags);
if (user.featureFlags && user.featureFlags.permanentWSFeatureFlags) {
Expand Down Expand Up @@ -724,6 +739,7 @@ export class WorkspaceStarter {
spec.setPortsList(ports);
spec.setInitializer((await initializerPromise).initializer);
spec.setIdeImage(ideImage);
spec.setDesktopIdeImage(instance.configuration?.desktopIdeImage || "");
spec.setWorkspaceImage(instance.workspaceImage);
spec.setWorkspaceLocation(workspace.config.workspaceLocation || spec.getCheckoutLocation());
spec.setFeatureFlagsList(this.toWorkspaceFeatureFlags(featureFlags));
Expand Down

0 comments on commit c931375

Please sign in to comment.