Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
Kazuhiko Shiozaki
gitlab-workhorse
Commits
b0452381
Commit
b0452381
authored
Dec 10, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make go fmt happy
parent
d186cf65
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
35 deletions
+33
-35
deploy_page_test.go
deploy_page_test.go
+2
-2
error_pages_test.go
error_pages_test.go
+4
-5
main.go
main.go
+1
-1
main_test.go
main_test.go
+0
-1
sendfile_test.go
sendfile_test.go
+6
-7
servefile.go
servefile.go
+2
-2
servefile_test.go
servefile_test.go
+4
-3
uploads_test.go
uploads_test.go
+2
-2
upstream.go
upstream.go
+12
-12
No files found.
deploy_page_test.go
View file @
b0452381
package
main
package
main
import
(
import
(
"testing"
"io/ioutil"
"io/ioutil"
"os"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"os"
"path/filepath"
"path/filepath"
"testing"
)
)
func
TestIfNoDeployPageExist
(
t
*
testing
.
T
)
{
func
TestIfNoDeployPageExist
(
t
*
testing
.
T
)
{
...
...
error_pages_test.go
View file @
b0452381
package
main
package
main
import
(
import
(
"
testing
"
"
fmt
"
"io/ioutil"
"io/ioutil"
"
path/filepath
"
"
net/http
"
"net/http/httptest"
"net/http/httptest"
"os"
"os"
"
net/http
"
"
path/filepath
"
"
fmt
"
"
testing
"
)
)
func
TestIfErrorPageIsPresented
(
t
*
testing
.
T
)
{
func
TestIfErrorPageIsPresented
(
t
*
testing
.
T
)
{
...
@@ -59,4 +59,3 @@ func TestIfErrorPassedIfNoErrorPageIsFound(t *testing.T) {
...
@@ -59,4 +59,3 @@ func TestIfErrorPassedIfNoErrorPageIsFound(t *testing.T) {
t
.
Error
(
"Page should be response error: "
,
w
.
Body
.
String
())
t
.
Error
(
"Page should be response error: "
,
w
.
Body
.
String
())
}
}
}
}
main.go
View file @
b0452381
...
@@ -37,7 +37,7 @@ var authSocket = flag.String("authSocket", "", "Optional: Unix domain socket to
...
@@ -37,7 +37,7 @@ var authSocket = flag.String("authSocket", "", "Optional: Unix domain socket to
var
pprofListenAddr
=
flag
.
String
(
"pprofListenAddr"
,
""
,
"pprof listening address, e.g. 'localhost:6060'"
)
var
pprofListenAddr
=
flag
.
String
(
"pprofListenAddr"
,
""
,
"pprof listening address, e.g. 'localhost:6060'"
)
var
relativeUrlRoot
=
flag
.
String
(
"relativeUrlRoot"
,
"/"
,
"GitLab relative URL root"
)
var
relativeUrlRoot
=
flag
.
String
(
"relativeUrlRoot"
,
"/"
,
"GitLab relative URL root"
)
var
documentRoot
=
flag
.
String
(
"documentRoot"
,
"public"
,
"Path to static files content"
)
var
documentRoot
=
flag
.
String
(
"documentRoot"
,
"public"
,
"Path to static files content"
)
var
proxyTimeout
=
flag
.
Duration
(
"proxyTimeout"
,
5
*
time
.
Minute
,
"Proxy request timeout"
)
var
proxyTimeout
=
flag
.
Duration
(
"proxyTimeout"
,
5
*
time
.
Minute
,
"Proxy request timeout"
)
type
httpRoute
struct
{
type
httpRoute
struct
{
method
string
method
string
...
...
main_test.go
View file @
b0452381
...
@@ -366,4 +366,3 @@ func repoPath(t *testing.T) string {
...
@@ -366,4 +366,3 @@ func repoPath(t *testing.T) string {
}
}
return
path
.
Join
(
cwd
,
testRepoRoot
,
testRepo
)
return
path
.
Join
(
cwd
,
testRepoRoot
,
testRepo
)
}
}
sendfile_test.go
View file @
b0452381
package
main
package
main
import
(
import
(
"
testing
"
"
bytes
"
"fmt"
"fmt"
"path"
"io/ioutil"
"net/http/httptest"
"net/http"
"log"
"log"
"net/http"
"net/http/httptest"
"os"
"os"
"io/ioutil"
"os/exec"
"os/exec"
"bytes"
"path"
"testing"
)
)
func
TestDeniedLfsDownload
(
t
*
testing
.
T
)
{
func
TestDeniedLfsDownload
(
t
*
testing
.
T
)
{
...
@@ -98,4 +98,3 @@ func deniedXSendfileDownload(t *testing.T, contentFilename string, filePath stri
...
@@ -98,4 +98,3 @@ func deniedXSendfileDownload(t *testing.T, contentFilename string, filePath stri
t
.
Fatal
(
"Unexpected file contents in download"
)
t
.
Fatal
(
"Unexpected file contents in download"
)
}
}
}
}
servefile.go
View file @
b0452381
...
@@ -15,9 +15,9 @@ func handleServeFile(documentRoot *string, notFoundHandler serviceHandleFunc) se
...
@@ -15,9 +15,9 @@ func handleServeFile(documentRoot *string, notFoundHandler serviceHandleFunc) se
// The filepath.Join does Clean traversing directories up
// The filepath.Join does Clean traversing directories up
if
!
strings
.
HasPrefix
(
file
,
*
documentRoot
)
{
if
!
strings
.
HasPrefix
(
file
,
*
documentRoot
)
{
fail500
(
w
,
&
os
.
PathError
{
fail500
(
w
,
&
os
.
PathError
{
Op
:
"open"
,
Op
:
"open"
,
Path
:
file
,
Path
:
file
,
Err
:
os
.
ErrInvalid
,
Err
:
os
.
ErrInvalid
,
})
})
return
return
}
}
...
...
servefile_test.go
View file @
b0452381
package
main
package
main
import
(
import
(
"io/ioutil"
"io/ioutil"
"
testing
"
"
net/http
"
"net/http/httptest"
"net/http/httptest"
"os"
"os"
"net/http"
"path/filepath"
"path/filepath"
"testing"
)
)
func
TestServingNonExistingFile
(
t
*
testing
.
T
)
{
func
TestServingNonExistingFile
(
t
*
testing
.
T
)
{
...
@@ -76,7 +77,7 @@ func TestServingTheActualFile(t *testing.T) {
...
@@ -76,7 +77,7 @@ func TestServingTheActualFile(t *testing.T) {
httpRequest
,
_
:=
http
.
NewRequest
(
"GET"
,
"/file"
,
nil
)
httpRequest
,
_
:=
http
.
NewRequest
(
"GET"
,
"/file"
,
nil
)
request
:=
&
gitRequest
{
request
:=
&
gitRequest
{
Request
:
httpRequest
,
Request
:
httpRequest
,
relativeUriPath
:
"/file"
,
relativeUriPath
:
"/file"
,
}
}
...
...
uploads_test.go
View file @
b0452381
...
@@ -41,7 +41,7 @@ func TestUploadHandlerForwardingRawData(t *testing.T) {
...
@@ -41,7 +41,7 @@ func TestUploadHandlerForwardingRawData(t *testing.T) {
fmt
.
Fprint
(
w
,
"RESPONSE"
)
fmt
.
Fprint
(
w
,
"RESPONSE"
)
})
})
httpRequest
,
err
:=
http
.
NewRequest
(
"PATCH"
,
ts
.
URL
+
"/url/path"
,
bytes
.
NewBufferString
(
"REQUEST"
))
httpRequest
,
err
:=
http
.
NewRequest
(
"PATCH"
,
ts
.
URL
+
"/url/path"
,
bytes
.
NewBufferString
(
"REQUEST"
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -123,7 +123,7 @@ func TestUploadHandlerRewritingMultiPartData(t *testing.T) {
...
@@ -123,7 +123,7 @@ func TestUploadHandlerRewritingMultiPartData(t *testing.T) {
fmt
.
Fprint
(
file
,
"test"
)
fmt
.
Fprint
(
file
,
"test"
)
writer
.
Close
()
writer
.
Close
()
httpRequest
,
err
:=
http
.
NewRequest
(
"PUT"
,
ts
.
URL
+
"/url/path"
,
nil
)
httpRequest
,
err
:=
http
.
NewRequest
(
"PUT"
,
ts
.
URL
+
"/url/path"
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
upstream.go
View file @
b0452381
...
@@ -27,29 +27,29 @@ type upstream struct {
...
@@ -27,29 +27,29 @@ type upstream struct {
type
authorizationResponse
struct
{
type
authorizationResponse
struct
{
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// push' and 'git pull'
// push' and 'git pull'
GL_ID
string
GL_ID
string
// RepoPath is the full path on disk to the Git repository the request is
// RepoPath is the full path on disk to the Git repository the request is
// about
// about
RepoPath
string
RepoPath
string
// ArchivePath is the full path where we should find/create a cached copy
// ArchivePath is the full path where we should find/create a cached copy
// of a requested archive
// of a requested archive
ArchivePath
string
ArchivePath
string
// ArchivePrefix is used to put extracted archive contents in a
// ArchivePrefix is used to put extracted archive contents in a
// subdirectory
// subdirectory
ArchivePrefix
string
ArchivePrefix
string
// CommitId is used do prevent race conditions between the 'time of check'
// CommitId is used do prevent race conditions between the 'time of check'
// in the GitLab Rails app and the 'time of use' in gitlab-workhorse.
// in the GitLab Rails app and the 'time of use' in gitlab-workhorse.
CommitId
string
CommitId
string
// StoreLFSPath is provided by the GitLab Rails application
// StoreLFSPath is provided by the GitLab Rails application
// to mark where the tmp file should be placed
// to mark where the tmp file should be placed
StoreLFSPath
string
StoreLFSPath
string
// LFS object id
// LFS object id
LfsOid
string
LfsOid
string
// LFS object size
// LFS object size
LfsSize
int64
LfsSize
int64
// TmpPath is the path where we should store temporary files
// TmpPath is the path where we should store temporary files
// This is set by authorization middleware
// This is set by authorization middleware
TempPath
string
TempPath
string
}
}
// A gitRequest is an *http.Request decorated with attributes returned by the
// A gitRequest is an *http.Request decorated with attributes returned by the
...
@@ -57,7 +57,7 @@ type authorizationResponse struct {
...
@@ -57,7 +57,7 @@ type authorizationResponse struct {
type
gitRequest
struct
{
type
gitRequest
struct
{
*
http
.
Request
*
http
.
Request
authorizationResponse
authorizationResponse
u
*
upstream
u
*
upstream
// This field contains the URL.Path stripped from RelativeUrlRoot
// This field contains the URL.Path stripped from RelativeUrlRoot
relativeUriPath
string
relativeUriPath
string
...
@@ -70,9 +70,9 @@ func newUpstream(authBackend string, authTransport http.RoundTripper) *upstream
...
@@ -70,9 +70,9 @@ func newUpstream(authBackend string, authTransport http.RoundTripper) *upstream
}
}
up
:=
&
upstream
{
up
:=
&
upstream
{
authBackend
:
authBackend
,
authBackend
:
authBackend
,
httpClient
:
&
http
.
Client
{
Transport
:
authTransport
},
httpClient
:
&
http
.
Client
{
Transport
:
authTransport
},
httpProxy
:
httputil
.
NewSingleHostReverseProxy
(
u
),
httpProxy
:
httputil
.
NewSingleHostReverseProxy
(
u
),
relativeUrlRoot
:
"/"
,
relativeUrlRoot
:
"/"
,
}
}
up
.
httpProxy
.
Transport
=
authTransport
up
.
httpProxy
.
Transport
=
authTransport
...
...
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