Commit 61d6c6dc authored by Kim "BKC" Carlbäcker's avatar Kim "BKC" Carlbäcker

Update vendoring for gitaly

parent 5f1ab210
v5.4.0
- Update Gitaly vendoring to use new RPC calls instead of old deprecated ones
v5.3.1 v5.3.1
- Gracefully handle internal API errors when getting merge request URLs - Gracefully handle internal API errors when getting merge request URLs
......
...@@ -19,6 +19,8 @@ It is generated from these files: ...@@ -19,6 +19,8 @@ It is generated from these files:
It has these top-level messages: It has these top-level messages:
GetBlobRequest GetBlobRequest
GetBlobResponse GetBlobResponse
CommitStatsRequest
CommitStatsResponse
CommitIsAncestorRequest CommitIsAncestorRequest
CommitIsAncestorResponse CommitIsAncestorResponse
TreeEntryRequest TreeEntryRequest
...@@ -27,6 +29,13 @@ It has these top-level messages: ...@@ -27,6 +29,13 @@ It has these top-level messages:
CommitsBetweenResponse CommitsBetweenResponse
CountCommitsRequest CountCommitsRequest
CountCommitsResponse CountCommitsResponse
TreeEntry
GetTreeEntriesRequest
GetTreeEntriesResponse
ListFilesRequest
ListFilesResponse
FindCommitRequest
FindCommitResponse
CommitDiffRequest CommitDiffRequest
CommitDiffResponse CommitDiffResponse
CommitDeltaRequest CommitDeltaRequest
...@@ -48,6 +57,12 @@ It has these top-level messages: ...@@ -48,6 +57,12 @@ It has these top-level messages:
FindLocalBranchCommitAuthor FindLocalBranchCommitAuthor
RepositoryExistsRequest RepositoryExistsRequest
RepositoryExistsResponse RepositoryExistsResponse
RepackIncrementalRequest
RepackIncrementalResponse
RepackFullRequest
RepackFullResponse
GarbageCollectRequest
GarbageCollectResponse
Repository Repository
GitCommit GitCommit
CommitAuthor CommitAuthor
......
package helper
import (
"io"
pb "gitlab.com/gitlab-org/gitaly-proto/go"
)
type InfoRefsClient interface {
Recv() (*pb.InfoRefsResponse, error)
}
type InfoRefsClientWriterTo struct {
InfoRefsClient
}
func (clientReader *InfoRefsClientWriterTo) WriteTo(w io.Writer) (total int64, err error) {
for {
response, err := clientReader.Recv()
if err == io.EOF {
return total, nil
} else if err != nil {
return total, err
}
n, err := w.Write(response.GetData())
total += int64(n)
if err != nil {
return total, err
}
}
}
package helper
import (
"io"
)
// NewReceiveReader turns receiver into an io.Reader. Errors from the
// receiver function are passed on unmodified. This means receiver should
// emit io.EOF when done.
func NewReceiveReader(receiver func() ([]byte, error)) io.Reader {
return &receiveReader{receiver: receiver}
}
type receiveReader struct {
receiver func() ([]byte, error)
data []byte
err error
}
func (rr *receiveReader) Read(p []byte) (int, error) {
if len(rr.data) == 0 {
rr.data, rr.err = rr.receiver()
}
n := copy(p, rr.data)
rr.data = rr.data[n:]
if len(rr.data) == 0 {
return n, rr.err
}
return n, nil
}
// NewSendWriter turns sender into an io.Writer. The number of 'bytes
// written' reported back is always len(p).
func NewSendWriter(sender func(p []byte) error) io.Writer {
return &sendWriter{sender: sender}
}
type sendWriter struct {
sender func([]byte) error
}
func (sw *sendWriter) Write(p []byte) (int, error) {
return len(p), sw.sender(p)
}
...@@ -3,12 +3,12 @@ package client ...@@ -3,12 +3,12 @@ package client
import ( import (
"io" "io"
"google.golang.org/grpc" "gitlab.com/gitlab-org/gitaly/streamio"
"golang.org/x/net/context"
pb "gitlab.com/gitlab-org/gitaly-proto/go" pb "gitlab.com/gitlab-org/gitaly-proto/go"
pbhelper "gitlab.com/gitlab-org/gitaly-proto/go/helper"
"golang.org/x/net/context"
"google.golang.org/grpc"
) )
// ReceivePack proxies an SSH git-receive-pack (git push) session to Gitaly // ReceivePack proxies an SSH git-receive-pack (git push) session to Gitaly
...@@ -16,7 +16,7 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st ...@@ -16,7 +16,7 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st
ctx2, cancel := context.WithCancel(ctx) ctx2, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
ssh := pb.NewSSHClient(conn) ssh := pb.NewSSHServiceClient(conn)
stream, err := ssh.SSHReceivePack(ctx2) stream, err := ssh.SSHReceivePack(ctx2)
if err != nil { if err != nil {
return 0, err return 0, err
...@@ -26,7 +26,7 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st ...@@ -26,7 +26,7 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st
return 0, err return 0, err
} }
inWriter := pbhelper.NewSendWriter(func(p []byte) error { inWriter := streamio.NewWriter(func(p []byte) error {
return stream.Send(&pb.SSHReceivePackRequest{Stdin: p}) return stream.Send(&pb.SSHReceivePackRequest{Stdin: p})
}) })
......
...@@ -3,12 +3,12 @@ package client ...@@ -3,12 +3,12 @@ package client
import ( import (
"io" "io"
"google.golang.org/grpc" "gitlab.com/gitlab-org/gitaly/streamio"
"golang.org/x/net/context"
pb "gitlab.com/gitlab-org/gitaly-proto/go" pb "gitlab.com/gitlab-org/gitaly-proto/go"
pbhelper "gitlab.com/gitlab-org/gitaly-proto/go/helper"
"golang.org/x/net/context"
"google.golang.org/grpc"
) )
// UploadPack proxies an SSH git-upload-pack (git fetch) session to Gitaly // UploadPack proxies an SSH git-upload-pack (git fetch) session to Gitaly
...@@ -16,7 +16,7 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std ...@@ -16,7 +16,7 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std
ctx2, cancel := context.WithCancel(ctx) ctx2, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
ssh := pb.NewSSHClient(conn) ssh := pb.NewSSHServiceClient(conn)
stream, err := ssh.SSHUploadPack(ctx2) stream, err := ssh.SSHUploadPack(ctx2)
if err != nil { if err != nil {
return 0, err return 0, err
...@@ -26,7 +26,7 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std ...@@ -26,7 +26,7 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std
return 0, err return 0, err
} }
inWriter := pbhelper.NewSendWriter(func(p []byte) error { inWriter := streamio.NewWriter(func(p []byte) error {
return stream.Send(&pb.SSHUploadPackRequest{Stdin: p}) return stream.Send(&pb.SSHUploadPackRequest{Stdin: p})
}) })
......
// Package streamio contains wrappers intended for turning gRPC streams
// that send/receive messages with a []byte field into io.Writers and
// io.Readers.
//
package streamio
import (
"io"
"os"
"strconv"
)
func init() {
bufSize64, err := strconv.ParseInt(os.Getenv("GITALY_STREAMIO_WRITE_BUFFER_SIZE"), 10, 32)
if err == nil && bufSize64 > 0 {
WriteBufferSize = int(bufSize64)
}
}
// NewReader turns receiver into an io.Reader. Errors from the receiver
// function are passed on unmodified. This means receiver should emit
// io.EOF when done.
func NewReader(receiver func() ([]byte, error)) io.Reader {
return &receiveReader{receiver: receiver}
}
type receiveReader struct {
receiver func() ([]byte, error)
data []byte
err error
}
func (rr *receiveReader) Read(p []byte) (int, error) {
if len(rr.data) == 0 {
rr.data, rr.err = rr.receiver()
}
n := copy(p, rr.data)
rr.data = rr.data[n:]
if len(rr.data) == 0 {
return n, rr.err
}
return n, nil
}
// WriteTo implements io.WriterTo.
func (rr *receiveReader) WriteTo(w io.Writer) (int64, error) {
var written int64
// Deal with left-over state in rr.data and rr.err, if any
if len(rr.data) > 0 {
n, err := w.Write(rr.data)
written += int64(n)
if err != nil {
return written, err
}
}
if rr.err != nil {
return written, rr.err
}
// Consume the response stream
var errRead, errWrite error
var n int
var buf []byte
for errWrite == nil && errRead != io.EOF {
buf, errRead = rr.receiver()
if errRead != nil && errRead != io.EOF {
return written, errRead
}
if len(buf) > 0 {
n, errWrite = w.Write(buf)
written += int64(n)
}
}
return written, errWrite
}
// NewWriter turns sender into an io.Writer. The sender callback will
// receive []byte arguments of length at most WriteBufferSize.
func NewWriter(sender func(p []byte) error) io.Writer {
return &sendWriter{sender: sender}
}
// WriteBufferSize is the largest []byte that Write() will pass to its
// underlying send function. This value can be changed at runtime using
// the GITALY_STREAMIO_WRITE_BUFFER_SIZE environment variable.
var WriteBufferSize = 128 * 1024
type sendWriter struct {
sender func([]byte) error
}
func (sw *sendWriter) Write(p []byte) (int, error) {
var sent int
for len(p) > 0 {
chunkSize := len(p)
if chunkSize > WriteBufferSize {
chunkSize = WriteBufferSize
}
if err := sw.sender(p[:chunkSize]); err != nil {
return sent, err
}
sent += chunkSize
p = p[chunkSize:]
}
return sent, nil
}
// ReadFrom implements io.ReaderFrom.
func (sw *sendWriter) ReadFrom(r io.Reader) (int64, error) {
var nRead int64
buf := make([]byte, WriteBufferSize)
var errRead, errSend error
for errSend == nil && errRead != io.EOF {
var n int
n, errRead = r.Read(buf)
nRead += int64(n)
if errRead != nil && errRead != io.EOF {
return nRead, errRead
}
if n > 0 {
errSend = sw.sender(buf[:n])
}
}
return nRead, errSend
}
...@@ -21,29 +21,37 @@ ...@@ -21,29 +21,37 @@
"revisionTime": "2017-03-31T03:19:02Z" "revisionTime": "2017-03-31T03:19:02Z"
}, },
{ {
"checksumSHA1": "FPNHA80Wu9QTcNcjbuw0kdLOg5Q=", "checksumSHA1": "dTfc2UncJV8JxRznLbc0itGp8SI=",
"path": "gitlab.com/gitlab-org/gitaly-proto/go", "path": "gitlab.com/gitlab-org/gitaly-proto/go",
"revision": "e73c809c669748d0f49e257a249c4c12b59f7968", "revision": "c7790557c271c6e082c9e7cfa9e63380a7643dcf",
"revisionTime": "2017-07-07T12:10:40Z", "revisionTime": "2017-07-14T18:05:40Z",
"tree": true, "tree": true,
"version": "v0.14.0", "version": "v0.17.0",
"versionExact": "v0.14.0" "versionExact": "v0.17.0"
}, },
{ {
"checksumSHA1": "dUHJbKas746n5fLzlwxHb6FOCxs=", "checksumSHA1": "dUHJbKas746n5fLzlwxHb6FOCxs=",
"path": "gitlab.com/gitlab-org/gitaly/auth", "path": "gitlab.com/gitlab-org/gitaly/auth",
"revision": "e4f8d3d14cc3fe673cb511fb4d0189b68a158ccd", "revision": "421641a7cd5a5d7edd8008a8089acbe9335b7f3d",
"revisionTime": "2017-06-30T12:58:40Z", "revisionTime": "2017-07-18T12:50:12Z",
"version": "v0.14.0", "version": "v0.21.2",
"versionExact": "v0.14.0" "versionExact": "v0.21.2"
}, },
{ {
"checksumSHA1": "Z/BteCm3WErBI8bBmSN9gD+3EbU=", "checksumSHA1": "qlzYmQ21XX/voiKWHDWUZ3lybGQ=",
"path": "gitlab.com/gitlab-org/gitaly/client", "path": "gitlab.com/gitlab-org/gitaly/client",
"revision": "e4f8d3d14cc3fe673cb511fb4d0189b68a158ccd", "revision": "421641a7cd5a5d7edd8008a8089acbe9335b7f3d",
"revisionTime": "2017-06-30T12:58:40Z", "revisionTime": "2017-07-18T12:50:12Z",
"version": "v0.14.0", "version": "v0.21.2",
"versionExact": "v0.14.0" "versionExact": "v0.21.2"
},
{
"checksumSHA1": "mifcYH0qXpoPkX5KzXoM3mterWQ=",
"path": "gitlab.com/gitlab-org/gitaly/streamio",
"revision": "421641a7cd5a5d7edd8008a8089acbe9335b7f3d",
"revisionTime": "2017-07-18T12:50:12Z",
"version": "v0.21.2",
"versionExact": "v0.21.2"
}, },
{ {
"checksumSHA1": "Y+HGqEkYM15ir+J93MEaHdyFy0c=", "checksumSHA1": "Y+HGqEkYM15ir+J93MEaHdyFy0c=",
...@@ -230,6 +238,11 @@ ...@@ -230,6 +238,11 @@
"path": "gopkg.in/yaml.v2", "path": "gopkg.in/yaml.v2",
"revision": "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b", "revision": "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b",
"revisionTime": "2017-04-07T17:21:22Z" "revisionTime": "2017-04-07T17:21:22Z"
},
{
"path": "vendor/gitlab.com/gitlab-org/gitaly/streamio",
"revision": "v0.21.2",
"version": "v0.21.2"
} }
], ],
"rootPath": "gitlab.com/gitlab-org/gitlab-shell/go" "rootPath": "gitlab.com/gitlab-org/gitlab-shell/go"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment