diff --git a/components/gitpod-protocol/src/workspace-instance.ts b/components/gitpod-protocol/src/workspace-instance.ts index ff6440bb444e7d..9ed22626ae9d7b 100644 --- a/components/gitpod-protocol/src/workspace-instance.ts +++ b/components/gitpod-protocol/src/workspace-instance.ts @@ -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 } diff --git a/components/server/src/ide-config.ts b/components/server/src/ide-config.ts index c033a1a9638969..7182e6d31cc7ee 100644 --- a/components/server/src/ide-config.ts +++ b/components/server/src/ide-config.ts @@ -17,6 +17,7 @@ interface RawIDEConfig { ideVersion: string; ideImageRepo: string; ideImageAliases?: { [index: string]: string }; + desktopIdeImageAliases?: { [index: string]: string }; } const scheme = { "type": "object", @@ -30,7 +31,11 @@ const scheme = { "ideImageAliases": { "type": "object", "additionalProperties": { "type": "string" } - } + }, + "desktopIdeImageAliases": { + "type": "object", + "additionalProperties": { "type": "string" } + }, }, "required": [ "ideVersion", @@ -42,7 +47,7 @@ export interface IDEConfig { ideVersion: string; ideImageRepo: string; ideImageAliases: { [index: string]: string }; - + desktopIdeImageAliases: { [index: string]: string }; ideImage: string; } @@ -112,6 +117,9 @@ export class IDEConfigService { ideImageAliases: { ...raw.ideImageAliases, "theia": ideImage, + }, + desktopIdeImageAliases: { + ...raw.desktopIdeImageAliases } } } diff --git a/components/server/src/workspace/workspace-starter.ts b/components/server/src/workspace/workspace-starter.ts index 4b3e7da148706c..03e0ebc3c07a22 100644 --- a/components/server/src/workspace/workspace-starter.ts +++ b/components/server/src/workspace/workspace-starter.ts @@ -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) { @@ -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));