diff options
author | Toon Claes <toon@gitlab.com> | 2021-09-30 18:06:15 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2021-09-30 18:06:15 +0300 |
commit | 1ec2f7682f9aad976a323881c4437228f4e7c201 (patch) | |
tree | aab863f7db31c4cd62f2a9f8c9126cf87721ec96 | |
parent | eeca095e5680831ad140c2338d0f1c7d8b06a1ba (diff) | |
parent | 7d681ebd6c531e048a9e5d41f524dafc02e76516 (diff) |
Merge branch 'qmnguyen0711/1219-create-postuploadpackwithsidechannel-postuploadpack-replacement-using-sidechannel' into 'master'
Create PostUploadPackWithSidechannel
See merge request gitlab-org/gitaly!3883
-rw-r--r-- | internal/gitaly/service/smarthttp/testhelper_test.go | 16 | ||||
-rw-r--r-- | internal/gitaly/service/smarthttp/upload_pack.go | 145 | ||||
-rw-r--r-- | internal/gitaly/service/smarthttp/upload_pack_test.go | 259 | ||||
-rw-r--r-- | proto/go/gitalypb/smarthttp.pb.go | 313 | ||||
-rw-r--r-- | proto/go/gitalypb/smarthttp_grpc.pb.go | 41 | ||||
-rw-r--r-- | proto/smarthttp.proto | 18 | ||||
-rw-r--r-- | ruby/proto/gitaly/smarthttp_pb.rb | 9 | ||||
-rw-r--r-- | ruby/proto/gitaly/smarthttp_services_pb.rb | 2 |
8 files changed, 612 insertions, 191 deletions
diff --git a/internal/gitaly/service/smarthttp/testhelper_test.go b/internal/gitaly/service/smarthttp/testhelper_test.go index bb6b2c9fe..3b4ef7cfc 100644 --- a/internal/gitaly/service/smarthttp/testhelper_test.go +++ b/internal/gitaly/service/smarthttp/testhelper_test.go @@ -53,6 +53,22 @@ func runSmartHTTPServer(t *testing.T, cfg config.Cfg, serverOpts ...ServerOpt) s return gitalyServer.Address() } +// TODO: remove this method and use runSmartHTTPServer after +// https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1218 +func runSmartHTTPServerWithoutPraefect(t *testing.T, cfg config.Cfg, serverOpts ...ServerOpt) string { + gitalyServer := testserver.StartGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { + gitalypb.RegisterSmartHTTPServiceServer(srv, NewServer( + deps.GetCfg(), + deps.GetLocator(), + deps.GetGitCmdFactory(), + deps.GetDiskCache(), + serverOpts..., + )) + gitalypb.RegisterHookServiceServer(srv, hookservice.NewServer(deps.GetCfg(), deps.GetHookManager(), deps.GetGitCmdFactory(), deps.GetPackObjectsCache())) + }, testserver.WithDisablePraefect()) + return gitalyServer.Address() +} + func newSmartHTTPClient(t *testing.T, serverSocketPath, token string) (gitalypb.SmartHTTPServiceClient, *grpc.ClientConn) { t.Helper() diff --git a/internal/gitaly/service/smarthttp/upload_pack.go b/internal/gitaly/service/smarthttp/upload_pack.go index e8e900d63..768e686e6 100644 --- a/internal/gitaly/service/smarthttp/upload_pack.go +++ b/internal/gitaly/service/smarthttp/upload_pack.go @@ -10,12 +10,20 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/command" "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/stats" + "gitlab.com/gitlab-org/gitaly/v14/internal/helper" + "gitlab.com/gitlab-org/gitaly/v14/internal/sidechannel" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/v14/streamio" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) +type basicPostUploadPackRequest interface { + GetRepository() *gitalypb.Repository + GetGitConfigOptions() []string + GetGitProtocol() string +} + func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackServer) error { ctx := stream.Context() @@ -24,81 +32,48 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS return err } - if err := validateUploadPackRequest(req); err != nil { - return err + if req.Data != nil { + return status.Errorf(codes.InvalidArgument, "non-empty Data") } - h := sha1.New() + repoPath, gitConfig, err := s.validateUploadPackRequest(ctx, req) + if err != nil { + return err + } - stdinReader := io.TeeReader(streamio.NewReader(func() ([]byte, error) { + stdin := streamio.NewReader(func() ([]byte, error) { resp, err := stream.Recv() return resp.GetData(), err - }), h) - - stdin, collector := s.runStatsCollector(stream.Context(), stdinReader) - defer collector.finish() - - var respBytes int64 - + }) stdout := streamio.NewWriter(func(p []byte) error { - respBytes += int64(len(p)) return stream.Send(&gitalypb.PostUploadPackResponse{Data: p}) }) - repoPath, err := s.locator.GetRepoPath(req.Repository) - if err != nil { - return err - } - - git.WarnIfTooManyBitmaps(ctx, s.locator, req.GetRepository().GetStorageName(), repoPath) + return s.runUploadPack(ctx, req, repoPath, gitConfig, stdin, stdout) +} - config, err := git.ConvertConfigOptions(req.GitConfigOptions) +func (s *server) PostUploadPackWithSidechannel(ctx context.Context, req *gitalypb.PostUploadPackWithSidechannelRequest) (*gitalypb.PostUploadPackWithSidechannelResponse, error) { + repoPath, gitConfig, err := s.validateUploadPackRequest(ctx, req) if err != nil { - return err + return nil, err } - commandOpts := []git.CmdOpt{ - git.WithStdin(stdin), - git.WithStdout(stdout), - git.WithGitProtocol(ctx, req), - git.WithConfig(config...), - git.WithPackObjectsHookEnv(ctx, req.Repository, s.cfg), - } - - cmd, err := s.gitCmdFactory.NewWithoutRepo(ctx, git.SubCmd{ - Name: "upload-pack", - Flags: []git.Option{git.Flag{Name: "--stateless-rpc"}}, - Args: []string{repoPath}, - }, commandOpts...) + conn, err := sidechannel.OpenSidechannel(ctx) if err != nil { - return status.Errorf(codes.Unavailable, "PostUploadPack: cmd: %v", err) + return nil, status.Errorf(codes.Internal, "open sidechannel: %v", err) } + defer conn.Close() - if err := cmd.Wait(); err != nil { - stats := collector.finish() - - if _, ok := command.ExitStatus(err); ok && stats.Deepen != "" { - // We have seen a 'deepen' message in the request. It is expected that - // git-upload-pack has a non-zero exit status: don't treat this as an - // error. - return nil - } - - return status.Errorf(codes.Unavailable, "PostUploadPack: %v", err) + if err := s.runUploadPack(ctx, req, repoPath, gitConfig, conn, conn); err != nil { + return nil, err } - ctxlogrus.Extract(ctx).WithField("request_sha", fmt.Sprintf("%x", h.Sum(nil))).WithField("response_bytes", respBytes).Info("request details") - - return nil -} - -func validateUploadPackRequest(req *gitalypb.PostUploadPackRequest) error { - if req.Data != nil { - return status.Errorf(codes.InvalidArgument, "PostUploadPack: non-empty Data") + if err := conn.Close(); err != nil { + return nil, status.Errorf(codes.Internal, "close sidechannel connection: %v", err) } - return nil + return &gitalypb.PostUploadPackWithSidechannelResponse{}, nil } type statsCollector struct { @@ -133,3 +108,65 @@ func (s *server) runStatsCollector(ctx context.Context, r io.Reader) (io.Reader, return io.TeeReader(r, pw), sc } + +func (s *server) validateUploadPackRequest(ctx context.Context, req basicPostUploadPackRequest) (string, []git.ConfigPair, error) { + repoPath, err := s.locator.GetRepoPath(req.GetRepository()) + if err != nil { + return "", nil, helper.ErrInvalidArgument(err) + } + + git.WarnIfTooManyBitmaps(ctx, s.locator, req.GetRepository().GetStorageName(), repoPath) + + config, err := git.ConvertConfigOptions(req.GetGitConfigOptions()) + if err != nil { + return "", nil, helper.ErrInvalidArgument(err) + } + + return repoPath, config, nil +} + +func (s *server) runUploadPack(ctx context.Context, req basicPostUploadPackRequest, repoPath string, gitConfig []git.ConfigPair, stdin io.Reader, stdout io.Writer) error { + h := sha1.New() + + stdin = io.TeeReader(stdin, h) + stdin, collector := s.runStatsCollector(ctx, stdin) + defer collector.finish() + + commandOpts := []git.CmdOpt{ + git.WithStdin(stdin), + git.WithGitProtocol(ctx, req), + git.WithConfig(gitConfig...), + git.WithPackObjectsHookEnv(ctx, req.GetRepository(), s.cfg), + } + + cmd, err := s.gitCmdFactory.NewWithoutRepo(ctx, git.SubCmd{ + Name: "upload-pack", + Flags: []git.Option{git.Flag{Name: "--stateless-rpc"}}, + Args: []string{repoPath}, + }, commandOpts...) + if err != nil { + return helper.ErrUnavailablef("cmd: %v", err) + } + + respBytes, err := io.Copy(stdout, cmd) + if err != nil { + return helper.ErrUnavailablef("Fail to transfer git data: %v", err) + } + + if err := cmd.Wait(); err != nil { + stats := collector.finish() + + if _, ok := command.ExitStatus(err); ok && stats.Deepen != "" { + // We have seen a 'deepen' message in the request. It is expected that + // git-upload-pack has a non-zero exit status: don't treat this as an + // error. + return nil + } + + return helper.ErrUnavailable(err) + } + + ctxlogrus.Extract(ctx).WithField("request_sha", fmt.Sprintf("%x", h.Sum(nil))).WithField("response_bytes", respBytes).Info("request details") + + return nil +} diff --git a/internal/gitaly/service/smarthttp/upload_pack_test.go b/internal/gitaly/service/smarthttp/upload_pack_test.go index 8785a2c0e..1d9a9012a 100644 --- a/internal/gitaly/service/smarthttp/upload_pack_test.go +++ b/internal/gitaly/service/smarthttp/upload_pack_test.go @@ -11,46 +11,69 @@ import ( "github.com/prometheus/client_golang/prometheus" promtest "github.com/prometheus/client_golang/prometheus/testutil" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth" + "gitlab.com/gitlab-org/gitaly/v14/internal/backchannel" "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v14/internal/git/pktline" + "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" + "gitlab.com/gitlab-org/gitaly/v14/internal/listenmux" + "gitlab.com/gitlab-org/gitaly/v14/internal/sidechannel" "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/v14/streamio" + "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" ) const ( clientCapabilities = `multi_ack_detailed no-done side-band-64k thin-pack include-tag ofs-delta deepen-since deepen-not filter agent=git/2.18.0` ) -func runTestWithAndWithoutConfigOptions(t *testing.T, tf func(t *testing.T, ctx context.Context, opts ...testcfg.Option), opts ...testcfg.Option) { +type ( + requestMaker func(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) + serverRunner func(t *testing.T, cfg config.Cfg, serverOpts ...ServerOpt) string +) + +func runTestWithAndWithoutConfigOptions( + t *testing.T, + tf func(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option), + makeRequest requestMaker, + runServer serverRunner, + opts ...testcfg.Option, +) { ctx, cancel := testhelper.Context() defer cancel() - t.Run("no config options", func(t *testing.T) { tf(t, ctx) }) + t.Run("no config options", func(t *testing.T) { tf(t, ctx, makeRequest, runServer) }) if len(opts) > 0 { t.Run("with config options", func(t *testing.T) { - tf(t, ctx, opts...) + tf(t, ctx, makeRequest, runServer, opts...) }) } } func TestServer_PostUpload(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUpload, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUpload, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) +} + +func TestServer_PostUploadWithChannel(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUpload, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUpload(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func testServerPostUpload(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...) _, localRepoPath := gittest.CloneRepo(t, cfg, cfg.Storages[0]) testhelper.BuildGitalyHooks(t, cfg) negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"}) - serverSocketPath := runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) + serverSocketPath := runServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) oldCommit, err := git.NewObjectIDFromHex("1e292f8fedd741b75372e19097c76d327140c312") // refs/heads/master require.NoError(t, err) @@ -65,7 +88,7 @@ func testServerPostUpload(t *testing.T, ctx context.Context, opts ...testcfg.Opt gittest.WritePktlineFlush(t, requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, requestBuffer) + responseBuffer, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -81,14 +104,18 @@ func testServerPostUpload(t *testing.T, ctx context.Context, opts ...testcfg.Opt } func TestServer_PostUploadPack_gitConfigOptions(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitConfigOptions, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitConfigOptions, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func TestServer_PostUploadPackSidechannel_gitConfigOptions(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitConfigOptions, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) +} + +func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...) testhelper.BuildGitalyHooks(t, cfg) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) want := "3dd08961455abf80ef9115f4afdc1c6f968b503c" // refs/heads/csv gittest.Exec(t, cfg, "-C", repoPath, "update-ref", "refs/hidden/csv", want) @@ -106,7 +133,7 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, t.Run("sanity check: ref exists and can be fetched", func(t *testing.T) { rpcRequest := &gitalypb.PostUploadPackRequest{Repository: repo} - response, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) + response, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) require.NoError(t, err) _, _, count := extractPackDataFromResponse(t, response) require.Equal(t, 5, count, "pack should have 5 entries") @@ -120,7 +147,7 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, "uploadpack.allowAnySHA1InWant=false", }, } - response, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) + response, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewReader(requestBody.Bytes())) testhelper.RequireGrpcError(t, err, codes.Unavailable) // The failure message proves that upload-pack failed because of @@ -131,13 +158,17 @@ func testServerPostUploadPackGitConfigOptions(t *testing.T, ctx context.Context, } func TestServer_PostUploadPack_gitProtocol(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitProtocol, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitProtocol, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) +} + +func TestServer_PostUploadPackWithSidechannel_gitProtocol(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackGitProtocol, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, _ := testcfg.BuildWithRepo(t, opts...) readProto, cfg := gittest.EnableGitProtocolV2Support(t, cfg) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) // command=ls-refs does not exist in protocol v0, so if this succeeds, we're talking v2 requestBody := &bytes.Buffer{} @@ -152,7 +183,7 @@ func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, opts GitProtocol: git.ProtocolV2, } - _, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, requestBody) + _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, requestBody) require.NoError(t, err) envData := readProto() @@ -163,12 +194,16 @@ func testServerPostUploadPackGitProtocol(t *testing.T, ctx context.Context, opts // on 'deepen' requests even though the request is being handled just // fine from the client perspective. func TestServer_PostUploadPack_suppressDeepenExitError(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackSuppressDeepenExitError, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackSuppressDeepenExitError, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func TestServer_PostUploadPackWithSidechannel_suppressDeepenExitError(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackSuppressDeepenExitError, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) +} + +func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, _ := testcfg.BuildWithRepo(t, opts...) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) requestBody := &bytes.Buffer{} gittest.WritePktlineString(t, requestBody, fmt.Sprintf("want e63f41fe459e62e1228fcef60d7189127aeba95a %s\n", clientCapabilities)) @@ -176,7 +211,7 @@ func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.C gittest.WritePktlineFlush(t, requestBody) rpcRequest := &gitalypb.PostUploadPackRequest{Repository: repo} - response, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, requestBody) + response, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, requestBody) // This assertion is the main reason this test exists. assert.NoError(t, err) @@ -184,6 +219,20 @@ func testServerPostUploadPackSuppressDeepenExitError(t *testing.T, ctx context.C } func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) { + ctx, cancel := testhelper.Context() + defer cancel() + + testServerPostUploadPackUsesPackObjectsHook(t, ctx, makePostUploadPackRequest, runSmartHTTPServer) +} + +func TestServer_PostUploadPackWithSidechannel_usesPackObjectsHook(t *testing.T) { + ctx, cancel := testhelper.Context() + defer cancel() + + testServerPostUploadPackUsesPackObjectsHook(t, ctx, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect) +} + +func testServerPostUploadPackUsesPackObjectsHook(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, repoPath := testcfg.BuildWithRepo(t, testcfg.WithPackObjectsCacheEnabled()) cfg.BinDir = testhelper.TempDir(t) @@ -199,7 +248,7 @@ func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) { // transferred back. testhelper.WriteExecutable(t, filepath.Join(cfg.BinDir, "gitaly-hooks"), []byte(hookScript)) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) oldHead := bytes.TrimSpace(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "master~")) newHead := bytes.TrimSpace(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "master")) @@ -210,10 +259,7 @@ func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) { gittest.WritePktlineString(t, requestBuffer, fmt.Sprintf("have %s\n", oldHead)) gittest.WritePktlineFlush(t, requestBuffer) - ctx, cancel := testhelper.Context() - defer cancel() - - _, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, &gitalypb.PostUploadPackRequest{ + _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, &gitalypb.PostUploadPackRequest{ Repository: repo, }, requestBuffer) require.NoError(t, err) @@ -223,12 +269,12 @@ func TestServer_PostUploadPack_usesPackObjectsHook(t *testing.T) { } func TestServer_PostUploadPack_validation(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackValidation, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackValidation, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUploadPackValidation(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func testServerPostUploadPackValidation(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg := testcfg.Build(t, opts...) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) rpcRequests := []*gitalypb.PostUploadPackRequest{ {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist @@ -238,39 +284,31 @@ func testServerPostUploadPackValidation(t *testing.T, ctx context.Context, opts for _, rpcRequest := range rpcRequests { t.Run(fmt.Sprintf("%v", rpcRequest), func(t *testing.T) { - _, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewBuffer(nil)) + _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewBuffer(nil)) testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) } } -func makePostUploadPackRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { - client, conn := newSmartHTTPClient(t, serverSocketPath, token) - defer conn.Close() +func TestServer_PostUploadPackSidechannel_validation(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackWithSideChannelValidation, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) +} - stream, err := client.PostUploadPack(ctx) - require.NoError(t, err) +func testServerPostUploadPackWithSideChannelValidation(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { + cfg := testcfg.Build(t, opts...) + serverSocketPath := runServer(t, cfg) - require.NoError(t, stream.Send(in)) + rpcRequests := []*gitalypb.PostUploadPackRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist + {Repository: nil}, // Repository is nil + } - if body != nil { - sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&gitalypb.PostUploadPackRequest{Data: p}) + for _, rpcRequest := range rpcRequests { + t.Run(fmt.Sprintf("%v", rpcRequest), func(t *testing.T) { + _, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest, bytes.NewBuffer(nil)) + testhelper.RequireGrpcError(t, err, codes.InvalidArgument) }) - - _, err = io.Copy(sw, body) - require.NoError(t, err) - require.NoError(t, stream.CloseSend()) } - - responseBuffer := &bytes.Buffer{} - rr := streamio.NewReader(func() ([]byte, error) { - resp, err := stream.Recv() - return resp.GetData(), err - }) - _, err = io.Copy(responseBuffer, rr) - - return responseBuffer, err } // The response contains bunch of things; metadata, progress messages, and a pack file. We're only @@ -313,16 +351,20 @@ func extractPackDataFromResponse(t *testing.T, buf *bytes.Buffer) ([]byte, int, } func TestServer_PostUploadPack_partialClone(t *testing.T) { - runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackPartialClone, testcfg.WithPackObjectsCacheEnabled()) + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackPartialClone, makePostUploadPackRequest, runSmartHTTPServer, testcfg.WithPackObjectsCacheEnabled()) } -func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, opts ...testcfg.Option) { +func TestServer_PostUploadPackWithSidechannel_partialClone(t *testing.T) { + runTestWithAndWithoutConfigOptions(t, testServerPostUploadPackPartialClone, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect, testcfg.WithPackObjectsCacheEnabled()) +} + +func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, repoPath := testcfg.BuildWithRepo(t, opts...) _, localRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0]) testhelper.BuildGitalyHooks(t, cfg) negotiationMetrics := prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"feature"}) - serverSocketPath := runSmartHTTPServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) + serverSocketPath := runServer(t, cfg, WithPackfileNegotiationMetrics(negotiationMetrics)) oldCommit, err := git.NewObjectIDFromHex("1e292f8fedd741b75372e19097c76d327140c312") // refs/heads/master require.NoError(t, err) @@ -336,7 +378,7 @@ func testServerPostUploadPackPartialClone(t *testing.T, ctx context.Context, opt gittest.WritePktlineFlush(t, &requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, &requestBuffer) + responseBuffer, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, &requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -363,11 +405,22 @@ func TestServer_PostUploadPack_allowAnySHA1InWant(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() + testServerPostUploadPackAllowAnySHA1InWant(t, ctx, makePostUploadPackRequest, runSmartHTTPServer) +} + +func TestServer_PostUploadPackWithSidechannel_allowAnySHA1InWant(t *testing.T) { + ctx, cancel := testhelper.Context() + defer cancel() + + testServerPostUploadPackAllowAnySHA1InWant(t, ctx, makePostUploadPackWithSidechannelRequest, runSmartHTTPServerWithoutPraefect) +} + +func testServerPostUploadPackAllowAnySHA1InWant(t *testing.T, ctx context.Context, makeRequest requestMaker, runServer serverRunner, opts ...testcfg.Option) { cfg, repo, repoPath := testcfg.BuildWithRepo(t) _, localRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0]) testhelper.BuildGitalyHooks(t, cfg) - serverSocketPath := runSmartHTTPServer(t, cfg) + serverSocketPath := runServer(t, cfg) newCommit := gittest.WriteCommit(t, cfg, repoPath) var requestBuffer bytes.Buffer @@ -377,7 +430,7 @@ func TestServer_PostUploadPack_allowAnySHA1InWant(t *testing.T) { gittest.WritePktlineFlush(t, &requestBuffer) req := &gitalypb.PostUploadPackRequest{Repository: repo} - responseBuffer, err := makePostUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, &requestBuffer) + responseBuffer, err := makeRequest(ctx, t, serverSocketPath, cfg.Auth.Token, req, &requestBuffer) require.NoError(t, err) pack, version, entries := extractPackDataFromResponse(t, responseBuffer) @@ -387,3 +440,95 @@ func TestServer_PostUploadPack_allowAnySHA1InWant(t *testing.T) { gittest.GitObjectMustExist(t, cfg.Git.BinPath, localRepoPath, newCommit.String()) } + +func makePostUploadPackRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { + client, conn := newSmartHTTPClient(t, serverSocketPath, token) + defer conn.Close() + + stream, err := client.PostUploadPack(ctx) + require.NoError(t, err) + + require.NoError(t, stream.Send(in)) + + if body != nil { + sw := streamio.NewWriter(func(p []byte) error { + return stream.Send(&gitalypb.PostUploadPackRequest{Data: p}) + }) + + _, err = io.Copy(sw, body) + require.NoError(t, err) + require.NoError(t, stream.CloseSend()) + } + + responseBuffer := &bytes.Buffer{} + rr := streamio.NewReader(func() ([]byte, error) { + resp, err := stream.Recv() + return resp.GetData(), err + }) + _, err = io.Copy(responseBuffer, rr) + + return responseBuffer, err +} + +func dialSmartHTTPServerWithSidechannel(t *testing.T, serverSocketPath, token string, registry *sidechannel.Registry) *grpc.ClientConn { + logger := logrus.NewEntry(logrus.New()) + + factory := func() backchannel.Server { + lm := listenmux.New(insecure.NewCredentials()) + lm.Register(sidechannel.NewServerHandshaker(registry)) + return grpc.NewServer(grpc.Creds(lm)) + } + clientHandshaker := backchannel.NewClientHandshaker(logger, factory) + connOpts := []grpc.DialOption{ + grpc.WithTransportCredentials(clientHandshaker.ClientHandshake(insecure.NewCredentials())), + grpc.WithPerRPCCredentials(gitalyauth.RPCCredentialsV2(token)), + } + + conn, err := grpc.Dial(serverSocketPath, connOpts...) + require.NoError(t, err) + + return conn +} + +func makePostUploadPackWithSidechannelRequest(ctx context.Context, t *testing.T, serverSocketPath, token string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { + t.Helper() + + registry := sidechannel.NewRegistry() + conn := dialSmartHTTPServerWithSidechannel(t, serverSocketPath, token, registry) + client := gitalypb.NewSmartHTTPServiceClient(conn) + defer testhelper.MustClose(t, conn) + + responseBuffer := &bytes.Buffer{} + ctxOut, waiter := sidechannel.RegisterSidechannel(ctx, registry, func(sideConn *sidechannel.ClientConn) error { + errC := make(chan error, 1) + go func() { + _, err := io.Copy(responseBuffer, sideConn) + errC <- err + }() + + if body != nil { + if _, err := io.Copy(sideConn, body); err != nil { + return err + } + } + + if err := sideConn.CloseWrite(); err != nil { + return err + } + + return <-errC + }) + defer testhelper.MustClose(t, waiter) + + rpcRequest := &gitalypb.PostUploadPackWithSidechannelRequest{ + Repository: in.GetRepository(), + GitConfigOptions: in.GetGitConfigOptions(), + GitProtocol: in.GetGitProtocol(), + } + _, err := client.PostUploadPackWithSidechannel(ctxOut, rpcRequest) + if err == nil { + require.NoError(t, waiter.Wait()) + } + + return responseBuffer, err +} diff --git a/proto/go/gitalypb/smarthttp.pb.go b/proto/go/gitalypb/smarthttp.pb.go index bbedd31b2..e7ec4a48a 100644 --- a/proto/go/gitalypb/smarthttp.pb.go +++ b/proto/go/gitalypb/smarthttp.pb.go @@ -255,6 +255,110 @@ func (x *PostUploadPackResponse) GetData() []byte { return nil } +type PostUploadPackWithSidechannelRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // repository should only be present in the first message of the stream + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + // Parameters to use with git -c (key=value pairs) + GitConfigOptions []string `protobuf:"bytes,2,rep,name=git_config_options,json=gitConfigOptions,proto3" json:"git_config_options,omitempty"` + // Git protocol version + GitProtocol string `protobuf:"bytes,3,opt,name=git_protocol,json=gitProtocol,proto3" json:"git_protocol,omitempty"` +} + +func (x *PostUploadPackWithSidechannelRequest) Reset() { + *x = PostUploadPackWithSidechannelRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_smarthttp_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PostUploadPackWithSidechannelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PostUploadPackWithSidechannelRequest) ProtoMessage() {} + +func (x *PostUploadPackWithSidechannelRequest) ProtoReflect() protoreflect.Message { + mi := &file_smarthttp_proto_msgTypes[4] + 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 PostUploadPackWithSidechannelRequest.ProtoReflect.Descriptor instead. +func (*PostUploadPackWithSidechannelRequest) Descriptor() ([]byte, []int) { + return file_smarthttp_proto_rawDescGZIP(), []int{4} +} + +func (x *PostUploadPackWithSidechannelRequest) GetRepository() *Repository { + if x != nil { + return x.Repository + } + return nil +} + +func (x *PostUploadPackWithSidechannelRequest) GetGitConfigOptions() []string { + if x != nil { + return x.GitConfigOptions + } + return nil +} + +func (x *PostUploadPackWithSidechannelRequest) GetGitProtocol() string { + if x != nil { + return x.GitProtocol + } + return "" +} + +type PostUploadPackWithSidechannelResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PostUploadPackWithSidechannelResponse) Reset() { + *x = PostUploadPackWithSidechannelResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_smarthttp_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PostUploadPackWithSidechannelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PostUploadPackWithSidechannelResponse) ProtoMessage() {} + +func (x *PostUploadPackWithSidechannelResponse) ProtoReflect() protoreflect.Message { + mi := &file_smarthttp_proto_msgTypes[5] + 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 PostUploadPackWithSidechannelResponse.ProtoReflect.Descriptor instead. +func (*PostUploadPackWithSidechannelResponse) Descriptor() ([]byte, []int) { + return file_smarthttp_proto_rawDescGZIP(), []int{5} +} + type PostReceivePackRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -278,7 +382,7 @@ type PostReceivePackRequest struct { func (x *PostReceivePackRequest) Reset() { *x = PostReceivePackRequest{} if protoimpl.UnsafeEnabled { - mi := &file_smarthttp_proto_msgTypes[4] + mi := &file_smarthttp_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -291,7 +395,7 @@ func (x *PostReceivePackRequest) String() string { func (*PostReceivePackRequest) ProtoMessage() {} func (x *PostReceivePackRequest) ProtoReflect() protoreflect.Message { - mi := &file_smarthttp_proto_msgTypes[4] + mi := &file_smarthttp_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -304,7 +408,7 @@ func (x *PostReceivePackRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PostReceivePackRequest.ProtoReflect.Descriptor instead. func (*PostReceivePackRequest) Descriptor() ([]byte, []int) { - return file_smarthttp_proto_rawDescGZIP(), []int{4} + return file_smarthttp_proto_rawDescGZIP(), []int{6} } func (x *PostReceivePackRequest) GetRepository() *Repository { @@ -368,7 +472,7 @@ type PostReceivePackResponse struct { func (x *PostReceivePackResponse) Reset() { *x = PostReceivePackResponse{} if protoimpl.UnsafeEnabled { - mi := &file_smarthttp_proto_msgTypes[5] + mi := &file_smarthttp_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -381,7 +485,7 @@ func (x *PostReceivePackResponse) String() string { func (*PostReceivePackResponse) ProtoMessage() {} func (x *PostReceivePackResponse) ProtoReflect() protoreflect.Message { - mi := &file_smarthttp_proto_msgTypes[5] + mi := &file_smarthttp_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -394,7 +498,7 @@ func (x *PostReceivePackResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PostReceivePackResponse.ProtoReflect.Descriptor instead. func (*PostReceivePackResponse) Descriptor() ([]byte, []int) { - return file_smarthttp_proto_rawDescGZIP(), []int{5} + return file_smarthttp_proto_rawDescGZIP(), []int{7} } func (x *PostReceivePackResponse) GetData() []byte { @@ -437,54 +541,76 @@ var file_smarthttp_proto_rawDesc = []byte{ 0x63, 0x6f, 0x6c, 0x22, 0x2c, 0x0a, 0x16, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x22, 0x92, 0x02, 0x0a, 0x16, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0a, - 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x13, 0x0a, 0x05, 0x67, 0x6c, - 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x67, 0x6c, 0x49, 0x64, 0x12, - 0x23, 0x0a, 0x0d, 0x67, 0x6c, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x67, 0x6c, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x67, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x67, 0x6c, 0x55, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x2d, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xf6, 0x02, 0x0a, 0x10, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x48, - 0x54, 0x54, 0x50, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x12, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, - 0x12, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, - 0x6c, 0x79, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x52, 0x0a, - 0x13, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x50, 0x61, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, + 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x24, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x50, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, + 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0a, 0x72, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x27, 0x0a, 0x25, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, + 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x92, + 0x02, 0x0a, 0x16, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0a, 0x72, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, + 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x13, 0x0a, 0x05, 0x67, 0x6c, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x67, 0x6c, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, + 0x67, 0x6c, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x67, 0x6c, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, + 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x67, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x67, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x67, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x67, 0x69, 0x74, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x22, 0x2d, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x32, 0xfd, 0x03, 0x0a, 0x10, 0x53, 0x6d, 0x61, 0x72, 0x74, 0x48, 0x54, 0x54, 0x50, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x12, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x65, 0x66, 0x73, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, - 0x01, 0x12, 0x5b, 0x0a, 0x0e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, - 0x61, 0x63, 0x6b, 0x12, 0x1d, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12, 0x5e, - 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, - 0x6b, 0x12, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x52, - 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x52, - 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x01, 0x28, 0x01, 0x30, 0x01, 0x42, 0x34, - 0x5a, 0x32, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, - 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2f, 0x76, - 0x31, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x61, - 0x6c, 0x79, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x52, 0x0a, 0x13, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, + 0x6b, 0x12, 0x17, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x65, 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x69, 0x74, + 0x61, 0x6c, 0x79, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x5b, + 0x0a, 0x0e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, + 0x12, 0x1d, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, + 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x28, 0x01, 0x30, 0x01, 0x12, 0x84, 0x01, 0x0a, 0x1d, + 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x57, 0x69, + 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x2c, 0x2e, + 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x50, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, + 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x67, 0x69, + 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, + 0x61, 0x63, 0x6b, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x64, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x6e, + 0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, + 0x08, 0x02, 0x12, 0x5e, 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x1e, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, + 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x50, + 0x6f, 0x73, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x01, 0x28, 0x01, + 0x30, 0x01, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x69, 0x74, 0x61, + 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, + 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -499,33 +625,38 @@ func file_smarthttp_proto_rawDescGZIP() []byte { return file_smarthttp_proto_rawDescData } -var file_smarthttp_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_smarthttp_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_smarthttp_proto_goTypes = []interface{}{ - (*InfoRefsRequest)(nil), // 0: gitaly.InfoRefsRequest - (*InfoRefsResponse)(nil), // 1: gitaly.InfoRefsResponse - (*PostUploadPackRequest)(nil), // 2: gitaly.PostUploadPackRequest - (*PostUploadPackResponse)(nil), // 3: gitaly.PostUploadPackResponse - (*PostReceivePackRequest)(nil), // 4: gitaly.PostReceivePackRequest - (*PostReceivePackResponse)(nil), // 5: gitaly.PostReceivePackResponse - (*Repository)(nil), // 6: gitaly.Repository + (*InfoRefsRequest)(nil), // 0: gitaly.InfoRefsRequest + (*InfoRefsResponse)(nil), // 1: gitaly.InfoRefsResponse + (*PostUploadPackRequest)(nil), // 2: gitaly.PostUploadPackRequest + (*PostUploadPackResponse)(nil), // 3: gitaly.PostUploadPackResponse + (*PostUploadPackWithSidechannelRequest)(nil), // 4: gitaly.PostUploadPackWithSidechannelRequest + (*PostUploadPackWithSidechannelResponse)(nil), // 5: gitaly.PostUploadPackWithSidechannelResponse + (*PostReceivePackRequest)(nil), // 6: gitaly.PostReceivePackRequest + (*PostReceivePackResponse)(nil), // 7: gitaly.PostReceivePackResponse + (*Repository)(nil), // 8: gitaly.Repository } var file_smarthttp_proto_depIdxs = []int32{ - 6, // 0: gitaly.InfoRefsRequest.repository:type_name -> gitaly.Repository - 6, // 1: gitaly.PostUploadPackRequest.repository:type_name -> gitaly.Repository - 6, // 2: gitaly.PostReceivePackRequest.repository:type_name -> gitaly.Repository - 0, // 3: gitaly.SmartHTTPService.InfoRefsUploadPack:input_type -> gitaly.InfoRefsRequest - 0, // 4: gitaly.SmartHTTPService.InfoRefsReceivePack:input_type -> gitaly.InfoRefsRequest - 2, // 5: gitaly.SmartHTTPService.PostUploadPack:input_type -> gitaly.PostUploadPackRequest - 4, // 6: gitaly.SmartHTTPService.PostReceivePack:input_type -> gitaly.PostReceivePackRequest - 1, // 7: gitaly.SmartHTTPService.InfoRefsUploadPack:output_type -> gitaly.InfoRefsResponse - 1, // 8: gitaly.SmartHTTPService.InfoRefsReceivePack:output_type -> gitaly.InfoRefsResponse - 3, // 9: gitaly.SmartHTTPService.PostUploadPack:output_type -> gitaly.PostUploadPackResponse - 5, // 10: gitaly.SmartHTTPService.PostReceivePack:output_type -> gitaly.PostReceivePackResponse - 7, // [7:11] is the sub-list for method output_type - 3, // [3:7] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 0: gitaly.InfoRefsRequest.repository:type_name -> gitaly.Repository + 8, // 1: gitaly.PostUploadPackRequest.repository:type_name -> gitaly.Repository + 8, // 2: gitaly.PostUploadPackWithSidechannelRequest.repository:type_name -> gitaly.Repository + 8, // 3: gitaly.PostReceivePackRequest.repository:type_name -> gitaly.Repository + 0, // 4: gitaly.SmartHTTPService.InfoRefsUploadPack:input_type -> gitaly.InfoRefsRequest + 0, // 5: gitaly.SmartHTTPService.InfoRefsReceivePack:input_type -> gitaly.InfoRefsRequest + 2, // 6: gitaly.SmartHTTPService.PostUploadPack:input_type -> gitaly.PostUploadPackRequest + 4, // 7: gitaly.SmartHTTPService.PostUploadPackWithSidechannel:input_type -> gitaly.PostUploadPackWithSidechannelRequest + 6, // 8: gitaly.SmartHTTPService.PostReceivePack:input_type -> gitaly.PostReceivePackRequest + 1, // 9: gitaly.SmartHTTPService.InfoRefsUploadPack:output_type -> gitaly.InfoRefsResponse + 1, // 10: gitaly.SmartHTTPService.InfoRefsReceivePack:output_type -> gitaly.InfoRefsResponse + 3, // 11: gitaly.SmartHTTPService.PostUploadPack:output_type -> gitaly.PostUploadPackResponse + 5, // 12: gitaly.SmartHTTPService.PostUploadPackWithSidechannel:output_type -> gitaly.PostUploadPackWithSidechannelResponse + 7, // 13: gitaly.SmartHTTPService.PostReceivePack:output_type -> gitaly.PostReceivePackResponse + 9, // [9:14] is the sub-list for method output_type + 4, // [4:9] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_smarthttp_proto_init() } @@ -585,7 +716,7 @@ func file_smarthttp_proto_init() { } } file_smarthttp_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PostReceivePackRequest); i { + switch v := v.(*PostUploadPackWithSidechannelRequest); i { case 0: return &v.state case 1: @@ -597,6 +728,30 @@ func file_smarthttp_proto_init() { } } file_smarthttp_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PostUploadPackWithSidechannelResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_smarthttp_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PostReceivePackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_smarthttp_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PostReceivePackResponse); i { case 0: return &v.state @@ -615,7 +770,7 @@ func file_smarthttp_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_smarthttp_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/go/gitalypb/smarthttp_grpc.pb.go b/proto/go/gitalypb/smarthttp_grpc.pb.go index da3528e32..523303520 100644 --- a/proto/go/gitalypb/smarthttp_grpc.pb.go +++ b/proto/go/gitalypb/smarthttp_grpc.pb.go @@ -28,6 +28,8 @@ type SmartHTTPServiceClient interface { InfoRefsReceivePack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (SmartHTTPService_InfoRefsReceivePackClient, error) // Request and response body for POST /upload-pack PostUploadPack(ctx context.Context, opts ...grpc.CallOption) (SmartHTTPService_PostUploadPackClient, error) + // Request and response body for POST /upload-pack using sidechannel protocol + PostUploadPackWithSidechannel(ctx context.Context, in *PostUploadPackWithSidechannelRequest, opts ...grpc.CallOption) (*PostUploadPackWithSidechannelResponse, error) // Request and response body for POST /receive-pack PostReceivePack(ctx context.Context, opts ...grpc.CallOption) (SmartHTTPService_PostReceivePackClient, error) } @@ -135,6 +137,15 @@ func (x *smartHTTPServicePostUploadPackClient) Recv() (*PostUploadPackResponse, return m, nil } +func (c *smartHTTPServiceClient) PostUploadPackWithSidechannel(ctx context.Context, in *PostUploadPackWithSidechannelRequest, opts ...grpc.CallOption) (*PostUploadPackWithSidechannelResponse, error) { + out := new(PostUploadPackWithSidechannelResponse) + err := c.cc.Invoke(ctx, "/gitaly.SmartHTTPService/PostUploadPackWithSidechannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *smartHTTPServiceClient) PostReceivePack(ctx context.Context, opts ...grpc.CallOption) (SmartHTTPService_PostReceivePackClient, error) { stream, err := c.cc.NewStream(ctx, &SmartHTTPService_ServiceDesc.Streams[3], "/gitaly.SmartHTTPService/PostReceivePack", opts...) if err != nil { @@ -180,6 +191,8 @@ type SmartHTTPServiceServer interface { InfoRefsReceivePack(*InfoRefsRequest, SmartHTTPService_InfoRefsReceivePackServer) error // Request and response body for POST /upload-pack PostUploadPack(SmartHTTPService_PostUploadPackServer) error + // Request and response body for POST /upload-pack using sidechannel protocol + PostUploadPackWithSidechannel(context.Context, *PostUploadPackWithSidechannelRequest) (*PostUploadPackWithSidechannelResponse, error) // Request and response body for POST /receive-pack PostReceivePack(SmartHTTPService_PostReceivePackServer) error mustEmbedUnimplementedSmartHTTPServiceServer() @@ -198,6 +211,9 @@ func (UnimplementedSmartHTTPServiceServer) InfoRefsReceivePack(*InfoRefsRequest, func (UnimplementedSmartHTTPServiceServer) PostUploadPack(SmartHTTPService_PostUploadPackServer) error { return status.Errorf(codes.Unimplemented, "method PostUploadPack not implemented") } +func (UnimplementedSmartHTTPServiceServer) PostUploadPackWithSidechannel(context.Context, *PostUploadPackWithSidechannelRequest) (*PostUploadPackWithSidechannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PostUploadPackWithSidechannel not implemented") +} func (UnimplementedSmartHTTPServiceServer) PostReceivePack(SmartHTTPService_PostReceivePackServer) error { return status.Errorf(codes.Unimplemented, "method PostReceivePack not implemented") } @@ -282,6 +298,24 @@ func (x *smartHTTPServicePostUploadPackServer) Recv() (*PostUploadPackRequest, e return m, nil } +func _SmartHTTPService_PostUploadPackWithSidechannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PostUploadPackWithSidechannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SmartHTTPServiceServer).PostUploadPackWithSidechannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitaly.SmartHTTPService/PostUploadPackWithSidechannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SmartHTTPServiceServer).PostUploadPackWithSidechannel(ctx, req.(*PostUploadPackWithSidechannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SmartHTTPService_PostReceivePack_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(SmartHTTPServiceServer).PostReceivePack(&smartHTTPServicePostReceivePackServer{stream}) } @@ -314,7 +348,12 @@ func (x *smartHTTPServicePostReceivePackServer) Recv() (*PostReceivePackRequest, var SmartHTTPService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "gitaly.SmartHTTPService", HandlerType: (*SmartHTTPServiceServer)(nil), - Methods: []grpc.MethodDesc{}, + Methods: []grpc.MethodDesc{ + { + MethodName: "PostUploadPackWithSidechannel", + Handler: _SmartHTTPService_PostUploadPackWithSidechannel_Handler, + }, + }, Streams: []grpc.StreamDesc{ { StreamName: "InfoRefsUploadPack", diff --git a/proto/smarthttp.proto b/proto/smarthttp.proto index 26d057685..f9e3977d6 100644 --- a/proto/smarthttp.proto +++ b/proto/smarthttp.proto @@ -33,6 +33,13 @@ service SmartHTTPService { }; } + // Request and response body for POST /upload-pack using sidechannel protocol + rpc PostUploadPackWithSidechannel(PostUploadPackWithSidechannelRequest) returns (PostUploadPackWithSidechannelResponse) { + option (op_type) = { + op: ACCESSOR + }; + } + // Request and response body for POST /receive-pack rpc PostReceivePack(stream PostReceivePackRequest) returns (stream PostReceivePackResponse) { option (op_type) = { @@ -71,6 +78,17 @@ message PostUploadPackResponse { bytes data = 1; } +message PostUploadPackWithSidechannelRequest { + // repository should only be present in the first message of the stream + Repository repository = 1 [(target_repository)=true]; + // Parameters to use with git -c (key=value pairs) + repeated string git_config_options = 2; + // Git protocol version + string git_protocol = 3; +} + +message PostUploadPackWithSidechannelResponse { } + message PostReceivePackRequest { // repository should only be present in the first message of the stream Repository repository = 1 [(target_repository)=true]; diff --git a/ruby/proto/gitaly/smarthttp_pb.rb b/ruby/proto/gitaly/smarthttp_pb.rb index 6d4877f32..3bec5ac26 100644 --- a/ruby/proto/gitaly/smarthttp_pb.rb +++ b/ruby/proto/gitaly/smarthttp_pb.rb @@ -24,6 +24,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "gitaly.PostUploadPackResponse" do optional :data, :bytes, 1 end + add_message "gitaly.PostUploadPackWithSidechannelRequest" do + optional :repository, :message, 1, "gitaly.Repository" + repeated :git_config_options, :string, 2 + optional :git_protocol, :string, 3 + end + add_message "gitaly.PostUploadPackWithSidechannelResponse" do + end add_message "gitaly.PostReceivePackRequest" do optional :repository, :message, 1, "gitaly.Repository" optional :data, :bytes, 2 @@ -44,6 +51,8 @@ module Gitaly InfoRefsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.InfoRefsResponse").msgclass PostUploadPackRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostUploadPackRequest").msgclass PostUploadPackResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostUploadPackResponse").msgclass + PostUploadPackWithSidechannelRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostUploadPackWithSidechannelRequest").msgclass + PostUploadPackWithSidechannelResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostUploadPackWithSidechannelResponse").msgclass PostReceivePackRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceivePackRequest").msgclass PostReceivePackResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceivePackResponse").msgclass end diff --git a/ruby/proto/gitaly/smarthttp_services_pb.rb b/ruby/proto/gitaly/smarthttp_services_pb.rb index 11a6e87b1..4b315d6b3 100644 --- a/ruby/proto/gitaly/smarthttp_services_pb.rb +++ b/ruby/proto/gitaly/smarthttp_services_pb.rb @@ -24,6 +24,8 @@ module Gitaly rpc :InfoRefsReceivePack, Gitaly::InfoRefsRequest, stream(Gitaly::InfoRefsResponse) # Request and response body for POST /upload-pack rpc :PostUploadPack, stream(Gitaly::PostUploadPackRequest), stream(Gitaly::PostUploadPackResponse) + # Request and response body for POST /upload-pack using sidechannel protocol + rpc :PostUploadPackWithSidechannel, Gitaly::PostUploadPackWithSidechannelRequest, Gitaly::PostUploadPackWithSidechannelResponse # Request and response body for POST /receive-pack rpc :PostReceivePack, stream(Gitaly::PostReceivePackRequest), stream(Gitaly::PostReceivePackResponse) end |