Expose Protocol Buffers/gRPC bindings (#66)

* Expose Protocol Buffers/gRPC bindings

* CI: pin used actions
This commit is contained in:
edi-oai
2026-09-02 08:56:14 -04:00
committed by GitHub
parent cb39b12dcc
commit 0540136b95
10 changed files with 160 additions and 153 deletions
+7 -7
View File
@@ -18,14 +18,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15 timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- uses: actions/setup-go@v6 - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with: with:
go-version-file: go.mod go-version-file: go.mod
cache: true cache: true
- name: Install system dependencies - name: Install system dependencies
run: sudo apt-get update && sudo apt-get install --yes libx11-dev 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: with:
version: v2.12.0 version: v2.12.0
only-new-issues: true only-new-issues: true
@@ -35,8 +35,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- uses: actions/setup-go@v6 - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with: with:
go-version-file: go.mod go-version-file: go.mod
cache: true cache: true
@@ -50,8 +50,8 @@ jobs:
runs-on: macos-26 runs-on: macos-26
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- uses: actions/setup-go@v6 - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with: with:
go-version-file: go.mod go-version-file: go.mod
cache: true cache: true
+2 -2
View File
@@ -1,8 +1,8 @@
version: v2 version: v2
plugins: plugins:
- remote: buf.build/protocolbuffers/go:v1.36.6 - remote: buf.build/protocolbuffers/go:v1.36.6
out: internal/ out: pkg/
opt: paths=source_relative opt: paths=source_relative
- remote: buf.build/grpc/go:v1.5.1 - remote: buf.build/grpc/go:v1.5.1
out: internal/ out: pkg/
opt: paths=source_relative opt: paths=source_relative
+31 -29
View File
@@ -13,6 +13,7 @@ import (
"syscall" "syscall"
"github.com/cirruslabs/tart-guest-agent/internal/execuser" "github.com/cirruslabs/tart-guest-agent/internal/execuser"
"github.com/cirruslabs/tart-guest-agent/pkg/v1"
"github.com/creack/pty" "github.com/creack/pty"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/samber/lo" "github.com/samber/lo"
@@ -35,13 +36,14 @@ const (
signalExitCodeOffset = 128 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 // Read the first exec request, it should describe a command to execute
firstExecRequest, err := stream.Recv() firstExecRequest, err := stream.Recv()
if err != nil { if err != nil {
return err return err
} }
firstExecRequestCommand, ok := firstExecRequest.Type.(*ExecRequest_Command_) firstExecRequestCommand, ok := firstExecRequest.GetType().(*v1.ExecRequest_Command_)
if !ok { if !ok {
return fmt.Errorf("first exec request should describe a command to execute") 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 return err
} }
if err := stream.Send(&ExecResponse{ if err := stream.Send(&v1.ExecResponse{
Type: &ExecResponse_Exit_{ Type: &v1.ExecResponse_Exit_{
Exit: &ExecResponse_Exit{ Exit: &v1.ExecResponse_Exit{
Code: 0, Code: 0,
}, },
}, },
@@ -209,7 +211,7 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse])
} }
switch typedAction := request.Type.(type) { switch typedAction := request.Type.(type) {
case *ExecRequest_StandardInput: case *v1.ExecRequest_StandardInput:
if !firstExecRequestCommand.Command.Interactive { if !firstExecRequestCommand.Command.Interactive {
// Ignore standard input from the client // Ignore standard input from the client
// as non-interactive command is running // as non-interactive command is running
@@ -232,7 +234,7 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse])
return return
} }
case *ExecRequest_TerminalResize: case *v1.ExecRequest_TerminalResize:
// Ignore terminal resize requests // Ignore terminal resize requests
// when pseudo terminal is disabled // when pseudo terminal is disabled
if !firstExecRequestCommand.Command.Tty { 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 // Serialize responses from the stdout and stderr goroutines
var sendMutex sync.Mutex var sendMutex sync.Mutex
sendResponse := func(response *ExecResponse) error { sendResponse := func(response *v1.ExecResponse) error {
sendMutex.Lock() sendMutex.Lock()
defer sendMutex.Unlock() defer sendMutex.Unlock()
@@ -282,9 +284,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse])
return err return err
} }
if err := sendResponse(&ExecResponse{ if err := sendResponse(&v1.ExecResponse{
Type: &ExecResponse_StandardOutput{ Type: &v1.ExecResponse_StandardOutput{
StandardOutput: &IOChunk{ StandardOutput: &v1.IOChunk{
Data: slices.Clone(buf[:n]), Data: slices.Clone(buf[:n]),
}, },
}, },
@@ -312,9 +314,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse])
return err return err
} }
if err := sendResponse(&ExecResponse{ if err := sendResponse(&v1.ExecResponse{
Type: &ExecResponse_StandardError{ Type: &v1.ExecResponse_StandardError{
StandardError: &IOChunk{ StandardError: &v1.IOChunk{
Data: slices.Clone(buf[:n]), Data: slices.Clone(buf[:n]),
}, },
}, },
@@ -358,9 +360,9 @@ func (rpc *RPC) Exec(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse])
} }
} }
return stream.Send(&ExecResponse{ return stream.Send(&v1.ExecResponse{
Type: &ExecResponse_Exit_{ Type: &v1.ExecResponse_Exit_{
Exit: &ExecResponse_Exit{ Exit: &v1.ExecResponse_Exit{
Code: int32(exitCode), Code: int32(exitCode),
}, },
}, },
@@ -402,7 +404,7 @@ func closeStdin(stdin io.WriteCloser, tty bool, closed *bool) error {
return nil 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()) process, ok := rpc.execs.Load(request.GetExecId())
if !ok { if !ok {
return nil, fmt.Errorf("exec %q is not running", request.GetExecId()) 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 var signal syscall.Signal
switch request.GetSignal() { switch request.GetSignal() {
case SignalRequest_SIGNAL_SIGTERM: case v1.SignalRequest_SIGNAL_SIGTERM:
signal = syscall.SIGTERM signal = syscall.SIGTERM
case SignalRequest_SIGNAL_SIGKILL: case v1.SignalRequest_SIGNAL_SIGKILL:
signal = syscall.SIGKILL signal = syscall.SIGKILL
default: default:
return nil, fmt.Errorf("unsupported exec signal %q", request.GetSignal().String()) 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 return &emptypb.Empty{}, nil
} }
func sendStartSuccess(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse], execID string) error { func sendStartSuccess(stream grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse], execID string) error {
return stream.Send(&ExecResponse{ return stream.Send(&v1.ExecResponse{
Type: &ExecResponse_Started_{ Type: &v1.ExecResponse_Started_{
Started: &ExecResponse_Started{ Started: &v1.ExecResponse_Started{
ExecId: execID, ExecId: execID,
}, },
}, },
}) })
} }
func sendStartFailure(stream grpc.BidiStreamingServer[ExecRequest, ExecResponse]) error { func sendStartFailure(stream grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse]) error {
return stream.Send(&ExecResponse{ return stream.Send(&v1.ExecResponse{
Type: &ExecResponse_Exit_{ Type: &v1.ExecResponse_Exit_{
Exit: &ExecResponse_Exit{ Exit: &v1.ExecResponse_Exit{
Code: execRuntimeFailureExitCode, Code: execRuntimeFailureExitCode,
}, },
}, },
}) })
} }
func applyExecOverrides(cmd *exec.Cmd, command *ExecRequest_Command) error { func applyExecOverrides(cmd *exec.Cmd, command *v1.ExecRequest_Command) error {
if command.Workdir != "" { if command.Workdir != "" {
cmd.Dir = command.Workdir cmd.Dir = command.Workdir
} }
+3 -2
View File
@@ -15,6 +15,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/cirruslabs/tart-guest-agent/pkg/v1"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
@@ -26,7 +27,7 @@ import (
func TestExecGRPCBackgroundProcessLifetime(t *testing.T) { func TestExecGRPCBackgroundProcessLifetime(t *testing.T) {
for _, mode := range []string{"normal exit", "cancel after exit", "cancel while running"} { for _, mode := range []string{"normal exit", "cancel after exit", "cancel while running"} {
t.Run(mode, func(t *testing.T) { t.Run(mode, func(t *testing.T) {
client := NewAgentClient(newExecGRPCTestConn(t)) client := v1.NewAgentClient(newExecGRPCTestConn(t))
ctx, cancel := context.WithTimeout(t.Context(), execTestTimeout) ctx, cancel := context.WithTimeout(t.Context(), execTestTimeout)
defer cancel() defer cancel()
@@ -34,7 +35,7 @@ func TestExecGRPCBackgroundProcessLifetime(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
releasePath := filepath.Join(t.TempDir(), "release") 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, Name: execTestShell,
Args: []string{"-c", `nohup sleep 30 >/dev/null 2>&1 </dev/null & Args: []string{"-c", `nohup sleep 30 >/dev/null 2>&1 </dev/null &
echo "$!" echo "$!"
+43 -42
View File
@@ -14,6 +14,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/cirruslabs/tart-guest-agent/pkg/v1"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@@ -27,22 +28,22 @@ type execTestStream struct {
grpc.ServerStream grpc.ServerStream
ctx context.Context ctx context.Context
requests chan *ExecRequest requests chan *v1.ExecRequest
responses chan *ExecResponse responses chan *v1.ExecResponse
sendHook func(*ExecResponse) error sendHook func(*v1.ExecResponse) error
} }
var _ grpc.BidiStreamingServer[ExecRequest, ExecResponse] = (*execTestStream)(nil) var _ grpc.BidiStreamingServer[v1.ExecRequest, v1.ExecResponse] = (*execTestStream)(nil)
func newExecTestStream(ctx context.Context) *execTestStream { func newExecTestStream(ctx context.Context) *execTestStream {
return &execTestStream{ return &execTestStream{
ctx: ctx, ctx: ctx,
requests: make(chan *ExecRequest, 8), requests: make(chan *v1.ExecRequest, 8),
responses: make(chan *ExecResponse, 8), responses: make(chan *v1.ExecResponse, 8),
} }
} }
func (stream *execTestStream) Send(response *ExecResponse) error { func (stream *execTestStream) Send(response *v1.ExecResponse) error {
if stream.sendHook != nil { if stream.sendHook != nil {
if err := stream.sendHook(response); err != nil { if err := stream.sendHook(response); err != nil {
return err return err
@@ -57,7 +58,7 @@ func (stream *execTestStream) Send(response *ExecResponse) error {
} }
} }
func (stream *execTestStream) Recv() (*ExecRequest, error) { func (stream *execTestStream) Recv() (*v1.ExecRequest, error) {
select { select {
case request, ok := <-stream.requests: case request, ok := <-stream.requests:
if !ok { if !ok {
@@ -72,7 +73,7 @@ func (stream *execTestStream) Recv() (*ExecRequest, error) {
func (stream *execTestStream) Context() context.Context { return stream.ctx } func (stream *execTestStream) Context() context.Context { return stream.ctx }
func TestExecSendsStartedBeforeOutputAndExit(t *testing.T) { func TestExecSendsStartedBeforeOutputAndExit(t *testing.T) {
_, stream, result := startExecTest(t, &ExecRequest_Command{ _, stream, result := startExecTest(t, &v1.ExecRequest_Command{
Name: execTestShell, Name: execTestShell,
Args: []string{"-c", "printf hello"}, Args: []string{"-c", "printf hello"},
}) })
@@ -84,9 +85,9 @@ func TestExecSendsStartedBeforeOutputAndExit(t *testing.T) {
for { for {
response := receiveExecResponse(t, stream) response := receiveExecResponse(t, stream)
switch response := response.GetType().(type) { switch response := response.GetType().(type) {
case *ExecResponse_StandardOutput: case *v1.ExecResponse_StandardOutput:
output = append(output, response.StandardOutput.GetData()...) output = append(output, response.StandardOutput.GetData()...)
case *ExecResponse_Exit_: case *v1.ExecResponse_Exit_:
require.EqualValues(t, 0, response.Exit.GetCode()) require.EqualValues(t, 0, response.Exit.GetCode())
require.Equal(t, []byte("hello"), output) require.Equal(t, []byte("hello"), output)
require.NoError(t, receiveExecResult(t, result)) require.NoError(t, receiveExecResult(t, result))
@@ -98,15 +99,15 @@ func TestExecSendsStartedBeforeOutputAndExit(t *testing.T) {
} }
func TestExecClosesStandardInputOnRequestStreamEOF(t *testing.T) { func TestExecClosesStandardInputOnRequestStreamEOF(t *testing.T) {
_, stream, result := startExecTest(t, &ExecRequest_Command{ _, stream, result := startExecTest(t, &v1.ExecRequest_Command{
Name: "/bin/cat", Name: "/bin/cat",
Interactive: true, Interactive: true,
}) })
require.NotNil(t, receiveExecResponse(t, stream).GetStarted()) require.NotNil(t, receiveExecResponse(t, stream).GetStarted())
stream.requests <- &ExecRequest{ stream.requests <- &v1.ExecRequest{
Type: &ExecRequest_StandardInput{ Type: &v1.ExecRequest_StandardInput{
StandardInput: &IOChunk{Data: []byte("hello")}, StandardInput: &v1.IOChunk{Data: []byte("hello")},
}, },
} }
close(stream.requests) close(stream.requests)
@@ -119,20 +120,20 @@ func TestExecClosesStandardInputOnRequestStreamEOF(t *testing.T) {
} }
func TestExecClosesStandardInputOnEmptyChunk(t *testing.T) { func TestExecClosesStandardInputOnEmptyChunk(t *testing.T) {
_, stream, result := startExecTest(t, &ExecRequest_Command{ _, stream, result := startExecTest(t, &v1.ExecRequest_Command{
Name: "/bin/cat", Name: "/bin/cat",
Interactive: true, Interactive: true,
}) })
require.NotNil(t, receiveExecResponse(t, stream).GetStarted()) require.NotNil(t, receiveExecResponse(t, stream).GetStarted())
stream.requests <- &ExecRequest{ stream.requests <- &v1.ExecRequest{
Type: &ExecRequest_StandardInput{ Type: &v1.ExecRequest_StandardInput{
StandardInput: &IOChunk{Data: []byte("hello")}, StandardInput: &v1.IOChunk{Data: []byte("hello")},
}, },
} }
stream.requests <- &ExecRequest{ stream.requests <- &v1.ExecRequest{
Type: &ExecRequest_StandardInput{ Type: &v1.ExecRequest_StandardInput{
StandardInput: &IOChunk{}, StandardInput: &v1.IOChunk{},
}, },
} }
@@ -146,17 +147,17 @@ func TestExecClosesStandardInputOnEmptyChunk(t *testing.T) {
func TestExecReportsStartFailureBeforeStarted(t *testing.T) { func TestExecReportsStartFailureBeforeStarted(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
command *ExecRequest_Command command *v1.ExecRequest_Command
}{ }{
{ {
name: "missing executable", name: "missing executable",
command: &ExecRequest_Command{ command: &v1.ExecRequest_Command{
Name: "/definitely/missing/tart-guest-agent-test-command", Name: "/definitely/missing/tart-guest-agent-test-command",
}, },
}, },
{ {
name: "missing workdir", name: "missing workdir",
command: &ExecRequest_Command{ command: &v1.ExecRequest_Command{
Name: execTestShell, Name: execTestShell,
Workdir: "/definitely/missing/tart-guest-agent-test-workdir", Workdir: "/definitely/missing/tart-guest-agent-test-workdir",
}, },
@@ -177,46 +178,46 @@ func TestExecReportsStartFailureBeforeStarted(t *testing.T) {
func TestExecSignalsProcess(t *testing.T) { func TestExecSignalsProcess(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
signal SignalRequest_Signal signal v1.SignalRequest_Signal
code int32 code int32
err string err string
}{ }{
{ {
name: "SIGTERM", name: "SIGTERM",
signal: SignalRequest_SIGNAL_SIGTERM, signal: v1.SignalRequest_SIGNAL_SIGTERM,
code: int32(signalExitCodeOffset + syscall.SIGTERM), code: int32(signalExitCodeOffset + syscall.SIGTERM),
}, },
{ {
name: "SIGKILL", name: "SIGKILL",
signal: SignalRequest_SIGNAL_SIGKILL, signal: v1.SignalRequest_SIGNAL_SIGKILL,
code: int32(signalExitCodeOffset + syscall.SIGKILL), code: int32(signalExitCodeOffset + syscall.SIGKILL),
}, },
{ {
name: "unsupported", name: "unsupported",
signal: SignalRequest_SIGNAL_UNSPECIFIED, signal: v1.SignalRequest_SIGNAL_UNSPECIFIED,
err: `unsupported exec signal "SIGNAL_UNSPECIFIED"`, err: `unsupported exec signal "SIGNAL_UNSPECIFIED"`,
}, },
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
rpc, stream, result := startExecTest(t, &ExecRequest_Command{ rpc, stream, result := startExecTest(t, &v1.ExecRequest_Command{
Name: "/bin/sleep", Name: "/bin/sleep",
Args: []string{"30"}, Args: []string{"30"},
}) })
started := receiveExecResponse(t, stream).GetStarted() started := receiveExecResponse(t, stream).GetStarted()
require.NotNil(t, started) require.NotNil(t, started)
_, err := rpc.Signal(context.Background(), &SignalRequest{ _, err := rpc.Signal(context.Background(), &v1.SignalRequest{
ExecId: started.GetExecId(), ExecId: started.GetExecId(),
Signal: test.signal, Signal: test.signal,
}) })
if test.err != "" { if test.err != "" {
require.EqualError(t, err, test.err) require.EqualError(t, err, test.err)
_, err = rpc.Signal(context.Background(), &SignalRequest{ _, err = rpc.Signal(context.Background(), &v1.SignalRequest{
ExecId: started.GetExecId(), ExecId: started.GetExecId(),
Signal: SignalRequest_SIGNAL_SIGKILL, Signal: v1.SignalRequest_SIGNAL_SIGKILL,
}) })
require.NoError(t, err) require.NoError(t, err)
receiveExecResponse(t, stream) receiveExecResponse(t, stream)
@@ -235,7 +236,7 @@ func TestExecSignalsProcess(t *testing.T) {
} }
func TestExecSignalsProcessGroup(t *testing.T) { func TestExecSignalsProcessGroup(t *testing.T) {
rpc, stream, result := startExecTest(t, &ExecRequest_Command{ rpc, stream, result := startExecTest(t, &v1.ExecRequest_Command{
Name: execTestShell, Name: execTestShell,
Args: []string{"-c", "sleep 30 & printf ready; wait"}, Args: []string{"-c", "sleep 30 & printf ready; wait"},
}) })
@@ -243,9 +244,9 @@ func TestExecSignalsProcessGroup(t *testing.T) {
require.NotNil(t, started) require.NotNil(t, started)
require.Equal(t, []byte("ready"), receiveExecResponse(t, stream).GetStandardOutput().GetData()) require.Equal(t, []byte("ready"), receiveExecResponse(t, stream).GetStandardOutput().GetData())
_, err := rpc.Signal(context.Background(), &SignalRequest{ _, err := rpc.Signal(context.Background(), &v1.SignalRequest{
ExecId: started.GetExecId(), ExecId: started.GetExecId(),
Signal: SignalRequest_SIGNAL_SIGTERM, Signal: v1.SignalRequest_SIGNAL_SIGTERM,
}) })
require.NoError(t, err) require.NoError(t, err)
@@ -259,12 +260,12 @@ func TestExecReapsProcessWhenStartedCannotBeSent(t *testing.T) {
sendErr := errors.New("failed to send Started") sendErr := errors.New("failed to send Started")
var processPID int var processPID int
_, _, result := startExecTest(t, &ExecRequest_Command{ _, _, result := startExecTest(t, &v1.ExecRequest_Command{
Name: execTestShell, Name: execTestShell,
Args: []string{"-c", `printf %d "$$" > "$PID_FILE"; exec sleep 30`}, Args: []string{"-c", `printf %d "$$" > "$PID_FILE"; exec sleep 30`},
Env: map[string]string{"PID_FILE": pidPath}, Env: map[string]string{"PID_FILE": pidPath},
}, func(stream *execTestStream) { }, func(stream *execTestStream) {
stream.sendHook = func(response *ExecResponse) error { stream.sendHook = func(response *v1.ExecResponse) error {
if response.GetStarted() == nil { if response.GetStarted() == nil {
return nil return nil
} }
@@ -285,7 +286,7 @@ func TestExecReapsProcessWhenStartedCannotBeSent(t *testing.T) {
func startExecTest( func startExecTest(
t *testing.T, t *testing.T,
command *ExecRequest_Command, command *v1.ExecRequest_Command,
configure ...func(*execTestStream), configure ...func(*execTestStream),
) (*RPC, *execTestStream, <-chan error) { ) (*RPC, *execTestStream, <-chan error) {
t.Helper() t.Helper()
@@ -302,13 +303,13 @@ func startExecTest(
go func() { go func() {
result <- rpc.Exec(stream) result <- rpc.Exec(stream)
}() }()
stream.requests <- &ExecRequest{ stream.requests <- &v1.ExecRequest{
Type: &ExecRequest_Command_{Command: command}, Type: &v1.ExecRequest_Command_{Command: command},
} }
return rpc, stream, result return rpc, stream, result
} }
func receiveExecResponse(t *testing.T, stream *execTestStream) *ExecResponse { func receiveExecResponse(t *testing.T, stream *execTestStream) *v1.ExecResponse {
t.Helper() t.Helper()
select { select {
+4 -2
View File
@@ -4,9 +4,11 @@ import (
"context" "context"
"fmt" "fmt"
"net" "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() ifaceAddrs, err := net.InterfaceAddrs()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to retrieve VM's network interface addresses: %w", err) 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 continue
} }
return &ResolveIPResponse{ return &v1.ResolveIPResponse{
Ip: ipNet.IP.String(), Ip: ipNet.IP.String(),
}, nil }, nil
} }
+4 -3
View File
@@ -5,16 +5,17 @@ import (
"net" "net"
"os" "os"
"github.com/cirruslabs/tart-guest-agent/pkg/v1"
"github.com/puzpuzpuz/xsync/v4" "github.com/puzpuzpuz/xsync/v4"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
type RPC struct { type RPC struct {
v1.UnimplementedAgentServer
grpcServer *grpc.Server grpcServer *grpc.Server
listener net.Listener listener net.Listener
execs *xsync.Map[string, *os.Process] execs *xsync.Map[string, *os.Process]
UnimplementedAgentServer
} }
func New(listener net.Listener) (*RPC, error) { func New(listener net.Listener) (*RPC, error) {
@@ -24,7 +25,7 @@ func New(listener net.Listener) (*RPC, error) {
execs: xsync.NewMap[string, *os.Process](), execs: xsync.NewMap[string, *os.Process](),
} }
RegisterAgentServer(rpc.grpcServer, rpc) v1.RegisterAgentServer(rpc.grpcServer, rpc)
return rpc, nil return rpc, nil
} }
+62 -62
View File
@@ -2,9 +2,9 @@
// versions: // versions:
// protoc-gen-go v1.36.6 // protoc-gen-go v1.36.6
// protoc v7.35.1 // protoc v7.35.1
// source: rpc/agent.proto // source: v1/agent.proto
package rpc package v1
import ( import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@@ -55,11 +55,11 @@ func (x SignalRequest_Signal) String() string {
} }
func (SignalRequest_Signal) Descriptor() protoreflect.EnumDescriptor { 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 { 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 { func (x SignalRequest_Signal) Number() protoreflect.EnumNumber {
@@ -68,7 +68,7 @@ func (x SignalRequest_Signal) Number() protoreflect.EnumNumber {
// Deprecated: Use SignalRequest_Signal.Descriptor instead. // Deprecated: Use SignalRequest_Signal.Descriptor instead.
func (SignalRequest_Signal) EnumDescriptor() ([]byte, []int) { 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 { type ExecRequest struct {
@@ -85,7 +85,7 @@ type ExecRequest struct {
func (x *ExecRequest) Reset() { func (x *ExecRequest) Reset() {
*x = ExecRequest{} *x = ExecRequest{}
mi := &file_rpc_agent_proto_msgTypes[0] mi := &file_v1_agent_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -97,7 +97,7 @@ func (x *ExecRequest) String() string {
func (*ExecRequest) ProtoMessage() {} func (*ExecRequest) ProtoMessage() {}
func (x *ExecRequest) ProtoReflect() protoreflect.Message { func (x *ExecRequest) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[0] mi := &file_v1_agent_proto_msgTypes[0]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -110,7 +110,7 @@ func (x *ExecRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ExecRequest.ProtoReflect.Descriptor instead.
func (*ExecRequest) Descriptor() ([]byte, []int) { 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 { func (x *ExecRequest) GetType() isExecRequest_Type {
@@ -184,7 +184,7 @@ type ExecResponse struct {
func (x *ExecResponse) Reset() { func (x *ExecResponse) Reset() {
*x = ExecResponse{} *x = ExecResponse{}
mi := &file_rpc_agent_proto_msgTypes[1] mi := &file_v1_agent_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -196,7 +196,7 @@ func (x *ExecResponse) String() string {
func (*ExecResponse) ProtoMessage() {} func (*ExecResponse) ProtoMessage() {}
func (x *ExecResponse) ProtoReflect() protoreflect.Message { func (x *ExecResponse) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[1] mi := &file_v1_agent_proto_msgTypes[1]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -209,7 +209,7 @@ func (x *ExecResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ExecResponse.ProtoReflect.Descriptor instead.
func (*ExecResponse) Descriptor() ([]byte, []int) { 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 { func (x *ExecResponse) GetType() isExecResponse_Type {
@@ -293,7 +293,7 @@ type TerminalSize struct {
func (x *TerminalSize) Reset() { func (x *TerminalSize) Reset() {
*x = TerminalSize{} *x = TerminalSize{}
mi := &file_rpc_agent_proto_msgTypes[2] mi := &file_v1_agent_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -305,7 +305,7 @@ func (x *TerminalSize) String() string {
func (*TerminalSize) ProtoMessage() {} func (*TerminalSize) ProtoMessage() {}
func (x *TerminalSize) ProtoReflect() protoreflect.Message { func (x *TerminalSize) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[2] mi := &file_v1_agent_proto_msgTypes[2]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -318,7 +318,7 @@ func (x *TerminalSize) ProtoReflect() protoreflect.Message {
// Deprecated: Use TerminalSize.ProtoReflect.Descriptor instead. // Deprecated: Use TerminalSize.ProtoReflect.Descriptor instead.
func (*TerminalSize) Descriptor() ([]byte, []int) { 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 { func (x *TerminalSize) GetRows() uint32 {
@@ -344,7 +344,7 @@ type IOChunk struct {
func (x *IOChunk) Reset() { func (x *IOChunk) Reset() {
*x = IOChunk{} *x = IOChunk{}
mi := &file_rpc_agent_proto_msgTypes[3] mi := &file_v1_agent_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -356,7 +356,7 @@ func (x *IOChunk) String() string {
func (*IOChunk) ProtoMessage() {} func (*IOChunk) ProtoMessage() {}
func (x *IOChunk) ProtoReflect() protoreflect.Message { func (x *IOChunk) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[3] mi := &file_v1_agent_proto_msgTypes[3]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -369,7 +369,7 @@ func (x *IOChunk) ProtoReflect() protoreflect.Message {
// Deprecated: Use IOChunk.ProtoReflect.Descriptor instead. // Deprecated: Use IOChunk.ProtoReflect.Descriptor instead.
func (*IOChunk) Descriptor() ([]byte, []int) { 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 { func (x *IOChunk) GetData() []byte {
@@ -387,7 +387,7 @@ type ResolveIPRequest struct {
func (x *ResolveIPRequest) Reset() { func (x *ResolveIPRequest) Reset() {
*x = ResolveIPRequest{} *x = ResolveIPRequest{}
mi := &file_rpc_agent_proto_msgTypes[4] mi := &file_v1_agent_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -399,7 +399,7 @@ func (x *ResolveIPRequest) String() string {
func (*ResolveIPRequest) ProtoMessage() {} func (*ResolveIPRequest) ProtoMessage() {}
func (x *ResolveIPRequest) ProtoReflect() protoreflect.Message { func (x *ResolveIPRequest) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[4] mi := &file_v1_agent_proto_msgTypes[4]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -412,7 +412,7 @@ func (x *ResolveIPRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ResolveIPRequest.ProtoReflect.Descriptor instead. // Deprecated: Use ResolveIPRequest.ProtoReflect.Descriptor instead.
func (*ResolveIPRequest) Descriptor() ([]byte, []int) { func (*ResolveIPRequest) Descriptor() ([]byte, []int) {
return file_rpc_agent_proto_rawDescGZIP(), []int{4} return file_v1_agent_proto_rawDescGZIP(), []int{4}
} }
type ResolveIPResponse struct { type ResolveIPResponse struct {
@@ -424,7 +424,7 @@ type ResolveIPResponse struct {
func (x *ResolveIPResponse) Reset() { func (x *ResolveIPResponse) Reset() {
*x = ResolveIPResponse{} *x = ResolveIPResponse{}
mi := &file_rpc_agent_proto_msgTypes[5] mi := &file_v1_agent_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -436,7 +436,7 @@ func (x *ResolveIPResponse) String() string {
func (*ResolveIPResponse) ProtoMessage() {} func (*ResolveIPResponse) ProtoMessage() {}
func (x *ResolveIPResponse) ProtoReflect() protoreflect.Message { func (x *ResolveIPResponse) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[5] mi := &file_v1_agent_proto_msgTypes[5]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -449,7 +449,7 @@ func (x *ResolveIPResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ResolveIPResponse.ProtoReflect.Descriptor instead. // Deprecated: Use ResolveIPResponse.ProtoReflect.Descriptor instead.
func (*ResolveIPResponse) Descriptor() ([]byte, []int) { 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 { func (x *ResolveIPResponse) GetIp() string {
@@ -469,7 +469,7 @@ type SignalRequest struct {
func (x *SignalRequest) Reset() { func (x *SignalRequest) Reset() {
*x = SignalRequest{} *x = SignalRequest{}
mi := &file_rpc_agent_proto_msgTypes[6] mi := &file_v1_agent_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -481,7 +481,7 @@ func (x *SignalRequest) String() string {
func (*SignalRequest) ProtoMessage() {} func (*SignalRequest) ProtoMessage() {}
func (x *SignalRequest) ProtoReflect() protoreflect.Message { func (x *SignalRequest) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[6] mi := &file_v1_agent_proto_msgTypes[6]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -494,7 +494,7 @@ func (x *SignalRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SignalRequest.ProtoReflect.Descriptor instead. // Deprecated: Use SignalRequest.ProtoReflect.Descriptor instead.
func (*SignalRequest) Descriptor() ([]byte, []int) { 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 { func (x *SignalRequest) GetExecId() string {
@@ -528,7 +528,7 @@ type ExecRequest_Command struct {
func (x *ExecRequest_Command) Reset() { func (x *ExecRequest_Command) Reset() {
*x = ExecRequest_Command{} *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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -540,7 +540,7 @@ func (x *ExecRequest_Command) String() string {
func (*ExecRequest_Command) ProtoMessage() {} func (*ExecRequest_Command) ProtoMessage() {}
func (x *ExecRequest_Command) ProtoReflect() protoreflect.Message { func (x *ExecRequest_Command) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[7] mi := &file_v1_agent_proto_msgTypes[7]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -553,7 +553,7 @@ func (x *ExecRequest_Command) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecRequest_Command.ProtoReflect.Descriptor instead. // Deprecated: Use ExecRequest_Command.ProtoReflect.Descriptor instead.
func (*ExecRequest_Command) Descriptor() ([]byte, []int) { 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 { func (x *ExecRequest_Command) GetName() string {
@@ -628,7 +628,7 @@ type ExecResponse_Exit struct {
func (x *ExecResponse_Exit) Reset() { func (x *ExecResponse_Exit) Reset() {
*x = ExecResponse_Exit{} *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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -640,7 +640,7 @@ func (x *ExecResponse_Exit) String() string {
func (*ExecResponse_Exit) ProtoMessage() {} func (*ExecResponse_Exit) ProtoMessage() {}
func (x *ExecResponse_Exit) ProtoReflect() protoreflect.Message { func (x *ExecResponse_Exit) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[9] mi := &file_v1_agent_proto_msgTypes[9]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -653,7 +653,7 @@ func (x *ExecResponse_Exit) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecResponse_Exit.ProtoReflect.Descriptor instead. // Deprecated: Use ExecResponse_Exit.ProtoReflect.Descriptor instead.
func (*ExecResponse_Exit) Descriptor() ([]byte, []int) { 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 { func (x *ExecResponse_Exit) GetCode() int32 {
@@ -672,7 +672,7 @@ type ExecResponse_Started struct {
func (x *ExecResponse_Started) Reset() { func (x *ExecResponse_Started) Reset() {
*x = ExecResponse_Started{} *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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -684,7 +684,7 @@ func (x *ExecResponse_Started) String() string {
func (*ExecResponse_Started) ProtoMessage() {} func (*ExecResponse_Started) ProtoMessage() {}
func (x *ExecResponse_Started) ProtoReflect() protoreflect.Message { func (x *ExecResponse_Started) ProtoReflect() protoreflect.Message {
mi := &file_rpc_agent_proto_msgTypes[10] mi := &file_v1_agent_proto_msgTypes[10]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -697,7 +697,7 @@ func (x *ExecResponse_Started) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExecResponse_Started.ProtoReflect.Descriptor instead. // Deprecated: Use ExecResponse_Started.ProtoReflect.Descriptor instead.
func (*ExecResponse_Started) Descriptor() ([]byte, []int) { 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 { func (x *ExecResponse_Started) GetExecId() string {
@@ -707,11 +707,11 @@ func (x *ExecResponse_Started) GetExecId() string {
return "" 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" + "\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" + "\vExecRequest\x120\n" +
"\acommand\x18\x01 \x01(\v2\x14.ExecRequest.CommandH\x00R\acommand\x121\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" + "\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" + "\x05Agent\x12'\n" +
"\x04Exec\x12\f.ExecRequest\x1a\r.ExecResponse(\x010\x01\x120\n" + "\x04Exec\x12\f.ExecRequest\x1a\r.ExecResponse(\x010\x01\x120\n" +
"\x06Signal\x12\x0e.SignalRequest\x1a\x16.google.protobuf.Empty\x122\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 ( var (
file_rpc_agent_proto_rawDescOnce sync.Once file_v1_agent_proto_rawDescOnce sync.Once
file_rpc_agent_proto_rawDescData []byte file_v1_agent_proto_rawDescData []byte
) )
func file_rpc_agent_proto_rawDescGZIP() []byte { func file_v1_agent_proto_rawDescGZIP() []byte {
file_rpc_agent_proto_rawDescOnce.Do(func() { file_v1_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))) 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_v1_agent_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_rpc_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_v1_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_rpc_agent_proto_goTypes = []any{ var file_v1_agent_proto_goTypes = []any{
(SignalRequest_Signal)(0), // 0: SignalRequest.Signal (SignalRequest_Signal)(0), // 0: SignalRequest.Signal
(*ExecRequest)(nil), // 1: ExecRequest (*ExecRequest)(nil), // 1: ExecRequest
(*ExecResponse)(nil), // 2: ExecResponse (*ExecResponse)(nil), // 2: ExecResponse
@@ -789,7 +789,7 @@ var file_rpc_agent_proto_goTypes = []any{
(*ExecResponse_Started)(nil), // 11: ExecResponse.Started (*ExecResponse_Started)(nil), // 11: ExecResponse.Started
(*emptypb.Empty)(nil), // 12: google.protobuf.Empty (*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 8, // 0: ExecRequest.command:type_name -> ExecRequest.Command
4, // 1: ExecRequest.standard_input:type_name -> IOChunk 4, // 1: ExecRequest.standard_input:type_name -> IOChunk
3, // 2: ExecRequest.terminal_resize:type_name -> TerminalSize 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 0, // [0:10] is the sub-list for field type_name
} }
func init() { file_rpc_agent_proto_init() } func init() { file_v1_agent_proto_init() }
func file_rpc_agent_proto_init() { func file_v1_agent_proto_init() {
if File_rpc_agent_proto != nil { if File_v1_agent_proto != nil {
return return
} }
file_rpc_agent_proto_msgTypes[0].OneofWrappers = []any{ file_v1_agent_proto_msgTypes[0].OneofWrappers = []any{
(*ExecRequest_Command_)(nil), (*ExecRequest_Command_)(nil),
(*ExecRequest_StandardInput)(nil), (*ExecRequest_StandardInput)(nil),
(*ExecRequest_TerminalResize)(nil), (*ExecRequest_TerminalResize)(nil),
} }
file_rpc_agent_proto_msgTypes[1].OneofWrappers = []any{ file_v1_agent_proto_msgTypes[1].OneofWrappers = []any{
(*ExecResponse_Exit_)(nil), (*ExecResponse_Exit_)(nil),
(*ExecResponse_StandardOutput)(nil), (*ExecResponse_StandardOutput)(nil),
(*ExecResponse_StandardError)(nil), (*ExecResponse_StandardError)(nil),
@@ -833,18 +833,18 @@ func file_rpc_agent_proto_init() {
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 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, NumEnums: 1,
NumMessages: 11, NumMessages: 11,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },
GoTypes: file_rpc_agent_proto_goTypes, GoTypes: file_v1_agent_proto_goTypes,
DependencyIndexes: file_rpc_agent_proto_depIdxs, DependencyIndexes: file_v1_agent_proto_depIdxs,
EnumInfos: file_rpc_agent_proto_enumTypes, EnumInfos: file_v1_agent_proto_enumTypes,
MessageInfos: file_rpc_agent_proto_msgTypes, MessageInfos: file_v1_agent_proto_msgTypes,
}.Build() }.Build()
File_rpc_agent_proto = out.File File_v1_agent_proto = out.File
file_rpc_agent_proto_goTypes = nil file_v1_agent_proto_goTypes = nil
file_rpc_agent_proto_depIdxs = nil file_v1_agent_proto_depIdxs = nil
} }
@@ -2,9 +2,9 @@
// versions: // versions:
// - protoc-gen-go-grpc v1.5.1 // - protoc-gen-go-grpc v1.5.1
// - protoc v7.35.1 // - protoc v7.35.1
// source: rpc/agent.proto // source: v1/agent.proto
package rpc package v1
import ( import (
context "context" context "context"
@@ -189,5 +189,5 @@ var Agent_ServiceDesc = grpc.ServiceDesc{
ClientStreams: true, ClientStreams: true,
}, },
}, },
Metadata: "rpc/agent.proto", Metadata: "v1/agent.proto",
} }
@@ -2,7 +2,7 @@ syntax = "proto3";
import "google/protobuf/empty.proto"; 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 { service Agent {
rpc Exec(stream ExecRequest) returns (stream ExecResponse); rpc Exec(stream ExecRequest) returns (stream ExecResponse);