Remove the subdomain when removing the last service of a subdomain

This commit is contained in:
nemunaire 2020-06-14 23:25:02 +02:00
parent 35fbb1625e
commit 19f0390454
1 changed files with 5 additions and 1 deletions

View File

@ -82,7 +82,11 @@ func (z *Zone) EraseService(subdomain string, origin string, id []byte, s *Servi
if subdomain == "" && svc.Type == "svcs.Origin" {
return errors.New("You cannot delete this service. It is mandatory.")
}
z.Services[subdomain] = append(z.Services[subdomain][:k], z.Services[subdomain][k+1:]...)
if len(z.Services[subdomain]) <= 1 {
delete(z.Services, subdomain)
} else {
z.Services[subdomain] = append(z.Services[subdomain][:k], z.Services[subdomain][k+1:]...)
}
} else {
s.Comment = s.GenComment(origin)
s.NbResources = s.GetNbResources()