package main

import (
	"log"
	"os"

	"github.com/stretchr/testify/assert/yaml"
)

type RaspberryPi struct {
	Name     string `yaml:"name"`
	Hostname string `yaml:"hostname"`
	Port     string `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password,omitempty"` // optional
}

type RaspiConfig struct {
	Raspis []RaspberryPi `yaml:"raspis"`
}

func readConfig() RaspiConfig {
	data, err := os.ReadFile("raspis.yaml")
	if err != nil {
		log.Fatalf("Failed to read config YAML file (raspis.yaml): %v", err)
	}

	var cfg RaspiConfig
	if err := yaml.Unmarshal(data, &cfg); err != nil {
		log.Fatalf("Failed to parse YAML file (raspis.yaml): %v", err)
	}

	return cfg
}
