any-sync/config/config.go
2022-09-08 12:05:30 +03:00

43 lines
919 B
Go

package config
import (
"context"
"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(ctx context.Context, a *app.App) (err error) {
logger.NewNamed("config").Info(fmt.Sprint(c.Space))
return
}
func (c Config) Name() (name string) {
return CName
}