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>2020-08-20 17:21:12 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2020-08-20 18:45:07 +0300
commitec8f8b27bca9471f67a64fec23eb1eb3b08ccde0 (patch)
tree3e843175e1ceab4c3813dacb63482f2e0f113eb9
parentf56500fa8d30838e25383910cf0b120ce2be65da (diff)
Rename `serving/disk/New()` to `serving/disk/Instance()`rename-disk-new-to-instance
The `Instance()` is a correct name for this, as we do not allocate a `Disk` each time, rather return a singleton object.
-rw-r--r--internal/domain/domain.go2
-rw-r--r--internal/domain/domain_test.go2
-rw-r--r--internal/serving/disk/serving.go4
-rw-r--r--internal/serving/disk/serving_test.go2
-rw-r--r--internal/source/disk/custom.go2
-rw-r--r--internal/source/disk/group.go4
-rw-r--r--internal/source/gitlab/factory.go4
7 files changed, 10 insertions, 10 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index 7c1639a3..4fa00cd6 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -44,7 +44,7 @@ func (d *Domain) resolve(r *http.Request) *serving.Request {
// TODO improve code around default serving, when `disk` serving gets removed
// https://gitlab.com/gitlab-org/gitlab-pages/issues/353
if request == nil {
- return &serving.Request{Serving: disk.New()}
+ return &serving.Request{Serving: disk.Instance()}
}
return request
diff --git a/internal/domain/domain_test.go b/internal/domain/domain_test.go
index 26a7735c..5fa5d792 100644
--- a/internal/domain/domain_test.go
+++ b/internal/domain/domain_test.go
@@ -23,7 +23,7 @@ type stubbedResolver struct {
func (resolver *stubbedResolver) Resolve(*http.Request) (*serving.Request, error) {
return &serving.Request{
- Serving: disk.New(),
+ Serving: disk.Instance(),
LookupPath: resolver.project,
SubPath: resolver.subpath,
}, resolver.err
diff --git a/internal/serving/disk/serving.go b/internal/serving/disk/serving.go
index b7501b80..a38124ef 100644
--- a/internal/serving/disk/serving.go
+++ b/internal/serving/disk/serving.go
@@ -36,8 +36,8 @@ func (s *Disk) ServeNotFoundHTTP(h serving.Handler) {
httperrors.Serve404(h.Writer)
}
-// New returns a serving instance that is capable of reading files
+// Instance returns a serving instance that is capable of reading files
// from the disk
-func New() serving.Serving {
+func Instance() serving.Serving {
return disk
}
diff --git a/internal/serving/disk/serving_test.go b/internal/serving/disk/serving_test.go
index 02b7fac7..60fb4180 100644
--- a/internal/serving/disk/serving_test.go
+++ b/internal/serving/disk/serving_test.go
@@ -15,7 +15,7 @@ import (
func TestDisk_ServeFileHTTP(t *testing.T) {
defer setUpTests(t)()
- s := New()
+ s := Instance()
w := httptest.NewRecorder()
r := httptest.NewRequest("GET", "http://group.gitlab-example.com/serving/index.html", nil)
handler := serving.Handler{
diff --git a/internal/source/disk/custom.go b/internal/source/disk/custom.go
index 2668ed81..4d991437 100644
--- a/internal/source/disk/custom.go
+++ b/internal/source/disk/custom.go
@@ -24,7 +24,7 @@ func (p *customProjectResolver) Resolve(r *http.Request) (*serving.Request, erro
}
return &serving.Request{
- Serving: disk.New(),
+ Serving: disk.Instance(),
LookupPath: lookupPath,
SubPath: r.URL.Path,
}, nil
diff --git a/internal/source/disk/group.go b/internal/source/disk/group.go
index e0365bbd..f161f9f7 100644
--- a/internal/source/disk/group.go
+++ b/internal/source/disk/group.go
@@ -84,7 +84,7 @@ func (g *Group) Resolve(r *http.Request) (*serving.Request, error) {
if projectConfig == nil {
// it is not an error when project does not exist, in that case
// serving.Request.LookupPath is nil.
- return &serving.Request{Serving: disk.New()}, nil
+ return &serving.Request{Serving: disk.Instance()}, nil
}
lookupPath := &serving.LookupPath{
@@ -97,7 +97,7 @@ func (g *Group) Resolve(r *http.Request) (*serving.Request, error) {
}
return &serving.Request{
- Serving: disk.New(),
+ Serving: disk.Instance(),
LookupPath: lookupPath,
SubPath: subPath,
}, nil
diff --git a/internal/source/gitlab/factory.go b/internal/source/gitlab/factory.go
index d526994f..b10dee37 100644
--- a/internal/source/gitlab/factory.go
+++ b/internal/source/gitlab/factory.go
@@ -31,7 +31,7 @@ func fabricateServing(lookup api.LookupPath) serving.Serving {
switch source.Type {
case "file":
- return disk.New()
+ return disk.Instance()
case "serverless":
serving, err := serverless.NewFromAPISource(source.Serverless)
if err != nil {
@@ -47,5 +47,5 @@ func fabricateServing(lookup api.LookupPath) serving.Serving {
}
func defaultServing() serving.Serving {
- return disk.New()
+ return disk.Instance()
}