diff --git a/go.mod b/go.mod index 51e126ad7..319211371 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 github.com/Microsoft/go-winio v0.6.1 github.com/atotto/clipboard v0.1.4 - github.com/bufbuild/connect-go v1.10.0 github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/lipgloss v0.9.1 github.com/cli/cli/v2 v2.42.1 diff --git a/go.sum b/go.sum index ae096af70..29ad75fb3 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= -github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg= -github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/charmbracelet/bubbles v0.17.1 h1:0SIyjOnkrsfDo88YvPgAWvZMwXe26TP6drRvmkjyUu4= github.com/charmbracelet/bubbles v0.17.1/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o= diff --git a/internal/cmd/server.go b/internal/cmd/server.go index 52f88c836..09d5dafc3 100644 --- a/internal/cmd/server.go +++ b/internal/cmd/server.go @@ -7,19 +7,21 @@ import ( "strings" "github.com/spf13/cobra" + "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/grpc/health" + healthgrpc "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/reflection" + "github.com/stateful/runme/internal/document/editor/editorservice" parserv1 "github.com/stateful/runme/internal/gen/proto/go/runme/parser/v1" projectv1 "github.com/stateful/runme/internal/gen/proto/go/runme/project/v1" runnerv1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1" + runnerv2alpha1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v2alpha1" "github.com/stateful/runme/internal/project/projectservice" "github.com/stateful/runme/internal/runner" runnerv2service "github.com/stateful/runme/internal/runnerv2service" runmetls "github.com/stateful/runme/internal/tls" - "go.uber.org/zap" - "google.golang.org/grpc" - "google.golang.org/grpc/health" - healthgrpc "google.golang.org/grpc/health/grpc_health_v1" - "google.golang.org/grpc/reflection" ) func serverCmd() *cobra.Command { diff --git a/internal/gen/proto/go/runme/runner/v2alpha1/runnerv1connect/runner.connect.go b/internal/gen/proto/go/runme/runner/v2alpha1/runnerv1connect/runner.connect.go deleted file mode 100644 index f3974b870..000000000 --- a/internal/gen/proto/go/runme/runner/v2alpha1/runnerv1connect/runner.connect.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: runme/runner/v2alpha1/runner.proto - -package runnerv1connect - -import ( - context "context" - errors "errors" - connect_go "github.com/bufbuild/connect-go" - v1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect_go.IsAtLeastVersion0_1_0 - -const ( - // RunnerServiceName is the fully-qualified name of the RunnerService service. - RunnerServiceName = "runme.runner.v2alpha1.RunnerService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // RunnerServiceCreateSessionProcedure is the fully-qualified name of the RunnerService's - // CreateSession RPC. - RunnerServiceCreateSessionProcedure = "/runme.runner.v2alpha1.RunnerService/CreateSession" - // RunnerServiceGetSessionProcedure is the fully-qualified name of the RunnerService's GetSession - // RPC. - RunnerServiceGetSessionProcedure = "/runme.runner.v2alpha1.RunnerService/GetSession" - // RunnerServiceListSessionsProcedure is the fully-qualified name of the RunnerService's - // ListSessions RPC. - RunnerServiceListSessionsProcedure = "/runme.runner.v2alpha1.RunnerService/ListSessions" - // RunnerServiceDeleteSessionProcedure is the fully-qualified name of the RunnerService's - // DeleteSession RPC. - RunnerServiceDeleteSessionProcedure = "/runme.runner.v2alpha1.RunnerService/DeleteSession" - // RunnerServiceExecuteProcedure is the fully-qualified name of the RunnerService's Execute RPC. - RunnerServiceExecuteProcedure = "/runme.runner.v2alpha1.RunnerService/Execute" - // RunnerServiceResolveEnvProcedure is the fully-qualified name of the RunnerService's ResolveEnv - // RPC. - RunnerServiceResolveEnvProcedure = "/runme.runner.v2alpha1.RunnerService/ResolveEnv" -) - -// RunnerServiceClient is a client for the runme.runner.v2alpha1.RunnerService service. -type RunnerServiceClient interface { - CreateSession(context.Context, *connect_go.Request[v1.CreateSessionRequest]) (*connect_go.Response[v1.CreateSessionResponse], error) - GetSession(context.Context, *connect_go.Request[v1.GetSessionRequest]) (*connect_go.Response[v1.GetSessionResponse], error) - ListSessions(context.Context, *connect_go.Request[v1.ListSessionsRequest]) (*connect_go.Response[v1.ListSessionsResponse], error) - DeleteSession(context.Context, *connect_go.Request[v1.DeleteSessionRequest]) (*connect_go.Response[v1.DeleteSessionResponse], error) - // Execute executes a program. Examine "ExecuteRequest" to explore - // configuration options. - // - // It's a bidirectional stream RPC method. It expects the first - // "ExecuteRequest" to contain details of a program to execute. - // Subsequent "ExecuteRequest" should only contain "input_data" as - // other fields will be ignored. - Execute(context.Context) *connect_go.BidiStreamForClient[v1.ExecuteRequest, v1.ExecuteResponse] - ResolveEnv(context.Context, *connect_go.Request[v1.ResolveEnvRequest]) (*connect_go.Response[v1.ResolveEnvResponse], error) -} - -// NewRunnerServiceClient constructs a client for the runme.runner.v2alpha1.RunnerService service. -// By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped -// responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the -// connect.WithGRPC() or connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewRunnerServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) RunnerServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &runnerServiceClient{ - createSession: connect_go.NewClient[v1.CreateSessionRequest, v1.CreateSessionResponse]( - httpClient, - baseURL+RunnerServiceCreateSessionProcedure, - opts..., - ), - getSession: connect_go.NewClient[v1.GetSessionRequest, v1.GetSessionResponse]( - httpClient, - baseURL+RunnerServiceGetSessionProcedure, - opts..., - ), - listSessions: connect_go.NewClient[v1.ListSessionsRequest, v1.ListSessionsResponse]( - httpClient, - baseURL+RunnerServiceListSessionsProcedure, - opts..., - ), - deleteSession: connect_go.NewClient[v1.DeleteSessionRequest, v1.DeleteSessionResponse]( - httpClient, - baseURL+RunnerServiceDeleteSessionProcedure, - opts..., - ), - execute: connect_go.NewClient[v1.ExecuteRequest, v1.ExecuteResponse]( - httpClient, - baseURL+RunnerServiceExecuteProcedure, - opts..., - ), - resolveEnv: connect_go.NewClient[v1.ResolveEnvRequest, v1.ResolveEnvResponse]( - httpClient, - baseURL+RunnerServiceResolveEnvProcedure, - opts..., - ), - } -} - -// runnerServiceClient implements RunnerServiceClient. -type runnerServiceClient struct { - createSession *connect_go.Client[v1.CreateSessionRequest, v1.CreateSessionResponse] - getSession *connect_go.Client[v1.GetSessionRequest, v1.GetSessionResponse] - listSessions *connect_go.Client[v1.ListSessionsRequest, v1.ListSessionsResponse] - deleteSession *connect_go.Client[v1.DeleteSessionRequest, v1.DeleteSessionResponse] - execute *connect_go.Client[v1.ExecuteRequest, v1.ExecuteResponse] - resolveEnv *connect_go.Client[v1.ResolveEnvRequest, v1.ResolveEnvResponse] -} - -// CreateSession calls runme.runner.v2alpha1.RunnerService.CreateSession. -func (c *runnerServiceClient) CreateSession(ctx context.Context, req *connect_go.Request[v1.CreateSessionRequest]) (*connect_go.Response[v1.CreateSessionResponse], error) { - return c.createSession.CallUnary(ctx, req) -} - -// GetSession calls runme.runner.v2alpha1.RunnerService.GetSession. -func (c *runnerServiceClient) GetSession(ctx context.Context, req *connect_go.Request[v1.GetSessionRequest]) (*connect_go.Response[v1.GetSessionResponse], error) { - return c.getSession.CallUnary(ctx, req) -} - -// ListSessions calls runme.runner.v2alpha1.RunnerService.ListSessions. -func (c *runnerServiceClient) ListSessions(ctx context.Context, req *connect_go.Request[v1.ListSessionsRequest]) (*connect_go.Response[v1.ListSessionsResponse], error) { - return c.listSessions.CallUnary(ctx, req) -} - -// DeleteSession calls runme.runner.v2alpha1.RunnerService.DeleteSession. -func (c *runnerServiceClient) DeleteSession(ctx context.Context, req *connect_go.Request[v1.DeleteSessionRequest]) (*connect_go.Response[v1.DeleteSessionResponse], error) { - return c.deleteSession.CallUnary(ctx, req) -} - -// Execute calls runme.runner.v2alpha1.RunnerService.Execute. -func (c *runnerServiceClient) Execute(ctx context.Context) *connect_go.BidiStreamForClient[v1.ExecuteRequest, v1.ExecuteResponse] { - return c.execute.CallBidiStream(ctx) -} - -// ResolveEnv calls runme.runner.v2alpha1.RunnerService.ResolveEnv. -func (c *runnerServiceClient) ResolveEnv(ctx context.Context, req *connect_go.Request[v1.ResolveEnvRequest]) (*connect_go.Response[v1.ResolveEnvResponse], error) { - return c.resolveEnv.CallUnary(ctx, req) -} - -// RunnerServiceHandler is an implementation of the runme.runner.v2alpha1.RunnerService service. -type RunnerServiceHandler interface { - CreateSession(context.Context, *connect_go.Request[v1.CreateSessionRequest]) (*connect_go.Response[v1.CreateSessionResponse], error) - GetSession(context.Context, *connect_go.Request[v1.GetSessionRequest]) (*connect_go.Response[v1.GetSessionResponse], error) - ListSessions(context.Context, *connect_go.Request[v1.ListSessionsRequest]) (*connect_go.Response[v1.ListSessionsResponse], error) - DeleteSession(context.Context, *connect_go.Request[v1.DeleteSessionRequest]) (*connect_go.Response[v1.DeleteSessionResponse], error) - // Execute executes a program. Examine "ExecuteRequest" to explore - // configuration options. - // - // It's a bidirectional stream RPC method. It expects the first - // "ExecuteRequest" to contain details of a program to execute. - // Subsequent "ExecuteRequest" should only contain "input_data" as - // other fields will be ignored. - Execute(context.Context, *connect_go.BidiStream[v1.ExecuteRequest, v1.ExecuteResponse]) error - ResolveEnv(context.Context, *connect_go.Request[v1.ResolveEnvRequest]) (*connect_go.Response[v1.ResolveEnvResponse], error) -} - -// NewRunnerServiceHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewRunnerServiceHandler(svc RunnerServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { - runnerServiceCreateSessionHandler := connect_go.NewUnaryHandler( - RunnerServiceCreateSessionProcedure, - svc.CreateSession, - opts..., - ) - runnerServiceGetSessionHandler := connect_go.NewUnaryHandler( - RunnerServiceGetSessionProcedure, - svc.GetSession, - opts..., - ) - runnerServiceListSessionsHandler := connect_go.NewUnaryHandler( - RunnerServiceListSessionsProcedure, - svc.ListSessions, - opts..., - ) - runnerServiceDeleteSessionHandler := connect_go.NewUnaryHandler( - RunnerServiceDeleteSessionProcedure, - svc.DeleteSession, - opts..., - ) - runnerServiceExecuteHandler := connect_go.NewBidiStreamHandler( - RunnerServiceExecuteProcedure, - svc.Execute, - opts..., - ) - runnerServiceResolveEnvHandler := connect_go.NewUnaryHandler( - RunnerServiceResolveEnvProcedure, - svc.ResolveEnv, - opts..., - ) - return "/runme.runner.v2alpha1.RunnerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case RunnerServiceCreateSessionProcedure: - runnerServiceCreateSessionHandler.ServeHTTP(w, r) - case RunnerServiceGetSessionProcedure: - runnerServiceGetSessionHandler.ServeHTTP(w, r) - case RunnerServiceListSessionsProcedure: - runnerServiceListSessionsHandler.ServeHTTP(w, r) - case RunnerServiceDeleteSessionProcedure: - runnerServiceDeleteSessionHandler.ServeHTTP(w, r) - case RunnerServiceExecuteProcedure: - runnerServiceExecuteHandler.ServeHTTP(w, r) - case RunnerServiceResolveEnvProcedure: - runnerServiceResolveEnvHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedRunnerServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedRunnerServiceHandler struct{} - -func (UnimplementedRunnerServiceHandler) CreateSession(context.Context, *connect_go.Request[v1.CreateSessionRequest]) (*connect_go.Response[v1.CreateSessionResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.CreateSession is not implemented")) -} - -func (UnimplementedRunnerServiceHandler) GetSession(context.Context, *connect_go.Request[v1.GetSessionRequest]) (*connect_go.Response[v1.GetSessionResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.GetSession is not implemented")) -} - -func (UnimplementedRunnerServiceHandler) ListSessions(context.Context, *connect_go.Request[v1.ListSessionsRequest]) (*connect_go.Response[v1.ListSessionsResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.ListSessions is not implemented")) -} - -func (UnimplementedRunnerServiceHandler) DeleteSession(context.Context, *connect_go.Request[v1.DeleteSessionRequest]) (*connect_go.Response[v1.DeleteSessionResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.DeleteSession is not implemented")) -} - -func (UnimplementedRunnerServiceHandler) Execute(context.Context, *connect_go.BidiStream[v1.ExecuteRequest, v1.ExecuteResponse]) error { - return connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.Execute is not implemented")) -} - -func (UnimplementedRunnerServiceHandler) ResolveEnv(context.Context, *connect_go.Request[v1.ResolveEnvRequest]) (*connect_go.Response[v1.ResolveEnvResponse], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runme.runner.v2alpha1.RunnerService.ResolveEnv is not implemented")) -}