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:
authorJaime Martinez <jmartinez@gitlab.com>2021-01-19 08:05:39 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-01-20 04:23:47 +0300
commit09144137f206ab70fe29fb172c606b8309018fc7 (patch)
treeba015081d250451d0ccdb5e9c1d66dfdbc529cfd /internal/logging
parentce03560d89e7315e24e6ade1fcb5ec14f0c82e39 (diff)
Simplify domain and resolver checks
Return domain not found Returns ErrDomainDoesNotExist when the lookup path cannot be found for a specific project. Closes https://gitlab.com/gitlab-org/gitlab-pages/issues/353 Return ErrDomainDoesNotExist in group resolver
Diffstat (limited to 'internal/logging')
-rw-r--r--internal/logging/logging.go1
-rw-r--r--internal/logging/logging_test.go23
2 files changed, 11 insertions, 13 deletions
diff --git a/internal/logging/logging.go b/internal/logging/logging.go
index 43fe65e6..4dcf66d2 100644
--- a/internal/logging/logging.go
+++ b/internal/logging/logging.go
@@ -61,7 +61,6 @@ func getExtraLogFields(r *http.Request) log.Fields {
if d := request.GetDomain(r); d != nil {
lp, err := d.GetLookupPath(r)
if err != nil {
- logFields["error"] = err.Error()
return logFields
}
diff --git a/internal/logging/logging_test.go b/internal/logging/logging_test.go
index 2ed2b6ec..9079cc9d 100644
--- a/internal/logging/logging_test.go
+++ b/internal/logging/logging_test.go
@@ -18,13 +18,15 @@ func (f lookupPathFunc) Resolve(r *http.Request) (*serving.Request, error) {
}
func TestGetExtraLogFields(t *testing.T) {
- domainWithResolver := domain.New("", "", "", lookupPathFunc(func(*http.Request) *serving.LookupPath {
- return &serving.LookupPath{
- ServingType: "file",
- ProjectID: 100,
- Prefix: "/prefix",
- }
- }))
+ domainWithResolver := &domain.Domain{
+ Resolver: lookupPathFunc(func(*http.Request) *serving.LookupPath {
+ return &serving.LookupPath{
+ ServingType: "file",
+ ProjectID: 100,
+ Prefix: "/prefix",
+ }
+ }),
+ }
tests := []struct {
name string
@@ -36,7 +38,6 @@ func TestGetExtraLogFields(t *testing.T) {
expectedProjectID interface{}
expectedProjectPrefix interface{}
expectedServingType interface{}
- expectedErrMsg interface{}
}{
{
name: "https",
@@ -61,15 +62,14 @@ func TestGetExtraLogFields(t *testing.T) {
expectedServingType: "file",
},
{
- name: "domain_without_resolver",
+ name: "domain_without_resolved",
scheme: request.SchemeHTTP,
host: "githost.io",
- domain: &domain.Domain{},
+ domain: nil,
expectedHTTPS: false,
expectedHost: "githost.io",
expectedProjectID: nil,
expectedServingType: nil,
- expectedErrMsg: "not configured",
},
{
name: "no_domain",
@@ -97,7 +97,6 @@ func TestGetExtraLogFields(t *testing.T) {
require.Equal(t, tt.expectedProjectID, got["pages_project_id"])
require.Equal(t, tt.expectedProjectPrefix, got["pages_project_prefix"])
require.Equal(t, tt.expectedServingType, got["pages_project_serving_type"])
- require.Equal(t, tt.expectedErrMsg, got["error"])
})
}
}