Merge pull request #6830 from dmgardiner25/rebuild-container-grpc

Rebuild container using gRPC client
This commit is contained in:
David Gardiner 2023-01-10 09:23:26 -08:00 committed by GitHub
commit 411181d14d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 667 additions and 314 deletions

View file

@ -0,0 +1,227 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.21.12
// source: codespace/codespace_host_service.v1.proto
package codespace
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type RebuildContainerRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Incremental *bool `protobuf:"varint,1,opt,name=Incremental,proto3,oneof" json:"Incremental,omitempty"`
}
func (x *RebuildContainerRequest) Reset() {
*x = RebuildContainerRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_codespace_codespace_host_service_v1_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RebuildContainerRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RebuildContainerRequest) ProtoMessage() {}
func (x *RebuildContainerRequest) ProtoReflect() protoreflect.Message {
mi := &file_codespace_codespace_host_service_v1_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RebuildContainerRequest.ProtoReflect.Descriptor instead.
func (*RebuildContainerRequest) Descriptor() ([]byte, []int) {
return file_codespace_codespace_host_service_v1_proto_rawDescGZIP(), []int{0}
}
func (x *RebuildContainerRequest) GetIncremental() bool {
if x != nil && x.Incremental != nil {
return *x.Incremental
}
return false
}
type RebuildContainerResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RebuildContainer bool `protobuf:"varint,1,opt,name=RebuildContainer,proto3" json:"RebuildContainer,omitempty"`
}
func (x *RebuildContainerResponse) Reset() {
*x = RebuildContainerResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_codespace_codespace_host_service_v1_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RebuildContainerResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RebuildContainerResponse) ProtoMessage() {}
func (x *RebuildContainerResponse) ProtoReflect() protoreflect.Message {
mi := &file_codespace_codespace_host_service_v1_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RebuildContainerResponse.ProtoReflect.Descriptor instead.
func (*RebuildContainerResponse) Descriptor() ([]byte, []int) {
return file_codespace_codespace_host_service_v1_proto_rawDescGZIP(), []int{1}
}
func (x *RebuildContainerResponse) GetRebuildContainer() bool {
if x != nil {
return x.RebuildContainer
}
return false
}
var File_codespace_codespace_host_service_v1_proto protoreflect.FileDescriptor
var file_codespace_codespace_host_service_v1_proto_rawDesc = []byte{
0x0a, 0x29, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x63, 0x6f, 0x64, 0x65,
0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x43, 0x6f, 0x64,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x64,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x2e, 0x76, 0x31, 0x22, 0x50, 0x0a, 0x17, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43,
0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x25, 0x0a, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x49, 0x6e, 0x63, 0x72, 0x65,
0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x22, 0x46, 0x0a, 0x18, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c,
0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6e,
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x52, 0x65,
0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x32, 0xae,
0x01, 0x0a, 0x0d, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x6f, 0x73, 0x74,
0x12, 0x9c, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x74,
0x61, 0x69, 0x6e, 0x65, 0x72, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x12, 0x40, 0x2e, 0x43, 0x6f, 0x64,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x64,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x74,
0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x43,
0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x43,
0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x6f,
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42,
0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_codespace_codespace_host_service_v1_proto_rawDescOnce sync.Once
file_codespace_codespace_host_service_v1_proto_rawDescData = file_codespace_codespace_host_service_v1_proto_rawDesc
)
func file_codespace_codespace_host_service_v1_proto_rawDescGZIP() []byte {
file_codespace_codespace_host_service_v1_proto_rawDescOnce.Do(func() {
file_codespace_codespace_host_service_v1_proto_rawDescData = protoimpl.X.CompressGZIP(file_codespace_codespace_host_service_v1_proto_rawDescData)
})
return file_codespace_codespace_host_service_v1_proto_rawDescData
}
var file_codespace_codespace_host_service_v1_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_codespace_codespace_host_service_v1_proto_goTypes = []interface{}{
(*RebuildContainerRequest)(nil), // 0: Codespaces.Grpc.CodespaceHostService.v1.RebuildContainerRequest
(*RebuildContainerResponse)(nil), // 1: Codespaces.Grpc.CodespaceHostService.v1.RebuildContainerResponse
}
var file_codespace_codespace_host_service_v1_proto_depIdxs = []int32{
0, // 0: Codespaces.Grpc.CodespaceHostService.v1.CodespaceHost.RebuildContainerAsync:input_type -> Codespaces.Grpc.CodespaceHostService.v1.RebuildContainerRequest
1, // 1: Codespaces.Grpc.CodespaceHostService.v1.CodespaceHost.RebuildContainerAsync:output_type -> Codespaces.Grpc.CodespaceHostService.v1.RebuildContainerResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_codespace_codespace_host_service_v1_proto_init() }
func file_codespace_codespace_host_service_v1_proto_init() {
if File_codespace_codespace_host_service_v1_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_codespace_codespace_host_service_v1_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RebuildContainerRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_codespace_codespace_host_service_v1_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RebuildContainerResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_codespace_codespace_host_service_v1_proto_msgTypes[0].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_codespace_codespace_host_service_v1_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_codespace_codespace_host_service_v1_proto_goTypes,
DependencyIndexes: file_codespace_codespace_host_service_v1_proto_depIdxs,
MessageInfos: file_codespace_codespace_host_service_v1_proto_msgTypes,
}.Build()
File_codespace_codespace_host_service_v1_proto = out.File
file_codespace_codespace_host_service_v1_proto_rawDesc = nil
file_codespace_codespace_host_service_v1_proto_goTypes = nil
file_codespace_codespace_host_service_v1_proto_depIdxs = nil
}

View file

@ -0,0 +1,17 @@
syntax = "proto3";
option go_package = "./codespace";
package Codespaces.Grpc.CodespaceHostService.v1;
service CodespaceHost {
rpc RebuildContainerAsync (RebuildContainerRequest) returns (RebuildContainerResponse);
}
message RebuildContainerRequest {
optional bool Incremental = 1;
}
message RebuildContainerResponse {
bool RebuildContainer = 1;
}

View file

@ -0,0 +1,105 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.12
// source: codespace/codespace_host_service.v1.proto
package codespace
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// CodespaceHostClient is the client API for CodespaceHost service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type CodespaceHostClient interface {
RebuildContainerAsync(ctx context.Context, in *RebuildContainerRequest, opts ...grpc.CallOption) (*RebuildContainerResponse, error)
}
type codespaceHostClient struct {
cc grpc.ClientConnInterface
}
func NewCodespaceHostClient(cc grpc.ClientConnInterface) CodespaceHostClient {
return &codespaceHostClient{cc}
}
func (c *codespaceHostClient) RebuildContainerAsync(ctx context.Context, in *RebuildContainerRequest, opts ...grpc.CallOption) (*RebuildContainerResponse, error) {
out := new(RebuildContainerResponse)
err := c.cc.Invoke(ctx, "/Codespaces.Grpc.CodespaceHostService.v1.CodespaceHost/RebuildContainerAsync", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CodespaceHostServer is the server API for CodespaceHost service.
// All implementations must embed UnimplementedCodespaceHostServer
// for forward compatibility
type CodespaceHostServer interface {
RebuildContainerAsync(context.Context, *RebuildContainerRequest) (*RebuildContainerResponse, error)
mustEmbedUnimplementedCodespaceHostServer()
}
// UnimplementedCodespaceHostServer must be embedded to have forward compatible implementations.
type UnimplementedCodespaceHostServer struct {
}
func (UnimplementedCodespaceHostServer) RebuildContainerAsync(context.Context, *RebuildContainerRequest) (*RebuildContainerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RebuildContainerAsync not implemented")
}
func (UnimplementedCodespaceHostServer) mustEmbedUnimplementedCodespaceHostServer() {}
// UnsafeCodespaceHostServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CodespaceHostServer will
// result in compilation errors.
type UnsafeCodespaceHostServer interface {
mustEmbedUnimplementedCodespaceHostServer()
}
func RegisterCodespaceHostServer(s grpc.ServiceRegistrar, srv CodespaceHostServer) {
s.RegisterService(&CodespaceHost_ServiceDesc, srv)
}
func _CodespaceHost_RebuildContainerAsync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RebuildContainerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CodespaceHostServer).RebuildContainerAsync(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Codespaces.Grpc.CodespaceHostService.v1.CodespaceHost/RebuildContainerAsync",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CodespaceHostServer).RebuildContainerAsync(ctx, req.(*RebuildContainerRequest))
}
return interceptor(ctx, in, info, handler)
}
// CodespaceHost_ServiceDesc is the grpc.ServiceDesc for CodespaceHost service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var CodespaceHost_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Codespaces.Grpc.CodespaceHostService.v1.CodespaceHost",
HandlerType: (*CodespaceHostServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "RebuildContainerAsync",
Handler: _CodespaceHost_RebuildContainerAsync_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "codespace/codespace_host_service.v1.proto",
}

