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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-05 14:49:15 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-05 14:49:15 +0300
commit70634f8693394cca63bfe84d63888992f756ad5a (patch)
tree5e8078af69febf318ef6330b6c1aadaf685c6db8 /internal/source/domains.go
parentcafc4369750e608ac4be5b61240e90265fdcb5a5 (diff)
parent7f35a7b7c1dde36f695fd7f1627fa77d9d8d2be0 (diff)
Merge branch 'master' into feature/gb/gitlab-domains-source
* master: Check presence of GitLab API secret when building a domains source Make GitLab API Secret a supported parameter Improve error reporting in the main package Check if GitLab API secret has been provided too Avoid using `testify/assert` in favor of `require` Test domains source not fully configured Improve error handing when creating new domains config source Fix formatting in internal/source/gitlab/client/client_test.go Conflicts: acceptance_test.go internal/source/gitlab/client/client_test.go
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