Prepare the use of multiple domains
This commit is contained in:
parent
e44233b9a3
commit
dd29c8ce92
3 changed files with 27 additions and 18 deletions
|
|
@ -5,21 +5,29 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
AssociatedDomainSuffix = "adlin2022.p0m.fr."
|
||||
DelegatedDomainSuffix = "srs.p0m.fr."
|
||||
var (
|
||||
AssociatedDomainSuffixes = []string{"adlin2023.p0m.fr."}
|
||||
DelegatedDomainSuffixes = []string{"srs.p0m.fr."}
|
||||
)
|
||||
|
||||
func (student *Student) MyDelegatedDomainSuffix() string {
|
||||
return DelegatedDomainSuffixes[int(student.Id)%len(DelegatedDomainSuffixes)]
|
||||
}
|
||||
|
||||
func (student *Student) MyDelegatedDomain() string {
|
||||
if student.DelegatedDomain != nil {
|
||||
return *student.DelegatedDomain
|
||||
} else {
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), DelegatedDomainSuffix)
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), student.MyDelegatedDomainSuffix())
|
||||
}
|
||||
}
|
||||
|
||||
func (student *Student) MyAssociatedDomainSuffix() string {
|
||||
return AssociatedDomainSuffixes[int(student.Id)%len(AssociatedDomainSuffixes)]
|
||||
}
|
||||
|
||||
func (student *Student) DefaultAssociatedDomain() string {
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), AssociatedDomainSuffix)
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), student.MyAssociatedDomainSuffix())
|
||||
}
|
||||
|
||||
func (student *Student) MyAssociatedDomain() string {
|
||||
|
|
|
|||
Reference in a new issue