Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-shell
Commits
164baba2
Commit
164baba2
authored
Jul 07, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Gitaly dialOpts
parent
51fe7f28
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
18 deletions
+15
-18
go/internal/handler/handler.go
go/internal/handler/handler.go
+13
-0
go/internal/handler/receive_pack.go
go/internal/handler/receive_pack.go
+1
-9
go/internal/handler/upload_pack.go
go/internal/handler/upload_pack.go
+1
-9
No files found.
go/internal/handler/handler.go
View file @
164baba2
...
...
@@ -5,6 +5,10 @@ import (
"os/exec"
"syscall"
"google.golang.org/grpc"
"gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/logger"
)
...
...
@@ -36,3 +40,12 @@ func execCommand(command string, args ...string) error {
args
=
append
([]
string
{
binPath
},
args
...
)
return
syscall
.
Exec
(
binPath
,
args
,
os
.
Environ
())
}
func
dialOpts
(
token
string
)
[]
grpc
.
DialOption
{
connOpts
:=
client
.
DefaultDialOpts
if
token
:=
os
.
Getenv
(
"GITALY_TOKEN"
);
token
!=
""
{
connOpts
=
append
(
client
.
DefaultDialOpts
,
grpc
.
WithPerRPCCredentials
(
gitalyauth
.
RPCCredentials
(
token
)))
}
return
connOpts
}
go/internal/handler/receive_pack.go
View file @
164baba2
...
...
@@ -5,10 +5,7 @@ import (
"fmt"
"os"
"google.golang.org/grpc"
pb
"gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client"
)
...
...
@@ -17,12 +14,7 @@ func ReceivePack(gitalyAddress string, request *pb.SSHReceivePackRequest) (int32
return
0
,
fmt
.
Errorf
(
"no gitaly_address given"
)
}
connOpts
:=
client
.
DefaultDialOpts
if
token
:=
os
.
Getenv
(
"GITALY_TOKEN"
);
token
!=
""
{
connOpts
=
append
(
client
.
DefaultDialOpts
,
grpc
.
WithPerRPCCredentials
(
gitalyauth
.
RPCCredentials
(
token
)))
}
conn
,
err
:=
client
.
Dial
(
gitalyAddress
,
connOpts
)
conn
,
err
:=
client
.
Dial
(
gitalyAddress
,
dialOpts
(
os
.
Getenv
(
"GITALY_TOKEN"
)))
if
err
!=
nil
{
return
0
,
err
}
...
...
go/internal/handler/upload_pack.go
View file @
164baba2
...
...
@@ -5,10 +5,7 @@ import (
"fmt"
"os"
"google.golang.org/grpc"
pb
"gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client"
)
...
...
@@ -17,12 +14,7 @@ func UploadPack(gitalyAddress string, request *pb.SSHUploadPackRequest) (int32,
return
0
,
fmt
.
Errorf
(
"no gitaly_address given"
)
}
connOpts
:=
client
.
DefaultDialOpts
if
token
:=
os
.
Getenv
(
"GITALY_TOKEN"
);
token
!=
""
{
connOpts
=
append
(
client
.
DefaultDialOpts
,
grpc
.
WithPerRPCCredentials
(
gitalyauth
.
RPCCredentials
(
token
)))
}
conn
,
err
:=
client
.
Dial
(
gitalyAddress
,
connOpts
)
conn
,
err
:=
client
.
Dial
(
gitalyAddress
,
dialOpts
(
os
.
Getenv
(
"GITALY_TOKEN"
)))
if
err
!=
nil
{
return
0
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment