package main

import (
	"io"
	"os"

	"gopkg.in/yaml.v3"
)

type (
	config struct {
		User     string     `yaml:"user"`
		Password string     `yaml:"password"`
		Watch    []*watchVm `yaml:"watch"`
	}
	watchVm struct {
		Name string `yaml:"name"`
		Addr string `yaml:"addr"`
	}
)

func parseConfig(file string) (*config, error) {
	cfgFile, err := os.Open(file)
	if err != nil {
		return nil, err
	}

	cfgBytes, err := io.ReadAll(cfgFile)
	if err != nil {
		return nil, err
	}

	var cfg config
	return &cfg, yaml.Unmarshal(cfgBytes, &cfg)
}
