diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42e409d..756f313 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,14 +18,14 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v6 - - uses: actions/setup-go@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6 with: go-version-file: go.mod cache: true - name: Install system dependencies run: sudo apt-get update && sudo apt-get install --yes libx11-dev - - uses: golangci/golangci-lint-action@v9 + - uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9 with: version: v2.12.0 only-new-issues: true @@ -35,8 +35,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v6 - - uses: actions/setup-go@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6 with: go-version-file: go.mod cache: true @@ -50,8 +50,8 @@ jobs: runs-on: macos-26 timeout-minutes: 30 steps: - - uses: actions/checkout@v6 - - uses: actions/setup-go@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6 with: go-version-file: go.mod cache: true diff --git a/buf.gen.yaml b/buf.gen.yaml index e78fd37..412ed4a 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,8 +1,8 @@ version: v2 plugins: - remote: buf.build/protocolbuffers/go:v1.36.6 - out: internal/ + out: pkg/ opt: paths=source_relative - remote: buf.build/grpc/go:v1.5.1 - out: internal/ + out: pkg/ opt: paths=source_relative diff --git a/internal/rpc/exec.go b/internal/rpc/exec.go index 3f277af..1a59ff5 100644 --- a/internal/rpc/exec.go +++ b/internal/rpc/exec.go @@ -13,6 +13,7 @@ import ( "syscall" "github.com/cirruslabs/tart-guest-agent/internal/execuser" + "github.com/cirruslabs/tart-guest-agent/pkg/v1" "github.com/creack/pty" "github.com/google/uuid" "github.com/samber/lo" @@ -35,13 +36,14 @@ const ( signalExitCodeOffset = 128 ) -func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) error { +//nolint:gocognit,gocyclo,maintidx // Exec coordinates process startup, bidirectional I/O, and cleanup. +func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse]) error { // Read the first exec request, it should describe a command to execute firstExecRequest, err := stream.Recv() if err != nil { return err } - firstExecRequestCommand, ok := firstExecRequest.Type.(*ExecRequest_Command_) + firstExecRequestCommand, ok := firstExecRequest.GetType().(*v1.ExecRequest_Command_) if !ok { return fmt.Errorf("first exec request should describe a command to execute") } @@ -96,9 +98,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) return err } - if err := stream.Send(&ExecResponse{ - Type: &ExecResponse_Exit_{ - Exit: &ExecResponse_Exit{ + if err := stream.Send(&v1.ExecResponse{ + Type: &v1.ExecResponse_Exit_{ + Exit: &v1.ExecResponse_Exit{ Code: 0, }, }, @@ -209,7 +211,7 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) } switch typedAction := request.Type.(type) { - case *ExecRequest_StandardInput: + case *v1.ExecRequest_StandardInput: if !firstExecRequestCommand.Command.Interactive { // Ignore standard input from the client // as non-interactive command is running @@ -232,7 +234,7 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) return } - case *ExecRequest_TerminalResize: + case *v1.ExecRequest_TerminalResize: // Ignore terminal resize requests // when pseudo terminal is disabled if !firstExecRequestCommand.Command.Tty { @@ -254,7 +256,7 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) // Serialize responses from the stdout and stderr goroutines var sendMutex sync.Mutex - sendResponse := func(response *ExecResponse) error { + sendResponse := func(response *v1.ExecResponse) error { sendMutex.Lock() defer sendMutex.Unlock() @@ -282,9 +284,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) return err } - if err := sendResponse(&ExecResponse{ - Type: &ExecResponse_StandardOutput{ - StandardOutput: &IOChunk{ + if err := sendResponse(&v1.ExecResponse{ + Type: &v1.ExecResponse_StandardOutput{ + StandardOutput: &v1.IOChunk{ Data: slices.Clone(buf[:n]), }, }, @@ -312,9 +314,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) return err } - if err := sendResponse(&ExecResponse{ - Type: &ExecResponse_StandardError{ - StandardError: &IOChunk{ + if err := sendResponse(&v1.ExecResponse{ + Type: &v1.ExecResponse_StandardError{ + StandardError: &v1.IOChunk{ Data: slices.Clone(buf[:n]), }, }, @@ -358,9 +360,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) } } - return stream.Send(&ExecResponse{ - Type: &ExecResponse_Exit_{ - Exit: &ExecResponse_Exit{ + return stream.Send(&v1.ExecResponse{ + Type: &v1.ExecResponse_Exit_{ + Exit: &v1.ExecResponse_Exit{ Code: int32(exitCode), }, }, @@ -402,7 +404,7 @@ func closeStdin(stdin io.WriteCloser, tty bool, closed *bool) error { return nil } -func (rpc *RPC) Signal(_ context.Context, request *SignalRequest) (*emptypb.Empty, error) { +func (rpc *RPC) Signal(_ context.Context, request *v1.SignalRequest) (*emptypb.Empty, error) { process, ok := rpc.execs.Load(request.GetExecId()) if !ok { return nil, fmt.Errorf("exec %q is not running", request.GetExecId()) @@ -411,9 +413,9 @@ func (rpc *RPC) Signal(_ context.Context, request *SignalRequest) (*emptypb.Empt var signal syscall.Signal switch request.GetSignal() { - case SignalRequest_SIGNAL_SIGTERM: + case v1.SignalRequest_SIGNAL_SIGTERM: signal = syscall.SIGTERM - case SignalRequest_SIGNAL_SIGKILL: + case v1.SignalRequest_SIGNAL_SIGKILL: signal = syscall.SIGKILL default: return nil, fmt.Errorf("unsupported exec signal %q", request.GetSignal().String()) @@ -431,27 +433,27 @@ func (rpc *RPC) Signal(_ context.Context, request *SignalRequest) (*emptypb.Empt return &emptypb.Empty{}, nil } -func sendStartSuccess(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse], execID string) error { - return stream.Send(&ExecResponse{ - Type: &ExecResponse_Started_{ - Started: &ExecResponse_Started{ +func sendStartSuccess(stream grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse], execID string) error { + return stream.Send(&v1.ExecResponse{ + Type: &v1.ExecResponse_Started_{ + Started: &v1.ExecResponse_Started{ ExecId: execID, }, }, }) } -func sendStartFailure(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) error { - return stream.Send(&ExecResponse{ - Type: &ExecResponse_Exit_{ - Exit: &ExecResponse_Exit{ +func sendStartFailure(stream grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse]) error { + return stream.Send(&v1.ExecResponse{ + Type: &v1.ExecResponse_Exit_{ + Exit: &v1.ExecResponse_Exit{ Code: execRuntimeFailureExitCode, }, }, }) } -func applyExecOverrides(cmd *exec.Cmd, command *ExecRequest_Command) error { +func applyExecOverrides(cmd *exec.Cmd, command *v1.ExecRequest_Command) error { if command.Workdir != "" { cmd.Dir = command.Workdir } diff --git a/internal/rpc/exec_grpc_test.go b/internal/rpc/exec_grpc_test.go index 22c637a..301dcc5 100644 --- a/internal/rpc/exec_grpc_test.go +++ b/internal/rpc/exec_grpc_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/cirruslabs/tart-guest-agent/pkg/v1" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -26,7 +27,7 @@ import ( func TestExecGRPCBackgroundProcessLifetime(t *testing.T) { for _, mode := range []string{"normal exit", "cancel after exit", "cancel while running"} { t.Run(mode, func(t *testing.T) { - client := NewAgentClient(newExecGRPCTestConn(t)) + client := v1.NewAgentClient(newExecGRPCTestConn(t)) ctx, cancel := context.WithTimeout(t.Context(), execTestTimeout) defer cancel() @@ -34,7 +35,7 @@ func TestExecGRPCBackgroundProcessLifetime(t *testing.T) { require.NoError(t, err) releasePath := filepath.Join(t.TempDir(), "release") - require.NoError(t, stream.Send(&ExecRequest{Type: &ExecRequest_Command_{Command: &ExecRequest_Command{ + require.NoError(t, stream.Send(&v1.ExecRequest{Type: &v1.ExecRequest_Command_{Command: &v1.ExecRequest_Command{ Name: execTestShell, Args: []string{"-c", `nohup sleep 30 >/dev/null 2>&1 "$PID_FILE"; exec sleep 30`}, Env: map[string]string{"PID_FILE": pidPath}, }, func(stream *execTestStream) { - stream.sendHook = func(response *ExecResponse) error { + stream.sendHook = func(response *v1.ExecResponse) error { if response.GetStarted() == nil { return nil } @@ -285,7 +286,7 @@ func TestExecReapsProcessWhenStartedCannotBeSent(t *testing.T) { func startExecTest( t *testing.T, - command *ExecRequest_Command, + command *v1.ExecRequest_Command, configure ...func(*execTestStream), ) (*RPC, *execTestStream, <-chan error) { t.Helper() @@ -302,13 +303,13 @@ func startExecTest( go func() { result <- rpc.Exec(stream) }() - stream.requests <- &ExecRequest{ - Type: &ExecRequest_Command_{Command: command}, + stream.requests <- &v1.ExecRequest{ + Type: &v1.ExecRequest_Command_{Command: command}, } return rpc, stream, result } -func receiveExecResponse(t *testing.T, stream *execTestStream) *ExecResponse { +func receiveExecResponse(t *testing.T, stream *execTestStream) *v1.ExecResponse { t.Helper() select { diff --git a/internal/rpc/resolveip.go b/internal/rpc/resolveip.go index ca43253..3cf8c85 100644 --- a/internal/rpc/resolveip.go +++ b/internal/rpc/resolveip.go @@ -4,9 +4,11 @@ import ( "context" "fmt" "net" + + "github.com/cirruslabs/tart-guest-agent/pkg/v1" ) -func (rpc *RPC) ResolveIP(ctx context.Context, _ *ResolveIPRequest) (*ResolveIPResponse, error) { +func (rpc *RPC) ResolveIP(ctx context.Context, _ *v1.ResolveIPRequest) (*v1.ResolveIPResponse, error) { ifaceAddrs, err := net.InterfaceAddrs() if err != nil { return nil, fmt.Errorf("failed to retrieve VM's network interface addresses: %w", err) @@ -33,7 +35,7 @@ func (rpc *RPC) ResolveIP(ctx context.Context, _ *ResolveIPRequest) (*ResolveIPR continue } - return &ResolveIPResponse{ + return &v1.ResolveIPResponse{ Ip: ipNet.IP.String(), }, nil } diff --git a/internal/rpc/rpc.go b/internal/rpc/rpc.go index 4f51745..198804d 100644 --- a/internal/rpc/rpc.go +++ b/internal/rpc/rpc.go @@ -5,16 +5,17 @@ import ( "net" "os" + "github.com/cirruslabs/tart-guest-agent/pkg/v1" "github.com/puzpuzpuz/xsync/v4" "google.golang.org/grpc" ) type RPC struct { + v1.UnimplementedAgentServer + grpcServer *grpc.Server listener net.Listener execs *xsync.Map[string, *os.Process] - - UnimplementedAgentServer } func New(listener net.Listener) (*RPC, error) { @@ -24,7 +25,7 @@ func New(listener net.Listener) (*RPC, error) { execs: xsync.NewMap[string, *os.Process](), } - RegisterAgentServer(rpc.grpcServer, rpc) + v1.RegisterAgentServer(rpc.grpcServer, rpc) return rpc, nil } diff --git a/internal/rpc/agent.pb.go b/pkg/v1/agent.pb.go similarity index 87% rename from internal/rpc/agent.pb.go rename to pkg/v1/agent.pb.go index f4d3cfb..384b0cf 100644 --- a/internal/rpc/agent.pb.go +++ b/pkg/v1/agent.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.36.6 // protoc v7.35.1 -// source: rpc/agent.proto +// source: v1/agent.proto -package rpc +package v1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -55,11 +55,11 @@ func (x SignalRequest_Signal) String() string { } func (SignalRequest_Signal) Descriptor() protoreflect.EnumDescriptor { - return file_rpc_agent_proto_enumTypes[0].Descriptor() + return file_v1_agent_proto_enumTypes[0].Descriptor() } func (SignalRequest_Signal) Type() protoreflect.EnumType { - return &file_rpc_agent_proto_enumTypes[0] + return &file_v1_agent_proto_enumTypes[0] } func (x SignalRequest_Signal) Number() protoreflect.EnumNumber { @@ -68,7 +68,7 @@ func (x SignalRequest_Signal) Number() protoreflect.EnumNumber { // Deprecated: Use SignalRequest_Signal.Descriptor instead. func (SignalRequest_Signal) EnumDescriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{6, 0} + return file_v1_agent_proto_rawDescGZIP(), []int{6, 0} } type ExecRequest struct { @@ -85,7 +85,7 @@ type ExecRequest struct { func (x *ExecRequest) Reset() { *x = ExecRequest{} - mi := &file_rpc_agent_proto_msgTypes[0] + mi := &file_v1_agent_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -97,7 +97,7 @@ func (x *ExecRequest) String() string { func (*ExecRequest) ProtoMessage() {} func (x *ExecRequest) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[0] + mi := &file_v1_agent_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -110,7 +110,7 @@ func (x *ExecRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecRequest.ProtoReflect.Descriptor instead. func (*ExecRequest) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{0} + return file_v1_agent_proto_rawDescGZIP(), []int{0} } func (x *ExecRequest) GetType() isExecRequest_Type { @@ -184,7 +184,7 @@ type ExecResponse struct { func (x *ExecResponse) Reset() { *x = ExecResponse{} - mi := &file_rpc_agent_proto_msgTypes[1] + mi := &file_v1_agent_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +196,7 @@ func (x *ExecResponse) String() string { func (*ExecResponse) ProtoMessage() {} func (x *ExecResponse) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[1] + mi := &file_v1_agent_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +209,7 @@ func (x *ExecResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecResponse.ProtoReflect.Descriptor instead. func (*ExecResponse) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{1} + return file_v1_agent_proto_rawDescGZIP(), []int{1} } func (x *ExecResponse) GetType() isExecResponse_Type { @@ -293,7 +293,7 @@ type TerminalSize struct { func (x *TerminalSize) Reset() { *x = TerminalSize{} - mi := &file_rpc_agent_proto_msgTypes[2] + mi := &file_v1_agent_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -305,7 +305,7 @@ func (x *TerminalSize) String() string { func (*TerminalSize) ProtoMessage() {} func (x *TerminalSize) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[2] + mi := &file_v1_agent_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -318,7 +318,7 @@ func (x *TerminalSize) ProtoReflect() protoreflect.Message { // Deprecated: Use TerminalSize.ProtoReflect.Descriptor instead. func (*TerminalSize) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{2} + return file_v1_agent_proto_rawDescGZIP(), []int{2} } func (x *TerminalSize) GetRows() uint32 { @@ -344,7 +344,7 @@ type IOChunk struct { func (x *IOChunk) Reset() { *x = IOChunk{} - mi := &file_rpc_agent_proto_msgTypes[3] + mi := &file_v1_agent_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -356,7 +356,7 @@ func (x *IOChunk) String() string { func (*IOChunk) ProtoMessage() {} func (x *IOChunk) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[3] + mi := &file_v1_agent_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -369,7 +369,7 @@ func (x *IOChunk) ProtoReflect() protoreflect.Message { // Deprecated: Use IOChunk.ProtoReflect.Descriptor instead. func (*IOChunk) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{3} + return file_v1_agent_proto_rawDescGZIP(), []int{3} } func (x *IOChunk) GetData() []byte { @@ -387,7 +387,7 @@ type ResolveIPRequest struct { func (x *ResolveIPRequest) Reset() { *x = ResolveIPRequest{} - mi := &file_rpc_agent_proto_msgTypes[4] + mi := &file_v1_agent_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -399,7 +399,7 @@ func (x *ResolveIPRequest) String() string { func (*ResolveIPRequest) ProtoMessage() {} func (x *ResolveIPRequest) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[4] + mi := &file_v1_agent_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -412,7 +412,7 @@ func (x *ResolveIPRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveIPRequest.ProtoReflect.Descriptor instead. func (*ResolveIPRequest) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{4} + return file_v1_agent_proto_rawDescGZIP(), []int{4} } type ResolveIPResponse struct { @@ -424,7 +424,7 @@ type ResolveIPResponse struct { func (x *ResolveIPResponse) Reset() { *x = ResolveIPResponse{} - mi := &file_rpc_agent_proto_msgTypes[5] + mi := &file_v1_agent_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -436,7 +436,7 @@ func (x *ResolveIPResponse) String() string { func (*ResolveIPResponse) ProtoMessage() {} func (x *ResolveIPResponse) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[5] + mi := &file_v1_agent_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -449,7 +449,7 @@ func (x *ResolveIPResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveIPResponse.ProtoReflect.Descriptor instead. func (*ResolveIPResponse) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{5} + return file_v1_agent_proto_rawDescGZIP(), []int{5} } func (x *ResolveIPResponse) GetIp() string { @@ -469,7 +469,7 @@ type SignalRequest struct { func (x *SignalRequest) Reset() { *x = SignalRequest{} - mi := &file_rpc_agent_proto_msgTypes[6] + mi := &file_v1_agent_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -481,7 +481,7 @@ func (x *SignalRequest) String() string { func (*SignalRequest) ProtoMessage() {} func (x *SignalRequest) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[6] + mi := &file_v1_agent_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -494,7 +494,7 @@ func (x *SignalRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignalRequest.ProtoReflect.Descriptor instead. func (*SignalRequest) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{6} + return file_v1_agent_proto_rawDescGZIP(), []int{6} } func (x *SignalRequest) GetExecId() string { @@ -528,7 +528,7 @@ type ExecRequest_Command struct { func (x *ExecRequest_Command) Reset() { *x = ExecRequest_Command{} - mi := &file_rpc_agent_proto_msgTypes[7] + mi := &file_v1_agent_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -540,7 +540,7 @@ func (x *ExecRequest_Command) String() string { func (*ExecRequest_Command) ProtoMessage() {} func (x *ExecRequest_Command) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[7] + mi := &file_v1_agent_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -553,7 +553,7 @@ func (x *ExecRequest_Command) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecRequest_Command.ProtoReflect.Descriptor instead. func (*ExecRequest_Command) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{0, 0} + return file_v1_agent_proto_rawDescGZIP(), []int{0, 0} } func (x *ExecRequest_Command) GetName() string { @@ -628,7 +628,7 @@ type ExecResponse_Exit struct { func (x *ExecResponse_Exit) Reset() { *x = ExecResponse_Exit{} - mi := &file_rpc_agent_proto_msgTypes[9] + mi := &file_v1_agent_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -640,7 +640,7 @@ func (x *ExecResponse_Exit) String() string { func (*ExecResponse_Exit) ProtoMessage() {} func (x *ExecResponse_Exit) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[9] + mi := &file_v1_agent_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -653,7 +653,7 @@ func (x *ExecResponse_Exit) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecResponse_Exit.ProtoReflect.Descriptor instead. func (*ExecResponse_Exit) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{1, 0} + return file_v1_agent_proto_rawDescGZIP(), []int{1, 0} } func (x *ExecResponse_Exit) GetCode() int32 { @@ -672,7 +672,7 @@ type ExecResponse_Started struct { func (x *ExecResponse_Started) Reset() { *x = ExecResponse_Started{} - mi := &file_rpc_agent_proto_msgTypes[10] + mi := &file_v1_agent_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -684,7 +684,7 @@ func (x *ExecResponse_Started) String() string { func (*ExecResponse_Started) ProtoMessage() {} func (x *ExecResponse_Started) ProtoReflect() protoreflect.Message { - mi := &file_rpc_agent_proto_msgTypes[10] + mi := &file_v1_agent_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -697,7 +697,7 @@ func (x *ExecResponse_Started) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecResponse_Started.ProtoReflect.Descriptor instead. func (*ExecResponse_Started) Descriptor() ([]byte, []int) { - return file_rpc_agent_proto_rawDescGZIP(), []int{1, 1} + return file_v1_agent_proto_rawDescGZIP(), []int{1, 1} } func (x *ExecResponse_Started) GetExecId() string { @@ -707,11 +707,11 @@ func (x *ExecResponse_Started) GetExecId() string { return "" } -var File_rpc_agent_proto protoreflect.FileDescriptor +var File_v1_agent_proto protoreflect.FileDescriptor -const file_rpc_agent_proto_rawDesc = "" + +const file_v1_agent_proto_rawDesc = "" + "\n" + - "\x0frpc/agent.proto\x1a\x1bgoogle/protobuf/empty.proto\"\xff\x03\n" + + "\x0ev1/agent.proto\x1a\x1bgoogle/protobuf/empty.proto\"\xff\x03\n" + "\vExecRequest\x120\n" + "\acommand\x18\x01 \x01(\v2\x14.ExecRequest.CommandH\x00R\acommand\x121\n" + "\x0estandard_input\x18\x02 \x01(\v2\b.IOChunkH\x00R\rstandardInput\x128\n" + @@ -758,23 +758,23 @@ const file_rpc_agent_proto_rawDesc = "" + "\x05Agent\x12'\n" + "\x04Exec\x12\f.ExecRequest\x1a\r.ExecResponse(\x010\x01\x120\n" + "\x06Signal\x12\x0e.SignalRequest\x1a\x16.google.protobuf.Empty\x122\n" + - "\tResolveIP\x12\x11.ResolveIPRequest\x1a\x12.ResolveIPResponseB5Z3github.com/cirruslabs/tart-guest-agent/internal/rpcb\x06proto3" + "\tResolveIP\x12\x11.ResolveIPRequest\x1a\x12.ResolveIPResponseB/Z-github.com/cirruslabs/tart-guest-agent/pkg/v1b\x06proto3" var ( - file_rpc_agent_proto_rawDescOnce sync.Once - file_rpc_agent_proto_rawDescData []byte + file_v1_agent_proto_rawDescOnce sync.Once + file_v1_agent_proto_rawDescData []byte ) -func file_rpc_agent_proto_rawDescGZIP() []byte { - file_rpc_agent_proto_rawDescOnce.Do(func() { - file_rpc_agent_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_rpc_agent_proto_rawDesc), len(file_rpc_agent_proto_rawDesc))) +func file_v1_agent_proto_rawDescGZIP() []byte { + file_v1_agent_proto_rawDescOnce.Do(func() { + file_v1_agent_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_v1_agent_proto_rawDesc), len(file_v1_agent_proto_rawDesc))) }) - return file_rpc_agent_proto_rawDescData + return file_v1_agent_proto_rawDescData } -var file_rpc_agent_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_rpc_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 11) -var file_rpc_agent_proto_goTypes = []any{ +var file_v1_agent_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_v1_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_v1_agent_proto_goTypes = []any{ (SignalRequest_Signal)(0), // 0: SignalRequest.Signal (*ExecRequest)(nil), // 1: ExecRequest (*ExecResponse)(nil), // 2: ExecResponse @@ -789,7 +789,7 @@ var file_rpc_agent_proto_goTypes = []any{ (*ExecResponse_Started)(nil), // 11: ExecResponse.Started (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } -var file_rpc_agent_proto_depIdxs = []int32{ +var file_v1_agent_proto_depIdxs = []int32{ 8, // 0: ExecRequest.command:type_name -> ExecRequest.Command 4, // 1: ExecRequest.standard_input:type_name -> IOChunk 3, // 2: ExecRequest.terminal_resize:type_name -> TerminalSize @@ -813,17 +813,17 @@ var file_rpc_agent_proto_depIdxs = []int32{ 0, // [0:10] is the sub-list for field type_name } -func init() { file_rpc_agent_proto_init() } -func file_rpc_agent_proto_init() { - if File_rpc_agent_proto != nil { +func init() { file_v1_agent_proto_init() } +func file_v1_agent_proto_init() { + if File_v1_agent_proto != nil { return } - file_rpc_agent_proto_msgTypes[0].OneofWrappers = []any{ + file_v1_agent_proto_msgTypes[0].OneofWrappers = []any{ (*ExecRequest_Command_)(nil), (*ExecRequest_StandardInput)(nil), (*ExecRequest_TerminalResize)(nil), } - file_rpc_agent_proto_msgTypes[1].OneofWrappers = []any{ + file_v1_agent_proto_msgTypes[1].OneofWrappers = []any{ (*ExecResponse_Exit_)(nil), (*ExecResponse_StandardOutput)(nil), (*ExecResponse_StandardError)(nil), @@ -833,18 +833,18 @@ func file_rpc_agent_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_rpc_agent_proto_rawDesc), len(file_rpc_agent_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_agent_proto_rawDesc), len(file_v1_agent_proto_rawDesc)), NumEnums: 1, NumMessages: 11, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_rpc_agent_proto_goTypes, - DependencyIndexes: file_rpc_agent_proto_depIdxs, - EnumInfos: file_rpc_agent_proto_enumTypes, - MessageInfos: file_rpc_agent_proto_msgTypes, + GoTypes: file_v1_agent_proto_goTypes, + DependencyIndexes: file_v1_agent_proto_depIdxs, + EnumInfos: file_v1_agent_proto_enumTypes, + MessageInfos: file_v1_agent_proto_msgTypes, }.Build() - File_rpc_agent_proto = out.File - file_rpc_agent_proto_goTypes = nil - file_rpc_agent_proto_depIdxs = nil + File_v1_agent_proto = out.File + file_v1_agent_proto_goTypes = nil + file_v1_agent_proto_depIdxs = nil } diff --git a/internal/rpc/agent_grpc.pb.go b/pkg/v1/agent_grpc.pb.go similarity index 99% rename from internal/rpc/agent_grpc.pb.go rename to pkg/v1/agent_grpc.pb.go index ef82d8a..fd527a2 100644 --- a/internal/rpc/agent_grpc.pb.go +++ b/pkg/v1/agent_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc v7.35.1 -// source: rpc/agent.proto +// source: v1/agent.proto -package rpc +package v1 import ( context "context" @@ -189,5 +189,5 @@ var Agent_ServiceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "rpc/agent.proto", + Metadata: "v1/agent.proto", } diff --git a/proto/rpc/agent.proto b/proto/v1/agent.proto similarity index 94% rename from proto/rpc/agent.proto rename to proto/v1/agent.proto index 09942b8..e25884c 100644 --- a/proto/rpc/agent.proto +++ b/proto/v1/agent.proto @@ -2,7 +2,7 @@ syntax = "proto3"; import "google/protobuf/empty.proto"; -option go_package = "github.com/cirruslabs/tart-guest-agent/internal/rpc"; +option go_package = "github.com/cirruslabs/tart-guest-agent/pkg/v1"; service Agent { rpc Exec(stream ExecRequest) returns (stream ExecResponse);