package server

import (
	"fmt"
	"os"

	"gopkg.in/yaml.v3"
)

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	Dbname   string
	Path     string
}

var Conf *Config

func ReadConf(filename string) error {
	buf, err := os.ReadFile(filename)
	if err != nil {
		return err
	}

	c := &Config{}
	err = yaml.Unmarshal(buf, c)
	if err != nil {
		return fmt.Errorf("in file %q: %w", filename, err)
	}
	Conf = c
	return err
}
