Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use workspace name
  • Loading branch information
mustard-mh committed Jan 24, 2025
commit 1cccea43c0debd34f11340833d27d49c080bd05a
13 changes: 3 additions & 10 deletions components/dashboard/src/workspaces/RenameWorkspaceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ import { Button } from "@podkit/buttons/Button";
import { Workspace } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
import { useUpdateWorkspaceMutation } from "../data/workspaces/update-workspace-mutation";
import { LoadingButton } from "@podkit/buttons/LoadingButton";
import { Workspace as WorkspaceProtocol } from "@gitpod/gitpod-protocol";

export const NAME_PREFIX = "named:";
export function toWorkspaceName(name: string): string {
// unsetting the name
if (name.trim().length === 0) {
return "no-name";
}
return `${NAME_PREFIX}${name}`;
return WorkspaceProtocol.toWorkspaceName(name);
}

export function fromWorkspaceName(workspace?: Workspace): string | undefined {
if (workspace?.metadata?.name?.startsWith(NAME_PREFIX)) {
return workspace.metadata.name.slice(NAME_PREFIX.length);
}
return undefined;
return WorkspaceProtocol.fromWorkspaceName(workspace?.metadata?.name);
}

type Props = {
Expand Down
14 changes: 14 additions & 0 deletions components/gitpod-protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,20 @@ export namespace Workspace {
}
return undefined;
}

const NAME_PREFIX = "named:";
export function fromWorkspaceName(name?: Workspace["description"]): string | undefined {
if (name?.startsWith(NAME_PREFIX)) {
return name.slice(NAME_PREFIX.length);
}
return undefined;
}
export function toWorkspaceName(name?: Workspace["description"]): string {
if (!name || name?.trim().length === 0) {
return "no-name";
}
return `${NAME_PREFIX}${name}`;
}
}

export interface GuessGitTokenScopesParams {
Expand Down
6 changes: 4 additions & 2 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1587,10 +1587,12 @@ export class WorkspaceStarter {
sysEnvvars.push(isSetJavaXmx);
sysEnvvars.push(isSetJavaProcessorCount);
sysEnvvars.push(disableJetBrainsLocalPortForwarding);
if (workspace.context.title) {

const workspaceName = Workspace.fromWorkspaceName(workspace.description);
if (workspaceName && workspaceName.length > 0) {
const workspaceNameEnv = new EnvironmentVariable();
workspaceNameEnv.setName("GITPOD_WORKSPACE_NAME");
workspaceNameEnv.setValue(workspace.context.title);
workspaceNameEnv.setValue(workspaceName);
sysEnvvars.push(workspaceNameEnv);
}
const spec = new StartWorkspaceSpec();
Expand Down
Loading