mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-23 02:36:42 +00:00
extend example
This commit is contained in:
1
management/refactor/resources/settings/api.go
Normal file
1
management/refactor/resources/settings/api.go
Normal file
@@ -0,0 +1 @@
|
||||
package settings
|
||||
21
management/refactor/resources/settings/manager.go
Normal file
21
management/refactor/resources/settings/manager.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package settings
|
||||
|
||||
import "github.com/netbirdio/netbird/management/refactor/resources/settings/types"
|
||||
|
||||
type Manager interface {
|
||||
GetSettings(accountID string) (types.Settings, error)
|
||||
}
|
||||
|
||||
type DefaultManager struct {
|
||||
repository Repository
|
||||
}
|
||||
|
||||
func NewDefaultManager(repository Repository) *DefaultManager {
|
||||
return &DefaultManager{
|
||||
repository: repository,
|
||||
}
|
||||
}
|
||||
|
||||
func (dm *DefaultManager) GetSettings(accountID string) (types.Settings, error) {
|
||||
return dm.repository.FindSettings(accountID)
|
||||
}
|
||||
7
management/refactor/resources/settings/repository.go
Normal file
7
management/refactor/resources/settings/repository.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package settings
|
||||
|
||||
import "github.com/netbirdio/netbird/management/refactor/resources/settings/types"
|
||||
|
||||
type Repository interface {
|
||||
FindSettings(accountID string) (types.Settings, error)
|
||||
}
|
||||
34
management/refactor/resources/settings/types/settings.go
Normal file
34
management/refactor/resources/settings/types/settings.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package types
|
||||
|
||||
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