View file

@ -21,6 +21,7 @@ function generate {
echo "Generated protocol buffers for $contract"
}
generate jupyter/JupyterServerHostService.v1.proto
generate jupyter/jupyter_server_host_service.v1.proto
generate codespace/codespace_host_service.v1.proto
echo 'Done!'

View file

@ -10,6 +10,7 @@ import (
"strconv"
"time"
"github.com/cli/cli/v2/internal/codespaces/rpc/codespace"
"github.com/cli/cli/v2/internal/codespaces/rpc/jupyter"
"github.com/cli/cli/v2/pkg/liveshare"
"google.golang.org/grpc"
@ -36,11 +37,12 @@ type Invoker interface {
}
type invoker struct {
conn *grpc.ClientConn
session liveshare.LiveshareSession
listener net.Listener
jupyterClient jupyter.JupyterServerHostClient
cancelPF context.CancelFunc
conn *grpc.ClientConn
session liveshare.LiveshareSession
listener net.Listener
jupyterClient jupyter.JupyterServerHostClient
codespaceClient codespace.CodespaceHostClient
cancelPF context.CancelFunc
}
// Connects to the internal RPC server and returns a new invoker for it
@ -115,6 +117,7 @@ func connect(ctx context.Context, session liveshare.LiveshareSession) (Invoker,
invoker.conn = conn
invoker.jupyterClient = jupyter.NewJupyterServerHostClient(conn)
invoker.codespaceClient = codespace.NewCodespaceHostClient(conn)
return invoker, nil
}
@ -162,7 +165,22 @@ func (i *invoker) StartJupyterServer(ctx context.Context) (port int, serverUrl s
// Rebuilds the container using cached layers by default or from scratch if full is true
func (i *invoker) RebuildContainer(ctx context.Context, full bool) error {
return i.session.RebuildContainer(ctx, full)
ctx = i.appendMetadata(ctx)
ctx, cancel := context.WithTimeout(ctx, requestTimeout)
defer cancel()
// If full is true, we want to pass false to the RPC call to indicate that we want to do a full rebuild
incremental := !full
response, err := i.codespaceClient.RebuildContainerAsync(ctx, &codespace.RebuildContainerRequest{Incremental: &incremental})
if err != nil {
return fmt.Errorf("failed to invoke rebuild RPC: %w", err)
}
if !response.RebuildContainer {
return fmt.Errorf("couldn't rebuild codespace")
}
return nil
}
// Starts a remote SSH server to allow the user to connect to the codespace via SSH

View file

@ -81,3 +81,35 @@ func TestStartJupyterServerFailure(t *testing.T) {
t.Fatalf("expected %s, got %s", "", url)
}
}
// Test that the RPC invoker doesn't throw an error when requesting an incremental rebuild
func TestRebuildContainerIncremental(t *testing.T) {
startServer(t)
invoker := createTestInvoker(t)
err := invoker.RebuildContainer(context.Background(), false)
if err != nil {
t.Fatalf("expected %v, got %v", nil, err)
}
}
// Test that the RPC invoker doesn't throw an error when requesting a full rebuild
func TestRebuildContainerFull(t *testing.T) {
startServer(t)
invoker := createTestInvoker(t)
err := invoker.RebuildContainer(context.Background(), true)
if err != nil {
t.Fatalf("expected %v, got %v", nil, err)
}
}
// Test that the RPC invoker throws an error when the rebuild fails
func TestRebuildContainerFailure(t *testing.T) {
startServer(t)
invoker := createTestInvoker(t)
rpctest.RebuildContainer = false
errorMessage := "couldn't rebuild codespace"
err := invoker.RebuildContainer(context.Background(), true)
if err.Error() != errorMessage {
t.Fatalf("expected %v, got %v", errorMessage, err)
}
}

View file

@ -1,241 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v3.12.4
// source: jupyter/JupyterServerHostService.v1.proto
package jupyter
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type GetRunningServerRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetRunningServerRequest) Reset() {
*x = GetRunningServerRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_jupyter_JupyterServerHostService_v1_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetRunningServerRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetRunningServerRequest) ProtoMessage() {}
func (x *GetRunningServerRequest) ProtoReflect() protoreflect.Message {
mi := &file_jupyter_JupyterServerHostService_v1_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetRunningServerRequest.ProtoReflect.Descriptor instead.
func (*GetRunningServerRequest) Descriptor() ([]byte, []int) {
return file_jupyter_JupyterServerHostService_v1_proto_rawDescGZIP(), []int{0}
}
type GetRunningServerResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Result bool `protobuf:"varint,1,opt,name=Result,proto3" json:"Result,omitempty"`
Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
Port string `protobuf:"bytes,3,opt,name=Port,proto3" json:"Port,omitempty"`
ServerUrl string `protobuf:"bytes,4,opt,name=ServerUrl,proto3" json:"ServerUrl,omitempty"`
}
func (x *GetRunningServerResponse) Reset() {
*x = GetRunningServerResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_jupyter_JupyterServerHostService_v1_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetRunningServerResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetRunningServerResponse) ProtoMessage() {}
func (x *GetRunningServerResponse) ProtoReflect() protoreflect.Message {
mi := &file_jupyter_JupyterServerHostService_v1_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetRunningServerResponse.ProtoReflect.Descriptor instead.
func (*GetRunningServerResponse) Descriptor() ([]byte, []int) {
return file_jupyter_JupyterServerHostService_v1_proto_rawDescGZIP(), []int{1}
}
func (x *GetRunningServerResponse) GetResult() bool {
if x != nil {
return x.Result
}
return false
}
func (x *GetRunningServerResponse) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *GetRunningServerResponse) GetPort() string {
if x != nil {
return x.Port
}
return ""
}
func (x *GetRunningServerResponse) GetServerUrl() string {
if x != nil {
return x.ServerUrl
}
return ""
}
var File_jupyter_JupyterServerHostService_v1_proto protoreflect.FileDescriptor
var file_jupyter_JupyterServerHostService_v1_proto_rawDesc = []byte{
0x0a, 0x29, 0x6a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x2f, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65,
0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2b, 0x43, 0x6f, 0x64,
0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x4a, 0x75, 0x70,
0x79, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x52,
0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x22, 0x7e, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e,
0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x16, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x55,
0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x55, 0x72, 0x6c, 0x32, 0xb5, 0x01, 0x0a, 0x11, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x9f, 0x01, 0x0a, 0x10, 0x47, 0x65,
0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x44,
0x2e, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63,
0x2e, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f,
0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x45, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65,
0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x2e,
0x2f, 0x6a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_jupyter_JupyterServerHostService_v1_proto_rawDescOnce sync.Once
file_jupyter_JupyterServerHostService_v1_proto_rawDescData = file_jupyter_JupyterServerHostService_v1_proto_rawDesc
)
func file_jupyter_JupyterServerHostService_v1_proto_rawDescGZIP() []byte {
file_jupyter_JupyterServerHostService_v1_proto_rawDescOnce.Do(func() {
file_jupyter_JupyterServerHostService_v1_proto_rawDescData = protoimpl.X.CompressGZIP(file_jupyter_JupyterServerHostService_v1_proto_rawDescData)
})
return file_jupyter_JupyterServerHostService_v1_proto_rawDescData
}
var file_jupyter_JupyterServerHostService_v1_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_jupyter_JupyterServerHostService_v1_proto_goTypes = []interface{}{
(*GetRunningServerRequest)(nil), // 0: Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerRequest
(*GetRunningServerResponse)(nil), // 1: Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerResponse
}
var file_jupyter_JupyterServerHostService_v1_proto_depIdxs = []int32{
0, // 0: Codespaces.Grpc.JupyterServerHostService.v1.JupyterServerHost.GetRunningServer:input_type -> Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerRequest
1, // 1: Codespaces.Grpc.JupyterServerHostService.v1.JupyterServerHost.GetRunningServer:output_type -> Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_jupyter_JupyterServerHostService_v1_proto_init() }
func file_jupyter_JupyterServerHostService_v1_proto_init() {
if File_jupyter_JupyterServerHostService_v1_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_jupyter_JupyterServerHostService_v1_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetRunningServerRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_jupyter_JupyterServerHostService_v1_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetRunningServerResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_jupyter_JupyterServerHostService_v1_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_jupyter_JupyterServerHostService_v1_proto_goTypes,
DependencyIndexes: file_jupyter_JupyterServerHostService_v1_proto_depIdxs,
MessageInfos: file_jupyter_JupyterServerHostService_v1_proto_msgTypes,
}.Build()
File_jupyter_JupyterServerHostService_v1_proto = out.File
file_jupyter_JupyterServerHostService_v1_proto_rawDesc = nil
file_jupyter_JupyterServerHostService_v1_proto_goTypes = nil
file_jupyter_JupyterServerHostService_v1_proto_depIdxs = nil
}

