Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--domain.go2
-rw-r--r--domains.go19
-rw-r--r--main.go1
4 files changed, 31 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index e356ef5c..41fae2bd 100644
--- a/Makefile
+++ b/Makefile
@@ -19,3 +19,24 @@ gitlab-pages: $(GO_FILES)
update:
godep save ./...
+
+verify: fmt vet lint complexity test
+
+fmt:
+ go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }'
+
+vet:
+ go get golang.org/x/tools/cmd/vet
+ go vet
+
+lint:
+ go get github.com/golang/lint/golint
+ golint . | ( ! grep -v "^$$" )
+
+complexity:
+ go get github.com/fzipp/gocyclo
+ gocyclo -over 9 $(wildcard *.go)
+
+test:
+ go get golang.org/x/tools/cmd/cover
+ go test ./... -cover
diff --git a/domain.go b/domain.go
index f9bbb7a7..0a75e21e 100644
--- a/domain.go
+++ b/domain.go
@@ -93,7 +93,7 @@ func (d *domain) serveFromConfig(w http.ResponseWriter, r *http.Request) {
}
func (d *domain) ensureCertificate() (*tls.Certificate, error) {
- if !d.Config {
+ if d.Config == nil {
return nil, errors.New("tls certificates can be loaded only for pages with configuration")
}
diff --git a/domains.go b/domains.go
index f553e106..49058fb0 100644
--- a/domains.go
+++ b/domains.go
@@ -2,7 +2,6 @@ package main
import (
"bytes"
- "encoding/json"
"errors"
"io/ioutil"
"log"
@@ -22,19 +21,19 @@ func isDomainAllowed(domain string) bool {
}
// TODO: better sanitize domain
domain = strings.ToLower(domain)
- pagesDomain = "." + strings.ToLower(pagesDomain)
- return !strings.HasPrefix(domain, pagesDomain)
+ rootDomain := "." + strings.ToLower(*pagesDomain)
+ return !strings.HasPrefix(domain, rootDomain)
}
func (d domains) addDomain(group, project string, config *domainConfig) error {
- newDomain := &domain{
+ newDomain := domain{
Group: group,
Project: project,
- Config: domainConfig,
+ Config: config,
}
if config != nil {
- if !isDomainAllowed(domainConfig.Domain) {
+ if !isDomainAllowed(config.Domain) {
return errors.New("domain name is not allowed")
}
@@ -43,7 +42,7 @@ func (d domains) addDomain(group, project string, config *domainConfig) error {
domainName := group + "." + *pagesDomain
d[domainName] = newDomain
}
- return
+ return nil
}
func (d domains) readProjects(group string) (count int) {
@@ -74,7 +73,7 @@ func (d domains) readProjects(group string) (count int) {
continue
}
- for _, domainConfig := range domainsConfig.Domains {
+ for _, domainConfig := range config.Domains {
d.addDomain(group, project.Name(), &domainConfig)
}
}
@@ -103,14 +102,14 @@ func (d domains) ReadGroups() error {
count := d.readProjects(group.Name())
if count > 0 {
- d.addDomain(group, "", &domainConfig)
+ d.addDomain(group.Name(), "", nil)
}
}
return nil
}
func watchDomains(updater domainsUpdater) {
- lastUpdate := "no-configuration"
+ lastUpdate := []byte("no-update")
for {
update, err := ioutil.ReadFile(filepath.Join(*pagesRoot, ".update"))
diff --git a/main.go b/main.go
index 7844e2d2..b89cec0c 100644
--- a/main.go
+++ b/main.go
@@ -8,7 +8,6 @@ import (
"net/http"
"strings"
"sync"
- "syscall"
)
// VERSION stores the information about the semantic version of application