diff options
author | Stan Hu <stanhu@gmail.com> | 2018-08-26 10:51:09 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-08-26 10:54:36 +0300 |
commit | 46c26d3bbb4ff0e55661b2143b8035bbfe002f8c (patch) | |
tree | b0802af70b315efc38dbfcf6f5eba69054c5c262 /internal | |
parent | 6e48bceb83147ef3093ba8c4d656af90cb4f4a37 (diff) |
Log duplicate domain names
This will help make it easier to track stale `config.json` files on disk.
Closes https://gitlab.com/gitlab-org/gitlab-pages/issues/160
Diffstat (limited to 'internal')
-rw-r--r-- | internal/domain/map.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/domain/map.go b/internal/domain/map.go index 30a8a74d..fb963fed 100644 --- a/internal/domain/map.go +++ b/internal/domain/map.go @@ -20,6 +20,20 @@ type Map map[string]*D type domainsUpdater func(Map) +func (dm Map) updateDomainMap(domainName string, domain *D) { + if old, ok := dm[domainName]; ok { + log.WithFields(log.Fields{ + "domain_name": domainName, + "new_group": domain.group, + "new_project_name": domain.projectName, + "old_group": old.group, + "old_project_name": old.projectName, + }).Error("Duplicate domain") + } + + dm[domainName] = domain +} + func (dm Map) addDomain(rootDomain, group, projectName string, config *domainConfig) { newDomain := &D{ group: group, @@ -29,7 +43,7 @@ func (dm Map) addDomain(rootDomain, group, projectName string, config *domainCon var domainName string domainName = strings.ToLower(config.Domain) - dm[domainName] = newDomain + dm.updateDomainMap(domainName, newDomain) } func (dm Map) updateGroupDomain(rootDomain, group, projectName string, httpsOnly bool) { |