View file

@ -0,0 +1,242 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.21.12
// source: jupyter/jupyter_server_host_service.v1.proto
package jupyter
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type GetRunningServerRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetRunningServerRequest) Reset() {
*x = GetRunningServerRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetRunningServerRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetRunningServerRequest) ProtoMessage() {}
func (x *GetRunningServerRequest) ProtoReflect() protoreflect.Message {
mi := &file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetRunningServerRequest.ProtoReflect.Descriptor instead.
func (*GetRunningServerRequest) Descriptor() ([]byte, []int) {
return file_jupyter_jupyter_server_host_service_v1_proto_rawDescGZIP(), []int{0}
}
type GetRunningServerResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Result bool `protobuf:"varint,1,opt,name=Result,proto3" json:"Result,omitempty"`
Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
Port string `protobuf:"bytes,3,opt,name=Port,proto3" json:"Port,omitempty"`
ServerUrl string `protobuf:"bytes,4,opt,name=ServerUrl,proto3" json:"ServerUrl,omitempty"`
}
func (x *GetRunningServerResponse) Reset() {
*x = GetRunningServerResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetRunningServerResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetRunningServerResponse) ProtoMessage() {}
func (x *GetRunningServerResponse) ProtoReflect() protoreflect.Message {
mi := &file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetRunningServerResponse.ProtoReflect.Descriptor instead.
func (*GetRunningServerResponse) Descriptor() ([]byte, []int) {
return file_jupyter_jupyter_server_host_service_v1_proto_rawDescGZIP(), []int{1}
}
func (x *GetRunningServerResponse) GetResult() bool {
if x != nil {
return x.Result
}
return false
}
func (x *GetRunningServerResponse) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *GetRunningServerResponse) GetPort() string {
if x != nil {
return x.Port
}
return ""
}
func (x *GetRunningServerResponse) GetServerUrl() string {
if x != nil {
return x.ServerUrl
}
return ""
}
var File_jupyter_jupyter_server_host_service_v1_proto protoreflect.FileDescriptor
var file_jupyter_jupyter_server_host_service_v1_proto_rawDesc = []byte{
0x0a, 0x2c, 0x6a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x2f, 0x6a, 0x75, 0x70, 0x79, 0x74, 0x65,
0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2b,
0x43, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e,
0x4a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73,
0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x19, 0x0a, 0x17, 0x47,
0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x7e, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6e,
0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x72, 0x76,
0x65, 0x72, 0x55, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x32, 0xb5, 0x01, 0x0a, 0x11, 0x4a, 0x75, 0x70, 0x79, 0x74,
0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x9f, 0x01, 0x0a,
0x10, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x12, 0x44, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x47,
0x72, 0x70, 0x63, 0x2e, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x45, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x70,
0x61, 0x63, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x4a, 0x75, 0x70, 0x79, 0x74, 0x65,
0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b,
0x5a, 0x09, 0x2e, 0x2f, 0x6a, 0x75, 0x70, 0x79, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_jupyter_jupyter_server_host_service_v1_proto_rawDescOnce sync.Once
file_jupyter_jupyter_server_host_service_v1_proto_rawDescData = file_jupyter_jupyter_server_host_service_v1_proto_rawDesc
)
func file_jupyter_jupyter_server_host_service_v1_proto_rawDescGZIP() []byte {
file_jupyter_jupyter_server_host_service_v1_proto_rawDescOnce.Do(func() {
file_jupyter_jupyter_server_host_service_v1_proto_rawDescData = protoimpl.X.CompressGZIP(file_jupyter_jupyter_server_host_service_v1_proto_rawDescData)
})
return file_jupyter_jupyter_server_host_service_v1_proto_rawDescData
}
var file_jupyter_jupyter_server_host_service_v1_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_jupyter_jupyter_server_host_service_v1_proto_goTypes = []interface{}{
(*GetRunningServerRequest)(nil), // 0: Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerRequest
(*GetRunningServerResponse)(nil), // 1: Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerResponse
}
var file_jupyter_jupyter_server_host_service_v1_proto_depIdxs = []int32{
0, // 0: Codespaces.Grpc.JupyterServerHostService.v1.JupyterServerHost.GetRunningServer:input_type -> Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerRequest
1, // 1: Codespaces.Grpc.JupyterServerHostService.v1.JupyterServerHost.GetRunningServer:output_type -> Codespaces.Grpc.JupyterServerHostService.v1.GetRunningServerResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_jupyter_jupyter_server_host_service_v1_proto_init() }
func file_jupyter_jupyter_server_host_service_v1_proto_init() {
if File_jupyter_jupyter_server_host_service_v1_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetRunningServerRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_jupyter_jupyter_server_host_service_v1_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetRunningServerResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_jupyter_jupyter_server_host_service_v1_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_jupyter_jupyter_server_host_service_v1_proto_goTypes,
DependencyIndexes: file_jupyter_jupyter_server_host_service_v1_proto_depIdxs,
MessageInfos: file_jupyter_jupyter_server_host_service_v1_proto_msgTypes,
}.Build()
File_jupyter_jupyter_server_host_service_v1_proto = out.File
file_jupyter_jupyter_server_host_service_v1_proto_rawDesc = nil
file_jupyter_jupyter_server_host_service_v1_proto_goTypes = nil
file_jupyter_jupyter_server_host_service_v1_proto_depIdxs = nil
}

