Commit 947d4d49 authored by Kim "BKC" Carlbäcker's avatar Kim "BKC" Carlbäcker

fix vendor

parent 799417a3
......@@ -77,7 +77,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LICENSE - gitlab.com/gitlab-org/gitaly/internal/service/middleware/panichandler
LICENSE - gitlab.com/gitlab-org/gitaly/internal/middleware/panichandler
Copyright (c) 2016 Masahiro Sano
MIT License
......
package gitalyauth
import (
"encoding/base64"
"golang.org/x/net/context"
"google.golang.org/grpc/credentials"
)
// RPCCredentials can be used with grpc.WithPerRPCCredentials to create a
// grpc.DialOption that inserts the supplied token for authentication
// with a Gitaly server.
func RPCCredentials(token string) credentials.PerRPCCredentials {
return &rpcCredentials{token: base64.StdEncoding.EncodeToString([]byte(token))}
}
type rpcCredentials struct {
token string
}
func (*rpcCredentials) RequireTransportSecurity() bool { return false }
func (rc *rpcCredentials) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
return map[string]string{"authorization": "Bearer " + rc.token}, nil
}
package client
import (
"fmt"
"io"
"google.golang.org/grpc"
......@@ -31,30 +30,11 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st
return stream.Send(&pb.SSHReceivePackRequest{Stdin: p})
})
errC := make(chan error, 1)
go func() {
return streamHandler(func() (stdoutStderrResponse, error) {
return stream.Recv()
}, func(errC chan error) {
_, errRecv := io.Copy(inWriter, stdin)
stream.CloseSend()
errC <- errRecv
}()
exitStatus, errRecv := recvStdoutStderrStream(func() (stdoutStderrResponse, error) {
return stream.Recv()
}, stdout, stderr)
if errRecv != nil {
return exitStatus, errRecv
}
select {
case errSend := <-errC:
if errSend != nil {
// This should not happen
errSend = fmt.Errorf("stdin send error: %v", errSend)
}
return exitStatus, errSend
default:
return exitStatus, nil
}
}
package client
import (
"fmt"
"io"
pb "gitlab.com/gitlab-org/gitaly-proto/go"
......@@ -12,12 +13,17 @@ type stdoutStderrResponse interface {
GetStdout() []byte
}
func recvStdoutStderrStream(recv func() (stdoutStderrResponse, error), stdout, stderr io.Writer) (int32, error) {
func streamHandler(recv func() (stdoutStderrResponse, error), send func(chan error), stdout, stderr io.Writer) (int32, error) {
var (
exitStatus int32
err error
resp stdoutStderrResponse
)
errC := make(chan error, 1)
go send(errC)
for {
resp, err = recv()
if err != nil {
......@@ -28,19 +34,33 @@ func recvStdoutStderrStream(recv func() (stdoutStderrResponse, error), stdout, s
}
if len(resp.GetStderr()) > 0 {
if _, errWrite := stderr.Write(resp.GetStderr()); errWrite != nil {
return exitStatus, errWrite
if _, err = stderr.Write(resp.GetStderr()); err != nil {
break
}
}
if len(resp.GetStdout()) > 0 {
if _, errWrite := stdout.Write(resp.GetStdout()); errWrite != nil {
return exitStatus, errWrite
if _, err = stdout.Write(resp.GetStdout()); err != nil {
break
}
}
}
if err == io.EOF {
err = nil
}
if err != nil {
return exitStatus, err
}
select {
case errSend := <-errC:
if errSend != nil {
// This should not happen
errSend = fmt.Errorf("stdin send error: %v", errSend)
}
return exitStatus, errSend
default:
return exitStatus, nil
}
}
package client
import (
"fmt"
"io"
"google.golang.org/grpc"
......@@ -31,30 +30,11 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std
return stream.Send(&pb.SSHUploadPackRequest{Stdin: p})
})
errC := make(chan error, 1)
go func() {
return streamHandler(func() (stdoutStderrResponse, error) {
return stream.Recv()
}, func(errC chan error) {
_, errRecv := io.Copy(inWriter, stdin)
stream.CloseSend()
errC <- errRecv
}()
exitStatus, errRecv := recvStdoutStderrStream(func() (stdoutStderrResponse, error) {
return stream.Recv()
}, stdout, stderr)
if errRecv != nil {
return exitStatus, errRecv
}
select {
case errSend := <-errC:
if errSend != nil {
// This should not happen
errSend = fmt.Errorf("stdin send error: %v", errSend)
}
return exitStatus, errSend
default:
return exitStatus, nil
}
}
......@@ -30,10 +30,20 @@
"versionExact": "v0.9.0"
},
{
"checksumSHA1": "xDXnu1dEiNdrGdL1VfuCnJZey7s=",
"checksumSHA1": "dUHJbKas746n5fLzlwxHb6FOCxs=",
"path": "gitlab.com/gitlab-org/gitaly/auth",
"revision": "e4f8d3d14cc3fe673cb511fb4d0189b68a158ccd",
"revisionTime": "2017-06-30T12:58:40Z",
"version": "v0.14.0",
"versionExact": "v0.14.0"
},
{
"checksumSHA1": "Z/BteCm3WErBI8bBmSN9gD+3EbU=",
"path": "gitlab.com/gitlab-org/gitaly/client",
"revision": "cf955be6f08f16cca367a97d1ac2631a2ba33be3",
"revisionTime": "2017-06-25T13:40:46Z"
"revision": "e4f8d3d14cc3fe673cb511fb4d0189b68a158ccd",
"revisionTime": "2017-06-30T12:58:40Z",
"version": "v0.14.0",
"versionExact": "v0.14.0"
},
{
"checksumSHA1": "Y+HGqEkYM15ir+J93MEaHdyFy0c=",
......
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