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>2017-04-24 19:31:28 +0300
committerNick Thomas <nick@gitlab.com>2017-04-24 19:36:52 +0300
commit829176ac76c1dc25373800824602261940fca121 (patch)
treeabb862b0ab1466be47c28d51d65e43bc5a53dd69
parent9851a84c2af522d982ce4a1f1b6521503b11c512 (diff)
Fix reading configuration for multiple custom domains
Without this patch, the different domains end up with pointers to the same domainsConfig struct, as go re-uses the same region of memory on each iteration of a for loop.
-rw-r--r--domains.go3
-rw-r--r--domains_test.go7
-rw-r--r--shared/pages/group/group.test.io/config.json2
3 files changed, 10 insertions, 2 deletions
diff --git a/domains.go b/domains.go
index d298b63b..1fed6324 100644
--- a/domains.go
+++ b/domains.go
@@ -44,8 +44,9 @@ func (d domains) readProjectConfig(rootDomain, group, project string) (err error
}
for _, domainConfig := range config.Domains {
+ config := domainConfig // domainConfig is reused for each loop iteration
if domainConfig.Valid(rootDomain) {
- d.addDomain(rootDomain, group, project, &domainConfig)
+ d.addDomain(rootDomain, group, project, &config)
}
}
return
diff --git a/domains_test.go b/domains_test.go
index 5a2882d6..6ce11f5f 100644
--- a/domains_test.go
+++ b/domains_test.go
@@ -40,6 +40,13 @@ func TestReadProjects(t *testing.T) {
for _, actual := range domains {
assert.Contains(t, expectedDomains, actual)
}
+
+ // Check that multiple domains in the same project are recorded faithfully
+ exp1 := &domainConfig{Domain: "test.domain.com"}
+ assert.Equal(t, exp1, d["test.domain.com"].Config)
+
+ exp2 := &domainConfig{Domain: "other.domain.com", Certificate: "test", Key: "key"}
+ assert.Equal(t, exp2, d["other.domain.com"].Config)
}
func writeRandomTimestamp() {
diff --git a/shared/pages/group/group.test.io/config.json b/shared/pages/group/group.test.io/config.json
index 1643525d..5b9be1fd 100644
--- a/shared/pages/group/group.test.io/config.json
+++ b/shared/pages/group/group.test.io/config.json
@@ -9,7 +9,7 @@
{
"Domain": "other.domain.com",
"Certificate": "test",
- "Certificate": "key"
+ "Key": "key"
}
]
}