Skip to content
Snippets Groups Projects
Commit 829176ac authored by Nick Thomas's avatar Nick Thomas
Browse files

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.
parent 9851a84c
No related branches found
No related tags found
1 merge request!27Fix reading configuration for multiple custom domains
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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() {
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@
{
"Domain": "other.domain.com",
"Certificate": "test",
"Certificate": "key"
"Key": "key"
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment