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:
authorKamil Trzciński <ayufan@ayufan.eu>2019-10-01 13:00:52 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-10-01 13:00:52 +0300
commit75111473589791e1d11dc9225798a19d248a6cbe (patch)
tree4564187489c4c261236bebc852a552f2142ec445
parentb37ed1c0ff9880fb73ed2ed771c100333d79f3c5 (diff)
Remove references to `Project`
Always uses `LookupPath`. The `project` is local to `source/disk`.
-rw-r--r--app.go4
-rw-r--r--internal/domain/domain.go44
-rw-r--r--internal/logging/logging.go2
-rw-r--r--internal/serving/lookup_path.go2
-rw-r--r--internal/source/disk/custom.go6
-rw-r--r--internal/source/disk/group.go6
6 files changed, 32 insertions, 32 deletions
diff --git a/app.go b/app.go
index 67b94f2a..82cc2680 100644
--- a/app.go
+++ b/app.go
@@ -101,7 +101,7 @@ func (a *theApp) domain(host string) *domain.Domain {
}
func (a *theApp) checkAuthenticationIfNotExists(domain *domain.Domain, w http.ResponseWriter, r *http.Request) bool {
- if domain == nil || !domain.HasProject(r) {
+ if domain == nil || !domain.HasLookupPath(r) {
// Only if auth is supported
if a.Auth.IsAuthSupported() {
@@ -231,7 +231,7 @@ func (a *theApp) accessControlMiddleware(handler http.Handler) http.Handler {
// Only for projects that have access control enabled
if domain.IsAccessControlEnabled(r) {
// accessControlMiddleware
- if a.Auth.CheckAuthentication(w, r, domain.GetID(r)) {
+ if a.Auth.CheckAuthentication(w, r, domain.GetProjectID(r)) {
return
}
}
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index 2941d174..febb488f 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -43,21 +43,21 @@ func (d *Domain) resolve(r *http.Request) (*serving.LookupPath, string) {
// TODO use lookupPaths to cache information about projects better, to
// improve performance and resilience
- project, subpath, _ := d.Resolver.Resolve(r)
+ lookupPath, subpath, _ := d.Resolver.Resolve(r)
// Current implementation does not return errors in any case
- if project == nil {
+ if lookupPath == nil {
return nil, ""
}
- return project, subpath
+ return lookupPath, subpath
}
-// GetProject returns a project details based on the request
-func (d *Domain) GetProject(r *http.Request) *serving.LookupPath {
- project, _ := d.resolve(r)
+// GetLookupPath returns a project details based on the request
+func (d *Domain) GetLookupPath(r *http.Request) *serving.LookupPath {
+ lookupPath, _ := d.resolve(r)
- return project
+ return lookupPath
}
// Serving returns domain serving driver
@@ -87,8 +87,8 @@ func (d *Domain) IsHTTPSOnly(r *http.Request) bool {
return false
}
- if project := d.GetProject(r); project != nil {
- return project.IsHTTPSOnly
+ if lookupPath := d.GetLookupPath(r); lookupPath != nil {
+ return lookupPath.IsHTTPSOnly
}
return false
@@ -100,8 +100,8 @@ func (d *Domain) IsAccessControlEnabled(r *http.Request) bool {
return false
}
- if project := d.GetProject(r); project != nil {
- return project.HasAccessControl
+ if lookupPath := d.GetLookupPath(r); lookupPath != nil {
+ return lookupPath.HasAccessControl
}
return false
@@ -113,33 +113,33 @@ func (d *Domain) IsNamespaceProject(r *http.Request) bool {
return false
}
- if project := d.GetProject(r); project != nil {
- return project.IsNamespaceProject
+ if lookupPath := d.GetLookupPath(r); lookupPath != nil {
+ return lookupPath.IsNamespaceProject
}
return false
}
-// GetID figures out what is the ID of the project user tries to access
-func (d *Domain) GetID(r *http.Request) uint64 {
+// GetProjectID figures out what is the ID of the project user tries to access
+func (d *Domain) GetProjectID(r *http.Request) uint64 {
if d.isUnconfigured() {
return 0
}
- if project := d.GetProject(r); project != nil {
- return project.ID
+ if lookupPath := d.GetLookupPath(r); lookupPath != nil {
+ return lookupPath.ProjectID
}
return 0
}
-// HasProject figures out if the project exists that the user tries to access
-func (d *Domain) HasProject(r *http.Request) bool {
+// HasLookupPath figures out if the project exists that the user tries to access
+func (d *Domain) HasLookupPath(r *http.Request) bool {
if d.isUnconfigured() {
return false
}
- return d.GetProject(r) != nil
+ return d.GetLookupPath(r) != nil
}
// EnsureCertificate parses the PEM-encoded certificate for the domain
@@ -164,7 +164,7 @@ func (d *Domain) EnsureCertificate() (*tls.Certificate, error) {
// ServeFileHTTP returns true if something was served, false if not.
func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
- if d.isUnconfigured() || !d.HasProject(r) {
+ if d.isUnconfigured() || !d.HasLookupPath(r) {
// TODO: this seems to be wrong:
// as we should rather return false,
// and fallback to `ServeNotFoundHTTP`
@@ -178,7 +178,7 @@ func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
// ServeNotFoundHTTP serves the not found pages from the projects.
func (d *Domain) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) {
- if d.isUnconfigured() || !d.HasProject(r) {
+ if d.isUnconfigured() || !d.HasLookupPath(r) {
httperrors.Serve404(w)
return
}
diff --git a/internal/logging/logging.go b/internal/logging/logging.go
index f0682573..7c2f013e 100644
--- a/internal/logging/logging.go
+++ b/internal/logging/logging.go
@@ -55,7 +55,7 @@ func getAccessLogger(format string) (*logrus.Logger, error) {
func getExtraLogFields(r *http.Request) log.Fields {
var projectID uint64
if d := request.GetDomain(r); d != nil {
- projectID = d.GetID(r)
+ projectID = d.GetProjectID(r)
}
return log.Fields{
diff --git a/internal/serving/lookup_path.go b/internal/serving/lookup_path.go
index 77ac45e8..0b651d53 100644
--- a/internal/serving/lookup_path.go
+++ b/internal/serving/lookup_path.go
@@ -7,5 +7,5 @@ type LookupPath struct {
IsNamespaceProject bool
IsHTTPSOnly bool
HasAccessControl bool
- ID uint64
+ ProjectID uint64
}
diff --git a/internal/source/disk/custom.go b/internal/source/disk/custom.go
index a7c89700..8a080f20 100644
--- a/internal/source/disk/custom.go
+++ b/internal/source/disk/custom.go
@@ -14,14 +14,14 @@ type customProjectResolver struct {
// TODO tests
func (p *customProjectResolver) Resolve(r *http.Request) (*serving.LookupPath, string, error) {
- project := &serving.LookupPath{
+ lookupPath := &serving.LookupPath{
Location: "/",
Path: p.path,
IsNamespaceProject: false,
IsHTTPSOnly: p.config.HTTPSOnly,
HasAccessControl: p.config.AccessControl,
- ID: p.config.ID,
+ ProjectID: p.config.ID,
}
- return project, r.URL.Path, nil
+ return lookupPath, r.URL.Path, nil
}
diff --git a/internal/source/disk/group.go b/internal/source/disk/group.go
index df093926..59aedc73 100644
--- a/internal/source/disk/group.go
+++ b/internal/source/disk/group.go
@@ -85,14 +85,14 @@ func (g *Group) Resolve(r *http.Request) (*serving.LookupPath, string, error) {
return nil, "", nil // it is not an error when project does not exist
}
- project := &serving.LookupPath{
+ lookupPath := &serving.LookupPath{
Location: location,
Path: filepath.Join(g.name, projectPath, "public"),
IsNamespaceProject: projectConfig.NamespaceProject,
IsHTTPSOnly: projectConfig.HTTPSOnly,
HasAccessControl: projectConfig.AccessControl,
- ID: projectConfig.ID,
+ ProjectID: projectConfig.ID,
}
- return project, subPath, nil
+ return lookupPath, subPath, nil
}