Commit ff480401 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'use-gopath' into 'master'

Be compatible with GOPATH



See merge request !43
parents b04210fe fece6a3b
......@@ -4,3 +4,4 @@ testdata/scratch
testdata/public
gitlab-zip-cat
gitlab-zip-metadata
_build
PREFIX=/usr/local
VERSION=$(shell git describe)-$(shell date -u +%Y%m%d.%H%M%S)
export GOPATH=$(shell pwd)/_build
GOBUILD=go build -ldflags "-X main.Version=${VERSION}"
PKG=gitlab.com/gitlab-org/gitlab-workhorse
all: gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
all: clean-build gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
gitlab-zip-cat: $(shell find cmd/gitlab-zip-cat/ -name '*.go')
${GOBUILD} -o $@ ./cmd/$@
gitlab-zip-cat: _build $(shell find cmd/gitlab-zip-cat/ -name '*.go')
${GOBUILD} -o $@ ${PKG}/cmd/$@
gitlab-zip-metadata: $(shell find cmd/gitlab-zip-metadata/ -name '*.go')
${GOBUILD} -o $@ ./cmd/$@
gitlab-zip-metadata: _build $(shell find cmd/gitlab-zip-metadata/ -name '*.go')
${GOBUILD} -o $@ ${PKG}/cmd/$@
gitlab-workhorse: $(shell find . -name '*.go')
${GOBUILD} -o $@
gitlab-workhorse: _build $(shell find . -name '*.go' | grep -v '^\./_')
${GOBUILD} -o $@ ${PKG}
install: gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
mkdir -p $(DESTDIR)${PREFIX}/bin/
install gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata ${DESTDIR}${PREFIX}/bin/
_build:
mkdir -p $@/src/${PKG}
tar -cf - --exclude $@ --exclude .git . | (cd $@/src/${PKG} && tar -xf -)
touch $@
.PHONY: test
test: testdata/data/group/test.git clean-workhorse all
go fmt ./... | awk '{ print } END { if (NR > 0) { print "Please run go fmt"; exit 1 } }'
support/path go test ./...
test: testdata/data/group/test.git clean-build clean-workhorse all
go fmt ${PKG}/... | awk '{ print } END { if (NR > 0) { print "Please run go fmt"; exit 1 } }'
support/path go test ${PKG}/...
@echo SUCCESS
coverage: testdata/data/group/test.git
......@@ -38,9 +45,13 @@ testdata/data:
mkdir -p $@
.PHONY: clean
clean: clean-workhorse
clean: clean-workhorse clean-build
rm -rf testdata/data testdata/scratch
.PHONY: clean-workhorse
clean-workhorse:
rm -f gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
.PHONY: clean-build
clean-build:
rm -rf _build
package main
import (
"./internal/api"
"./internal/helper"
"./internal/testhelper"
"fmt"
"net/http"
"net/http/httptest"
"regexp"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func okHandler(w http.ResponseWriter, _ *http.Request, _ *api.Response) {
......
package main
import (
"../../internal/zipartifacts"
"archive/zip"
"flag"
"fmt"
"io"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/zipartifacts"
)
const progName = "gitlab-zip-cat"
......
package main
import (
"../../internal/zipartifacts"
"flag"
"fmt"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/zipartifacts"
)
const progName = "gitlab-zip-metadata"
......
package api
import (
"../badgateway"
"../helper"
"encoding/json"
"fmt"
"io"
......@@ -10,6 +8,9 @@ import (
"net/http"
"net/url"
"strings"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
type API struct {
......
package artifacts
import (
"../api"
"../helper"
"../zipartifacts"
"bufio"
"errors"
"fmt"
......@@ -15,6 +12,10 @@ import (
"path/filepath"
"strings"
"syscall"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/zipartifacts"
)
func detectFileContentType(fileName string) string {
......
package artifacts
import (
"../api"
"../helper"
"../testhelper"
"archive/zip"
"encoding/base64"
"encoding/json"
......@@ -13,6 +10,10 @@ import (
"net/http/httptest"
"os"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func testArtifactDownloadServer(t *testing.T, archive string, entry string) *httptest.Server {
......
package artifacts
import (
"../api"
"../helper"
"../upload"
"../zipartifacts"
"errors"
"fmt"
"io/ioutil"
......@@ -13,6 +9,11 @@ import (
"os"
"os/exec"
"syscall"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/upload"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/zipartifacts"
)
type artifactsUploadProcessor struct {
......
package artifacts
import (
"../api"
"../helper"
"../proxy"
"../testhelper"
"../zipartifacts"
"archive/zip"
"bytes"
"compress/gzip"
......@@ -18,6 +13,12 @@ import (
"net/http/httptest"
"os"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/zipartifacts"
)
func testArtifactsUploadServer(t *testing.T, tempPath string) *httptest.Server {
......
package badgateway
import (
"../helper"
"bytes"
"fmt"
"io/ioutil"
"net"
"net/http"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
// Values from http.DefaultTransport
......
......@@ -5,8 +5,6 @@ In this file we handle 'git archive' downloads
package git
import (
"../helper"
"../senddata"
"fmt"
"io"
"io/ioutil"
......@@ -18,6 +16,9 @@ import (
"path/filepath"
"syscall"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
)
type archive struct{ senddata.Prefix }
......
package git
import (
"../helper"
"../senddata"
"fmt"
"io"
"log"
"net/http"
"strings"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
)
type blob struct{ senddata.Prefix }
......
......@@ -5,9 +5,6 @@ In this file we handle the Git 'smart HTTP' protocol
package git
import (
"../api"
"../delay"
"../helper"
"errors"
"fmt"
"io"
......@@ -17,6 +14,10 @@ import (
"path"
"path/filepath"
"strings"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/delay"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
func GetInfoRefs(a *api.API) http.Handler {
......
......@@ -5,8 +5,6 @@ In this file we handle git lfs objects downloads and uploads
package lfs
import (
"../api"
"../helper"
"bytes"
"crypto/sha256"
"encoding/hex"
......@@ -17,6 +15,9 @@ import (
"net/http"
"os"
"path/filepath"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
func PutStore(a *api.API, h http.Handler) http.Handler {
......
package proxy
import (
"../badgateway"
"../helper"
"net/http"
"net/http/httputil"
"net/url"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
type Proxy struct {
......
......@@ -7,9 +7,10 @@ via the X-Sendfile mechanism. All that is needed in the Rails code is the
package sendfile
import (
"../helper"
"log"
"net/http"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
const sendFileResponseHeader = "X-Sendfile"
......
package staticpages
import (
"../helper"
"io/ioutil"
"net/http"
"path/filepath"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
func (s *Static) DeployPage(handler http.Handler) http.Handler {
......
package staticpages
import (
"../testhelper"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestIfNoDeployPageExist(t *testing.T) {
......
package staticpages
import (
"../helper"
"fmt"
"io/ioutil"
"log"
"net/http"
"path/filepath"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
type errorPageResponseWriter struct {
......
package staticpages
import (
"../testhelper"
"fmt"
"io/ioutil"
"net/http"
......@@ -9,6 +8,8 @@ import (
"os"
"path/filepath"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestIfErrorPageIsPresented(t *testing.T) {
......
package staticpages
import (
"../helper"
"../urlprefix"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/urlprefix"
)
type CacheMode int
......
package staticpages
import (
"../testhelper"
"bytes"
"compress/gzip"
"io/ioutil"
......@@ -10,6 +9,8 @@ import (
"os"
"path/filepath"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestServingNonExistingFile(t *testing.T) {
......
package upload
import (
"../helper"
"bytes"
"fmt"
"io"
......@@ -9,6 +8,8 @@ import (
"mime/multipart"
"net/http"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
type MultipartFormProcessor interface {
......
package upload
import (
"../helper"
"../proxy"
"../testhelper"
"bytes"
"errors"
"fmt"
......@@ -16,6 +13,10 @@ import (
"regexp"
"strings"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
var nilHandler = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
......
package upstream
import (
"../testhelper"
"net/http"
"net/http/httptest"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestDevelopmentModeEnabled(t *testing.T) {
......
package upstream
import (
"../helper"
"compress/gzip"
"fmt"
"io"
"net/http"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
func contentEncodingHandler(h http.Handler) http.Handler {
......
package upstream
import (
"../testhelper"
"bytes"
"compress/gzip"
"fmt"
......@@ -10,6 +9,8 @@ import (
"net/http/httptest"
"reflect"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func TestGzipEncoding(t *testing.T) {
......
package upstream
import (
apipkg "../api"
"../artifacts"
"../git"
"../lfs"
proxypkg "../proxy"
"../senddata"
"../sendfile"
"../staticpages"
"net/http"
"regexp"
apipkg "gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/artifacts"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/git"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/lfs"
proxypkg "gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/sendfile"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/staticpages"
)
type route struct {
......
......@@ -7,14 +7,15 @@ In this file we handle request routing and interaction with the authBackend.
package upstream
import (
"../badgateway"
"../helper"
"../urlprefix"
"fmt"
"net/http"
"net/url"
"strings"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/urlprefix"
)
var DefaultBackend = helper.URLMustParse("http://localhost:8080")
......
......@@ -14,7 +14,6 @@ In this file we start the web server and hand off to the upstream type.
package main
import (
"./internal/upstream"
"flag"
"fmt"
"log"
......@@ -24,6 +23,8 @@ import (
"os"
"syscall"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/upstream"
)
// Current version of GitLab Workhorse
......
package main
import (
"./internal/api"
"./internal/helper"
"./internal/testhelper"
"./internal/upstream"
"bytes"
"encoding/base64"
"encoding/json"
......@@ -22,6 +18,11 @@ import (
"strings"
"testing"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/upstream"
)
const scratchDir = "testdata/scratch"
......
package main
import (
"./internal/badgateway"
"./internal/helper"
"./internal/proxy"
"./internal/testhelper"
"bytes"
"fmt"
"io"
......@@ -14,6 +10,11 @@ import (
"regexp"
"testing"
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
func newProxy(url string, rt *badgateway.RoundTripper) *proxy.Proxy {
......
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