View file

@ -1,8 +1,8 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.12.4
// source: jupyter/JupyterServerHostService.v1.proto
// - protoc v3.21.12
// source: jupyter/jupyter_server_host_service.v1.proto
package jupyter
@ -101,5 +101,5 @@ var JupyterServerHost_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "jupyter/JupyterServerHostService.v1.proto",
Metadata: "jupyter/jupyter_server_host_service.v1.proto",
}

View file

@ -6,6 +6,7 @@ import (
"net"
"strconv"
"github.com/cli/cli/v2/internal/codespaces/rpc/codespace"
"github.com/cli/cli/v2/internal/codespaces/rpc/jupyter"
"google.golang.org/grpc"
)
@ -14,6 +15,7 @@ const (
ServerPort = 50051
)
// Mock responses for the `GetRunningServer` RPC method
var (
JupyterPort = 1234
JupyterServerUrl = "http://localhost:1234?token=1234"
@ -21,8 +23,14 @@ var (
JupyterResult = true
)
// Mock responses for the `RebuildContainerAsync` RPC method
var (
RebuildContainer = true
)
type server struct {
jupyter.UnimplementedJupyterServerHostServer
codespace.CodespaceHostServer
}
func (s *server) GetRunningServer(ctx context.Context, in *jupyter.GetRunningServerRequest) (*jupyter.GetRunningServerResponse, error) {
@ -34,6 +42,12 @@ func (s *server) GetRunningServer(ctx context.Context, in *jupyter.GetRunningSer
}, nil
}
func (s *server) RebuildContainerAsync(ctx context.Context, in *codespace.RebuildContainerRequest) (*codespace.RebuildContainerResponse, error) {
return &codespace.RebuildContainerResponse{
RebuildContainer: RebuildContainer,
}, nil
}
// Starts the mock gRPC server listening on port 50051
func StartServer(ctx context.Context) error {
listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", ServerPort))
@ -44,6 +58,7 @@ func StartServer(ctx context.Context) error {
s := grpc.NewServer()
jupyter.RegisterJupyterServerHostServer(s, &server{})
codespace.RegisterCodespaceHostServer(s, &server{})
ch := make(chan error, 1)
go func() {

View file

@ -28,7 +28,6 @@ type LiveshareSession interface {
StartSharing(context.Context, string, int) (ChannelID, error)
StartSSHServer(context.Context) (int, string, error)
StartSSHServerWithOptions(context.Context, StartSSHServerOptions) (int, string, error)
RebuildContainer(context.Context, bool) error
}
// A Session represents the session between a connected Live Share client and server.
@ -109,25 +108,6 @@ func (s *Session) StartSSHServerWithOptions(ctx context.Context, options StartSS
return port, response.User, nil
}
func (s *Session) RebuildContainer(ctx context.Context, full bool) error {
rpcMethod := "IEnvironmentConfigurationService.incrementalRebuildContainer"
if full {
rpcMethod = "IEnvironmentConfigurationService.rebuildContainer"
}
var rebuildSuccess bool
err := s.rpc.do(ctx, rpcMethod, nil, &rebuildSuccess)
if err != nil {
return fmt.Errorf("invoking rebuild RPC: %w", err)
}
if !rebuildSuccess {
return fmt.Errorf("couldn't rebuild codespace")
}
return nil
}
// heartbeat runs until context cancellation, periodically checking whether there is a
// reason to keep the connection alive, and if so, notifying the Live Share host to do so.
// Heartbeat ensures it does not send more than one request every "interval" to ratelimit

View file

@ -399,49 +399,6 @@ func TestSessionHeartbeat(t *testing.T) {
}
}
func TestRebuild(t *testing.T) {
tests := []struct {
fullRebuild bool
rpcService string
}{
{
fullRebuild: false,
rpcService: "IEnvironmentConfigurationService.incrementalRebuildContainer",
},
{
fullRebuild: true,
rpcService: "IEnvironmentConfigurationService.rebuildContainer",
},
}
for _, tt := range tests {
t.Logf("RPC service: %s", tt.rpcService)
t.Logf("full rebuild: %t", tt.fullRebuild)
requestCount := 0
rebuildContainer := func(conn *jsonrpc2.Conn, req *jsonrpc2.Request) (interface{}, error) {
requestCount++
return true, nil
}
testServer, session, err := makeMockSession(
livesharetest.WithService(tt.rpcService, rebuildContainer),
)
if err != nil {
t.Errorf("creating mock session: %v", err)
}
defer testServer.Close()
err = session.RebuildContainer(context.Background(), tt.fullRebuild)
if err != nil {
t.Errorf("rebuilding codespace via mock session: %v", err)
}
if requestCount == 0 {
t.Errorf("no requests were made")
}
}
}
type mockLogger struct {
sync.Mutex
buf *bytes.Buffer