From 5d0fe5edb596e758604b03a5bf8c3d2a52e661ca Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 6 May 2025 18:55:23 +0200 Subject: [PATCH] Remove plural structs not used as struct --- internal/storage/inmemory/domain.go | 4 ++-- internal/storage/inmemory/user.go | 2 +- internal/storage/interface.go | 2 +- internal/storage/leveldb/domain.go | 2 +- model/backup.go | 2 +- model/domain.go | 13 +++++-------- model/user.go | 5 +---- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/internal/storage/inmemory/domain.go b/internal/storage/inmemory/domain.go index dd71bba5..e36f7e30 100644 --- a/internal/storage/inmemory/domain.go +++ b/internal/storage/inmemory/domain.go @@ -36,11 +36,11 @@ func (s *InMemoryStorage) ListAllDomains() (storage.Iterator[happydns.Domain], e } // ListDomains retrieves all Domains associated to the given User. -func (s *InMemoryStorage) ListDomains(u *happydns.User) (happydns.Domains, error) { +func (s *InMemoryStorage) ListDomains(u *happydns.User) ([]*happydns.Domain, error) { s.mu.Lock() defer s.mu.Unlock() - var domains happydns.Domains + var domains []*happydns.Domain for _, domain := range s.domains { if domain.Owner.Equals(u.Id) { domains = append(domains, domain) diff --git a/internal/storage/inmemory/user.go b/internal/storage/inmemory/user.go index 751e2b37..212979a8 100644 --- a/internal/storage/inmemory/user.go +++ b/internal/storage/inmemory/user.go @@ -34,7 +34,7 @@ func (s *InMemoryStorage) ListAllUsers() (storage.Iterator[happydns.User], error } // ListUsers retrieves the list of known Users. -func (s *InMemoryStorage) ListUsers() (users happydns.Users, err error) { +func (s *InMemoryStorage) ListUsers() (users []*happydns.User, err error) { s.mu.Lock() defer s.mu.Unlock() diff --git a/internal/storage/interface.go b/internal/storage/interface.go index 6852323c..a6c29ce6 100644 --- a/internal/storage/interface.go +++ b/internal/storage/interface.go @@ -60,7 +60,7 @@ type DomainStorage interface { ListAllDomains() (Iterator[happydns.Domain], error) // ListDomains retrieves all Domains associated to the given User. - ListDomains(user *happydns.User) (happydns.Domains, error) + ListDomains(user *happydns.User) ([]*happydns.Domain, error) // GetDomain retrieves the Domain with the given id and owned by the given User. GetDomain(domainid happydns.Identifier) (*happydns.Domain, error) diff --git a/internal/storage/leveldb/domain.go b/internal/storage/leveldb/domain.go index 11ed3424..97c56deb 100644 --- a/internal/storage/leveldb/domain.go +++ b/internal/storage/leveldb/domain.go @@ -37,7 +37,7 @@ func (s *LevelDBStorage) ListAllDomains() (storage.Iterator[happydns.Domain], er return NewLevelDBIterator[happydns.Domain](s.db, iter), nil } -func (s *LevelDBStorage) ListDomains(u *happydns.User) (domains happydns.Domains, err error) { +func (s *LevelDBStorage) ListDomains(u *happydns.User) (domains []*happydns.Domain, err error) { iter := s.search("domain-") defer iter.Release() diff --git a/model/backup.go b/model/backup.go index 5464cd3b..5089adb5 100644 --- a/model/backup.go +++ b/model/backup.go @@ -23,7 +23,7 @@ package happydns type Backup struct { Version int - Domains Domains + Domains []*Domain DomainsLogs map[string][]*DomainLog Errors []string Providers []*ProviderMessage diff --git a/model/domain.go b/model/domain.go index 29722c76..004fa995 100644 --- a/model/domain.go +++ b/model/domain.go @@ -56,14 +56,6 @@ type Domain struct { ZoneHistory []Identifier `json:"zone_history" swaggertype:"array,string"` } -type DomainWithZoneMetadata struct { - *Domain - ZoneMeta map[string]*ZoneMeta `json:"zone_meta"` -} - -// Domains is an array of Domain. -type Domains []*Domain - // HasZone checks if the given Zone's identifier is part of this Domain // history. func (d *Domain) HasZone(zoneId Identifier) (found bool) { @@ -75,6 +67,11 @@ func (d *Domain) HasZone(zoneId Identifier) (found bool) { return } +type DomainWithZoneMetadata struct { + *Domain + ZoneMeta map[string]*ZoneMeta `json:"zone_meta"` +} + type DomainUsecase interface { ApplyZoneCorrection(*User, *Domain, *Zone, *ApplyZoneForm) (*Zone, error) ActionOnEditableZone(*User, *Domain, *Zone, func(*Zone) error) (*Zone, error) diff --git a/model/user.go b/model/user.go index d52521a8..3bcc7e83 100644 --- a/model/user.go +++ b/model/user.go @@ -31,7 +31,7 @@ type User struct { // Id is the User's identifier. Id Identifier `json:"id"` - // Email is the User's login and mean of contact. + // Email is the User's login and means of contact. Email string `json:"email"` // CreatedAt is the time when the User logs in for the first time. @@ -56,9 +56,6 @@ func (u *User) JoinNewsletter() bool { return false } -// Users is a group of User. -type Users []*User - type UserUsecase interface { ChangeUserSettings(*User, UserSettings) error CreateUser(UserInfo) (*User, error)