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:
Diffstat (limited to 'internal/source/domains.go')
-rw-r--r--internal/source/domains.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/internal/source/domains.go b/internal/source/domains.go
index f47884ef..85d06152 100644
--- a/internal/source/domains.go
+++ b/internal/source/domains.go
@@ -36,11 +36,20 @@ type Domains struct {
// NewDomains is a factory method for domains initializing a mutex. It should
// not initialize `dm` as we later check the readiness by comparing it with a
// nil value.
-func NewDomains(config Config) *Domains {
+func NewDomains(config Config) (*Domains, error) {
+ if len(config.GitlabServerURL()) == 0 || len(config.GitlabAPISecret()) == 0 {
+ return &Domains{disk: disk.New()}, nil
+ }
+
+ gitlab, err := gitlab.New(config)
+ if err != nil {
+ return nil, err
+ }
+
return &Domains{
+ gitlab: gitlab,
disk: disk.New(),
- gitlab: gitlab.New(config),
- }
+ }, nil
}
// GetDomain retrieves a domain information from a source. We are using two
@@ -69,6 +78,10 @@ func (d *Domains) IsReady() bool {
}
func (d *Domains) source(domain string) Source {
+ if d.gitlab == nil {
+ return d.disk
+ }
+
for _, name := range newSourceDomains {
if domain == name {
return d.gitlab