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:
authorNick Thomas <nick@gitlab.com>2019-12-04 18:59:40 +0300
committerNick Thomas <nick@gitlab.com>2019-12-04 18:59:40 +0300
commit7f35a7b7c1dde36f695fd7f1627fa77d9d8d2be0 (patch)
tree3c2cb02406644a0b233ec90fe95aaaab4b93847a /internal/source/domains.go
parentb535811a888f52fc44925cc7abd3295b0e44903e (diff)
parent6b76b603ec5296666ec48d2e736cc66648f29504 (diff)
Merge branch 'fix/gb/improve-error-reporting-in-client' into 'master'
Improve error handing when creating new domains config source Closes #275 See merge request gitlab-org/gitlab-pages!205
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