mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
53 lines
811 B
Go
53 lines
811 B
Go
package config
|
|
|
|
import "fmt"
|
|
|
|
type dummyStore struct{}
|
|
|
|
// NewDummyStore returns a store that returns the default config
|
|
func NewDummyStore() Store {
|
|
return &dummyStore{}
|
|
}
|
|
|
|
func (c *dummyStore) Get() *Config {
|
|
cfg := New()
|
|
|
|
cfg.DB.Dir = "."
|
|
cfg.Storage.Disk.Dir = "."
|
|
|
|
return cfg
|
|
}
|
|
|
|
func (c *dummyStore) Set(d *Config) error {
|
|
d.Validate(true)
|
|
|
|
if d.HasErrors() {
|
|
return fmt.Errorf("configuration data has errors after validation")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *dummyStore) GetActive() *Config {
|
|
cfg := New()
|
|
|
|
cfg.DB.Dir = "."
|
|
cfg.Storage.Disk.Dir = "."
|
|
|
|
return cfg
|
|
}
|
|
|
|
func (c *dummyStore) SetActive(d *Config) error {
|
|
d.Validate(true)
|
|
|
|
if d.HasErrors() {
|
|
return fmt.Errorf("configuration data has errors after validation")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *dummyStore) Reload() error {
|
|
return nil
|
|
}
|