Skip to content

Migrate workspaceService updatePort method #19234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions components/dashboard/src/service/json-rpc-workspace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import {
CreateWorkspaceSnapshotResponse,
WaitForWorkspaceSnapshotRequest,
WaitForWorkspaceSnapshotResponse,
UpdateWorkspacePortRequest,
UpdateWorkspacePortResponse,
WorkspacePort_Protocol,
} from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
import { converter } from "./public-api";
import { getGitpodService } from "./service";
Expand Down Expand Up @@ -393,4 +396,25 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
await getGitpodService().server.waitForSnapshot(req.snapshotId);
return new WaitForWorkspaceSnapshotResponse();
}

async updateWorkspacePort(
req: PartialMessage<UpdateWorkspacePortRequest>,
_options?: CallOptions | undefined,
): Promise<UpdateWorkspacePortResponse> {
if (!req.workspaceId) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "workspaceId is required");
}
if (!req.port) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "port is required");
}
if (!req.admission && !req.protocol) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "admission or protocol is required");
}
getGitpodService().server.openPort(req.workspaceId, {
port: Number(req.port),
visibility: req.admission ? (req.admission === AdmissionLevel.EVERYONE ? "public" : "private") : undefined,
protocol: req.protocol ? (req.protocol === WorkspacePort_Protocol.HTTPS ? "https" : "http") : undefined,
});
return new UpdateWorkspacePortResponse();
}
}
23 changes: 23 additions & 0 deletions components/public-api/gitpod/v1/workspace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,31 @@ service WorkspaceService {

// WaitWorkspaceSnapshot waits for the snapshot to be available or failed.
rpc WaitForWorkspaceSnapshot(WaitForWorkspaceSnapshotRequest) returns (WaitForWorkspaceSnapshotResponse) {}

// UpdateWorkspacePort updates the port of workspace.
rpc UpdateWorkspacePort(UpdateWorkspacePortRequest) returns (UpdateWorkspacePortResponse) {}
}

message UpdateWorkspacePortRequest {
// workspace_id specifies the workspace to update port
//
// +required
string workspace_id = 1;

// port number
//
// +required
uint64 port = 2;

// admission controls the policy of this port
optional AdmissionLevel admission = 3;

// backend protocol of this port
optional WorkspacePort.Protocol protocol = 4;
}

message UpdateWorkspacePortResponse {}

message GetWorkspaceRequest {
// workspace_id specifies the workspace to get
//
Expand Down
24 changes: 24 additions & 0 deletions components/public-api/go/v1/v1connect/workspace.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading