mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-20 01:06:45 +00:00
add example setup for management refactor
This commit is contained in:
19
management/refactor/settings/manager.go
Normal file
19
management/refactor/settings/manager.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package settings
|
||||
|
||||
type Manager interface {
|
||||
GetSettings(accountID string) (Settings, error)
|
||||
}
|
||||
|
||||
type DefaultManager struct {
|
||||
repository repository
|
||||
}
|
||||
|
||||
func NewDefaultManager(repository repository) *DefaultManager {
|
||||
return &DefaultManager{
|
||||
repository: repository,
|
||||
}
|
||||
}
|
||||
|
||||
func (dm *DefaultManager) GetSettings(accountID string) (Settings, error) {
|
||||
return dm.repository.FindSettings(accountID)
|
||||
}
|
||||
5
management/refactor/settings/repository.go
Normal file
5
management/refactor/settings/repository.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package settings
|
||||
|
||||
type repository interface {
|
||||
FindSettings(accountID string) (Settings, error)
|
||||
}
|
||||
34
management/refactor/settings/settings.go
Normal file
34
management/refactor/settings/settings.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package settings
|
||||
|
||||
import "time"
|
||||
|
||||
type Settings interface {
|
||||
GetLicense() string
|
||||
GetPeerLoginExpiration() time.Duration
|
||||
SetPeerLoginExpiration(duration time.Duration)
|
||||
GetPeerLoginExpirationEnabled() bool
|
||||
SetPeerLoginExpirationEnabled(bool)
|
||||
}
|
||||
|
||||
type DefaultSettings struct {
|
||||
}
|
||||
|
||||
func (s *DefaultSettings) GetLicense() string {
|
||||
return "selfhosted"
|
||||
}
|
||||
|
||||
func (s *DefaultSettings) GetPeerLoginExpiration() time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (s *DefaultSettings) SetPeerLoginExpiration(duration time.Duration) {
|
||||
|
||||
}
|
||||
|
||||
func (s *DefaultSettings) GetPeerLoginExpirationEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *DefaultSettings) SetPeerLoginExpirationEnabled(bool) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user