42 lines
887 B
Go
42 lines
887 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
|
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
|
|
"gopkg.in/yaml.v3"
|
|
"io/ioutil"
|
|
)
|
|
|
|
const CName = "config"
|
|
|
|
func NewFromFile(path string) (c *Config, err error) {
|
|
c = &Config{}
|
|
data, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err = yaml.Unmarshal(data, c); err != nil {
|
|
return nil, err
|
|
}
|
|
return
|
|
}
|
|
|
|
type Config struct {
|
|
Anytype Anytype `yaml:"anytype"`
|
|
GrpcServer GrpcServer `yaml:"grpcServer"`
|
|
Account Account `yaml:"account"`
|
|
APIServer APIServer `yaml:"apiServer"`
|
|
Nodes []Node `yaml:"nodes"`
|
|
Space Space `yaml:"space"`
|
|
}
|
|
|
|
func (c *Config) Init(a *app.App) (err error) {
|
|
logger.NewNamed("config").Info(fmt.Sprint(c.Space))
|
|
return
|
|
}
|
|
|
|
func (c Config) Name() (name string) {
|
|
return CName
|
|
}
|