diff options
author | Igor <idrozdov@gitlab.com> | 2019-06-03 15:21:25 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-03 15:21:25 +0000 |
commit | cde5b73cb8776c70c6d00ff34c568ea4438bcba9 (patch) | |
tree | ddc0d81da81ebfdb2c05819c88cde2c56dbaf4d5 /go/internal/gitlabnet | |
parent | beb5855542645cdc9bf7f954b9c5a9333dfb3975 (diff) | |
download | gitlab-shell-cde5b73cb8776c70c6d00ff34c568ea4438bcba9.tar.gz |
Go implementation for git-upload-pack
Diffstat (limited to 'go/internal/gitlabnet')
-rw-r--r-- | go/internal/gitlabnet/accessverifier/client.go | 16 | ||||
-rw-r--r-- | go/internal/gitlabnet/accessverifier/client_test.go | 7 | ||||
-rw-r--r-- | go/internal/gitlabnet/testserver/gitalyserver.go | 9 |
3 files changed, 16 insertions, 16 deletions
diff --git a/go/internal/gitlabnet/accessverifier/client.go b/go/internal/gitlabnet/accessverifier/client.go index ebe8545..d87c4ad 100644 --- a/go/internal/gitlabnet/accessverifier/client.go +++ b/go/internal/gitlabnet/accessverifier/client.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + pb "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/go/internal/config" "gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet" @@ -27,19 +28,10 @@ type Request struct { Username string `json:"username,omitempty"` } -type GitalyRepo struct { - StorageName string `json:"storage_name"` - RelativePath string `json:"relative_path"` - GitObjectDirectory string `json:"git_object_directory"` - GitAlternateObjectDirectories []string `json:"git_alternate_object_directories"` - RepoName string `json:"gl_repository"` - ProjectPath string `json:"gl_project_path"` -} - type Gitaly struct { - Repo GitalyRepo `json:"repository"` - Address string `json:"address"` - Token string `json:"token"` + Repo pb.Repository `json:"repository"` + Address string `json:"address"` + Token string `json:"token"` } type CustomPayloadData struct { diff --git a/go/internal/gitlabnet/accessverifier/client_test.go b/go/internal/gitlabnet/accessverifier/client_test.go index a759919..31175ae 100644 --- a/go/internal/gitlabnet/accessverifier/client_test.go +++ b/go/internal/gitlabnet/accessverifier/client_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" + pb "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/go/internal/config" "gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet" @@ -29,13 +30,13 @@ func buildExpectedResponse(who string) *Response { Username: "root", GitConfigOptions: []string{"option"}, Gitaly: Gitaly{ - Repo: GitalyRepo{ + Repo: pb.Repository{ StorageName: "default", RelativePath: "@hashed/5f/9c/5f9c4ab08cac7457e9111a30e4664920607ea2c115a1433d7be98e97e64244ca.git", GitObjectDirectory: "path/to/git_object_directory", GitAlternateObjectDirectories: []string{"path/to/git_alternate_object_directory"}, - RepoName: "project-26", - ProjectPath: repo, + GlRepository: "project-26", + GlProjectPath: repo, }, Address: "unix:gitaly.socket", Token: "token", diff --git a/go/internal/gitlabnet/testserver/gitalyserver.go b/go/internal/gitlabnet/testserver/gitalyserver.go index 141a518..a31dfe2 100644 --- a/go/internal/gitlabnet/testserver/gitalyserver.go +++ b/go/internal/gitlabnet/testserver/gitalyserver.go @@ -18,7 +18,6 @@ type testGitalyServer struct{} func (s *testGitalyServer) SSHReceivePack(stream pb.SSHService_SSHReceivePackServer) error { req, err := stream.Recv() - if err != nil { return err } @@ -30,6 +29,14 @@ func (s *testGitalyServer) SSHReceivePack(stream pb.SSHService_SSHReceivePackSer } func (s *testGitalyServer) SSHUploadPack(stream pb.SSHService_SSHUploadPackServer) error { + req, err := stream.Recv() + if err != nil { + return err + } + + response := []byte("UploadPack: " + req.Repository.GlRepository) + stream.Send(&pb.SSHUploadPackResponse{Stdout: response}) + return nil } |