Skip to content

Commit 0b1e5d4

Browse files
authored
Migrate workspaceService updatePort method (#19234)
* Migrate workspaceService updatePort method * fix build * fixbuild
1 parent 99ad568 commit 0b1e5d4

File tree

11 files changed

+1549
-1124
lines changed

11 files changed

+1549
-1124
lines changed

components/dashboard/src/service/json-rpc-workspace-client.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ import {
4343
CreateWorkspaceSnapshotResponse,
4444
WaitForWorkspaceSnapshotRequest,
4545
WaitForWorkspaceSnapshotResponse,
46+
UpdateWorkspacePortRequest,
47+
UpdateWorkspacePortResponse,
48+
WorkspacePort_Protocol,
4649
} from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
4750
import { converter } from "./public-api";
4851
import { getGitpodService } from "./service";
@@ -393,4 +396,25 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
393396
await getGitpodService().server.waitForSnapshot(req.snapshotId);
394397
return new WaitForWorkspaceSnapshotResponse();
395398
}
399+
400+
async updateWorkspacePort(
401+
req: PartialMessage<UpdateWorkspacePortRequest>,
402+
_options?: CallOptions | undefined,
403+
): Promise<UpdateWorkspacePortResponse> {
404+
if (!req.workspaceId) {
405+
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "workspaceId is required");
406+
}
407+
if (!req.port) {
408+
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "port is required");
409+
}
410+
if (!req.admission && !req.protocol) {
411+
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "admission or protocol is required");
412+
}
413+
getGitpodService().server.openPort(req.workspaceId, {
414+
port: Number(req.port),
415+
visibility: req.admission ? (req.admission === AdmissionLevel.EVERYONE ? "public" : "private") : undefined,
416+
protocol: req.protocol ? (req.protocol === WorkspacePort_Protocol.HTTPS ? "https" : "http") : undefined,
417+
});
418+
return new UpdateWorkspacePortResponse();
419+
}
396420
}

components/public-api/gitpod/v1/workspace.proto

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,31 @@ service WorkspaceService {
7070

7171
// WaitWorkspaceSnapshot waits for the snapshot to be available or failed.
7272
rpc WaitForWorkspaceSnapshot(WaitForWorkspaceSnapshotRequest) returns (WaitForWorkspaceSnapshotResponse) {}
73+
74+
// UpdateWorkspacePort updates the port of workspace.
75+
rpc UpdateWorkspacePort(UpdateWorkspacePortRequest) returns (UpdateWorkspacePortResponse) {}
76+
}
77+
78+
message UpdateWorkspacePortRequest {
79+
// workspace_id specifies the workspace to update port
80+
//
81+
// +required
82+
string workspace_id = 1;
83+
84+
// port number
85+
//
86+
// +required
87+
uint64 port = 2;
88+
89+
// admission controls the policy of this port
90+
optional AdmissionLevel admission = 3;
91+
92+
// backend protocol of this port
93+
optional WorkspacePort.Protocol protocol = 4;
7394
}
7495

96+
message UpdateWorkspacePortResponse {}
97+
7598
message GetWorkspaceRequest {
7699
// workspace_id specifies the workspace to get
77100
//

components/public-api/go/v1/v1connect/workspace.connect.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/public-api/go/v1/v1connect/workspace.proxy.connect.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)