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>2020-08-28 06:58:46 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-08-28 06:58:46 +0300
commit8680dd6889cf601888a7a740e98913ba13e7c102 (patch)
tree3f9bce35efd71ce3e10f2ba4d5026ea3fb9df42e /internal/source
parent621dcafd3d1f75b846e67a77ed17dc0d704f10e3 (diff)
Revert "Start reading when disk is initialized"
This reverts commit 621dcafd3d1f75b846e67a77ed17dc0d704f10e3.
Diffstat (limited to 'internal/source')
-rw-r--r--internal/source/disk/disk.go15
-rw-r--r--internal/source/domains.go14
-rw-r--r--internal/source/domains_test.go7
-rw-r--r--internal/source/gitlab/client/config.go1
4 files changed, 21 insertions, 16 deletions
diff --git a/internal/source/disk/disk.go b/internal/source/disk/disk.go
index d0dd11d7..272d6c4e 100644
--- a/internal/source/disk/disk.go
+++ b/internal/source/disk/disk.go
@@ -18,15 +18,10 @@ type Disk struct {
// New is a factory method for the Disk source. It is initializing a mutex. It
// should not initialize `dm` as we later check the readiness by comparing it
// with a nil value.
-func New(rootDomain string) *Disk {
- d := &Disk{
+func New() *Disk {
+ return &Disk{
lock: &sync.RWMutex{},
}
-
- // start reading domain configuration from disk concurrently
- go Watch(rootDomain, d.updateDomains, time.Second)
-
- return d
}
// GetDomain returns a domain from the domains map if it exists
@@ -46,6 +41,12 @@ func (d *Disk) IsReady() bool {
return d.dm != nil
}
+// Read starts the domain source, in this case it is reading domains from
+// groups on disk concurrently.
+func (d *Disk) Read(rootDomain string) {
+ go Watch(rootDomain, d.updateDomains, time.Second)
+}
+
func (d *Disk) updateDomains(dm Map) {
d.lock.Lock()
defer d.lock.Unlock()
diff --git a/internal/source/domains.go b/internal/source/domains.go
index f8dbbcb9..2a7a317c 100644
--- a/internal/source/domains.go
+++ b/internal/source/domains.go
@@ -51,6 +51,7 @@ func NewDomains(config Config) (*Domains, error) {
// returns error if -domain-config-source is not valid
// returns error if -domain-config-source=gitlab and init fails
func (d *Domains) setConfigSource(config Config) error {
+ // TODO: Handle domain-config-source=auto https://gitlab.com/gitlab-org/gitlab/-/issues/218358
// attach gitlab by default when source is not disk (auto, gitlab)
switch config.DomainConfigSource() {
case "gitlab":
@@ -60,12 +61,12 @@ func (d *Domains) setConfigSource(config Config) error {
// TODO: handle DomainConfigSource == "auto" https://gitlab.com/gitlab-org/gitlab/-/issues/218358
d.configSource = sourceAuto
// enable disk for auto for now
- d.disk = disk.New(config.RootDomain())
+ d.disk = disk.New()
return d.setGitLabClient(config)
case "disk":
// TODO: disable domains.disk https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382
d.configSource = sourceDisk
- d.disk = disk.New(config.RootDomain())
+ d.disk = disk.New()
default:
return fmt.Errorf("invalid option for -domain-config-source: %q", config.DomainConfigSource())
}
@@ -102,6 +103,15 @@ func (d *Domains) GetDomain(name string) (*domain.Domain, error) {
return d.source(name).GetDomain(name)
}
+// Read starts the disk domain source. It is DEPRECATED, because we want to
+// remove it entirely when disk source gets removed.
+func (d *Domains) Read(rootDomain string) {
+ // start disk.Read for sourceDisk and sourceAuto
+ if d.configSource != sourceGitlab {
+ d.disk.Read(rootDomain)
+ }
+}
+
// IsReady checks if the disk domain source managed to traverse entire pages
// filesystem and is ready for use. It is DEPRECATED, because we want to remove
// it entirely when disk source gets removed.
diff --git a/internal/source/domains_test.go b/internal/source/domains_test.go
index 617e96c9..36c53e6f 100644
--- a/internal/source/domains_test.go
+++ b/internal/source/domains_test.go
@@ -11,16 +11,11 @@ import (
)
type sourceConfig struct {
- rootDomain string
api string
secret string
domainSource string
}
-func (c sourceConfig) RootDomain() string {
- return c.rootDomain
-}
-
func (c sourceConfig) InternalGitLabServerURL() string {
return c.api
}
@@ -196,6 +191,6 @@ func newTestDomains(t *testing.T, gitlabSource *MockSource, config configSource)
return &Domains{
configSource: config,
gitlab: gitlabSource,
- disk: disk.New("gitlab.io"),
+ disk: disk.New(),
}
}
diff --git a/internal/source/gitlab/client/config.go b/internal/source/gitlab/client/config.go
index f2bd1a2e..bd9aa061 100644
--- a/internal/source/gitlab/client/config.go
+++ b/internal/source/gitlab/client/config.go
@@ -5,7 +5,6 @@ import "time"
// Config represents an interface that is configuration provider for client
// capable of comunicating with GitLab
type Config interface {
- RootDomain() string
InternalGitLabServerURL() string
GitlabAPISecret() []byte
GitlabClientConnectionTimeout() time.Duration